Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

You will be given a text string to find the hidden eggs ant their amount.

Read them
and mark the ones that are valid, considering the folowing rules:
1. Egg's colour:
1.1 Surrounded by one or more "@" or "#" (they don't have been the same).
1.2 It is written with lower case alphabeticals letters only.
1.3 Each colour shoud be minimum three letters only.
2. Amount:
2.1 Always positioned after the colour.
2.2 Between the colour and the amount thete could or could not be any other
characters. If there are, they must not be alphabetical letters or digits.
Otherwise, the colour-amount combinationis invalid.
2.3 Surrounded be one or more "/".
2.4 Contains only digits.
2.5 If the colour or the amount is not valid, we consider that the colour-amount
combination is not valid.

Examples of valid eggs: "@red@*/54/", "#green##//2//", "@@@yellow#@*/%^&/36/",


"@#blue@*/1//"
Examples of invalid eggs: "##@InvalidColour##/54/", "@notc010r@*23*",
"invalid_colour@/notnumber/"

Next, you will have to print all the valid eggs like following:

"You found {amount} {colour} eggs!"

I want every colour-amount combination to be printed on new line.

if i have this primary input:


"@@@@green@*/10/@yel0w@*26*#red#####//8//@limon*@*23*@@@red#*/%^&/6/@gree_een@/
notnumber/###purple@@@@@*$%^&*/5/"

I want to get this output:


"You found 10 green eggs!"
"You found 8 red eggs!"
"You found 6 red eggs!"
"You found 5 purple eggs!"

You might also like