# PB - Easter Eggs

Jun 4th, 2020
76
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. function solve(input) {
2.     let index = 0;
3.     let num = input[index];
4.     index++;
5.
6.     let redEggs = 0;
7.     let orangeEggs = 0;
8.     let blueEggs = 0;
9.     let greenEggs = 0;
10.
11.     let colour = input[index];
12.     index++;
13.
14.     for(let i = 1; i <= num; i++) {
15.         switch(colour) {
16.             case 'red': redEggs++; break;
17.             case 'orange': orangeEggs++; break;
18.             case 'blue': blueEggs++; break;
19.             case 'green': greenEggs++; break;
20.         }
21.     }
22.         let maxNumber = redEggs;
23.         let maxColour = "red";
24.         if(orangeEggs > maxNumber) {
25.             maxColour = "orange";
26.         } if(blueEggs > maxNumber) {
27.             maxColour = "blue";
28.         } if(greenEggs > maxNumber) {
29.             maxColour = "green";
30.         }
31.
32.       console.log(`Red eggs: \${redEggs}`);
33.       console.log(`Orange eggs: \${orangeEggs}`);
34.       console.log(`Blue eggs: \${blueEggs}`);
35.       console.log(`Green eggs: \${greenEggs}`);
36.       console.log(`Max eggs: \${maxNumber} -> \${colour}`);
37. }
RAW Paste Data