SHARE
TWEET

Untitled

tin6tety Apr 21st, 2019 90 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.         if ($redEggs > $maxEggs){
  18.             $maxEggs = $redEggs;
  19.             $colorNameMax = $redEggs;    
  20.         }
  21.     }
  22.     if ($color == "orange") {
  23.         $orangeEggs++;
  24.         if ($orangeEggs > $maxEggs){
  25.             $maxEggs = $orangeEggs;
  26.             $colorNameMax = $orangeEggs;
  27.         }
  28.     }
  29.     if ($color == "blue") {
  30.         $blueEggs++;
  31.         if ($blueEggs > $maxEggs){
  32.             $maxEggs = $blueEggs;
  33.             $colorNameMax = $blueEggs;
  34.         }
  35.     }
  36.     if ($color == "green") {
  37.         $greenEggs++;
  38.         if ($greenEggs > $maxEggs){
  39.             $maxEggs = $greenEggs;
  40.             $colorNameMax = $greenEggs;
  41.         }
  42.     }
  43. }
  44.  
  45. echo "Red eggs: $redEggs" . PHP_EOL;
  46. echo "Orange eggs: $orangeEggs" . PHP_EOL;
  47. echo "Blue eggs: $blueEggs" . PHP_EOL;
  48. echo "Green eggs: $greenEggs" . PHP_EOL;
  49. echo "Max eggs: $maxEggs -> $colorNameMax";
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top