Closed

Ruby Necklace program in any language accepted

Ruby Necklace

It is the wedding day of Sanchi, the beautiful princess of Byteland. Her fiance Krishna is planning to gift her an awesome ruby necklace. Krishna has currently b -blue rubies, g -green rubies, r-red rubies and y -yellow rubies. He has to arrange the rubies next to each other in a straight line to make the necklace. But, there are a couple of rules to be followed while making this necklace:

A blue ruby should be followed by either a blue ruby or a red ruby

A green ruby should be followed by either a green ruby or a yellow ruby

A red ruby should be followed by either a green ruby or a yellow ruby

A yellow ruby should be followed by either a blue ruby or a red ruby

If it is possible, we should always start a necklace with a blue or a red ruby

Can you tell what is the maximum possible length of the necklace that Krishna can make. The length of a necklace is the number of rubies in it.

Input Format

The first line contains an integer representing b.

The second line contains an integer representing r.

The third line contains an integer representing y.

The fourth line contains an integer representing g.

Constraints

0 <= b, r, y, g <= 2000

At least one of b, r, y, g is greater than 0

Output Format

A single integer which is the answer to the problem.

Skills: Git, PHP, Python, Ruby, Ruby on Rails

See more: string necklace program in c, string necklace program in java, necklace program c++, codechef python problems, codechef python submission, codechef java sample, codechef solutions to problems, codechef problems solutions pdf, medical shop maintance program language, create data entry program language, card shuffling program language, matrix multiplication program language, multiply matris program language assembelly, ninja trader program language, program language travian, hospital management system program language coding, written program language, karnaugh mapping program language, sorting program language, simple stack program language

About the Employer:
( 0 reviews ) India

Project ID: #16688962

4 freelancers are bidding on average ₹249/hour for this job

pluralcode16

Greetings!! I am glad to bid for your project. I am a web developer & designer. I have a experience of more than 4 years in technologies like Android, Ruby on Rails, PHP, Django, Python, Ruby programming languag More

₹166 INR / hour
(8 Reviews)
4.4
megistoeditor

Sir, I am a web & WordPress developer and have four year of experience.I also have samples about it.I will do this project at cheapest rates with satisfactory work for you. Only thing that i need is your review. And i More

₹277 INR / hour
(0 Reviews)
0.0
vasundharamehta

I can create this program for you. I would prefer to do it in Java. Do you have any test cases? I could use them for testing the code. I can provide references from another site where I have been working for the pa More

₹277 INR / hour
(0 Reviews)
0.0
₹277 INR / hour
(0 Reviews)
0.0