Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $maxEggs = PHP_INT_MIN;
- $eggsCount = intval(readline());
- $redEggs = 0;
- $orangeEggs = 0;
- $blueEggs = 0;
- $greenEggs = 0;
- for ($i = 0; $i <= $eggsCount; $i++) {
- $color = readline();
- if ($color == "red") {
- $redEggs ++;
- }
- if ($color == "orange") {
- $orangeEggs ++;
- }
- if ($color == "blue") {
- $blueEggs ++;
- }
- if ($color == "green") {
- $greenEggs ++;
- }
- if ($eggsCount > $maxEggs) {
- $maxEggs = $eggsCount;
- $colorNameMax = $color;
- }
- }
- echo "Red eggs: $redEggs" . PHP_EOL;
- echo "Orange eggs: $orangeEggs" . PHP_EOL;
- echo "Blue eggs: $blueEggs" . PHP_EOL;
- echo "Green eggs: $greenEggs" . PHP_EOL;
- echo "Max eggs: $maxEggs -> $colorNameMax";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement