Ruby Halloween Challenge

HALLOWEEN RUBY CODING CHALLENGE

Ruby Halloween Challenge
Write the Candy Factory Software and Save Halloween!

Candy orders will be given to you & will you have to produce a string Clinica Stomatologie Bucuresti curs valutar crama lechinta Psiholog Cluj which represents the packaged candy in the correct order. Candy can be of different colors & you have to use the first letter of each color to represent each candy (Y for yellow, G for green, R for red, etc.)

According to the Candy Factory operator's manual you must follow two rules when packaging the candy.

Rule #1 - Green candy can't come after red candy

Rule #2 - Two yellow candies must have a blue or green candy between them (if available)

Here are some example runs of a working candy factory (you can use this to verify your results):

Input: { red: 3, green: 4, yellow: 7, blue: 3 }

Output: GYBYBYBYGYGYGYRRR

Input: { red: 2, green: 3, yellow: 2, blue: 3 }

Output: GGGYBYRRBB

Note that any output combination is fine as long as it follows the two rules above.

Have fun!

Made by Jesus Castello for Blackbytes.info subscribers.

Popular posts