tin6tety

Untitled

Apr 21st, 2019
97
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3.  
  4. $maxEggs = PHP_INT_MIN;
  5. $eggsCount = intval(readline());
  6.  
  7. $redEggs = 0;
  8. $orangeEggs = 0;
  9. $blueEggs = 0;
  10. $greenEggs = 0;
  11.  
  12.  
  13. for ($i = 0; $i <= $eggsCount; $i++) {
  14.     $color = readline();
  15.     if ($color == "red") {
  16.         $redEggs ++;
  17.     }
  18.     if ($color == "orange") {
  19.         $orangeEggs ++;
  20.     }
  21.     if ($color == "blue") {
  22.         $blueEggs ++;
  23.     }
  24.     if ($color == "green") {
  25.         $greenEggs ++;
  26.     }
  27.     if ($eggsCount > $maxEggs) {
  28.         $maxEggs = $eggsCount;
  29.         $colorNameMax = $color;
  30.     }
  31. }
  32.  
  33. echo "Red eggs: $redEggs" . PHP_EOL;
  34. echo "Orange eggs: $orangeEggs" . PHP_EOL;
  35. echo "Blue eggs: $blueEggs" . PHP_EOL;
  36. echo "Green eggs: $greenEggs" . PHP_EOL;
  37. echo "Max eggs: $maxEggs -> $colorNameMax";
RAW Paste Data