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 ($redEggs > $maxEggs){
- $maxEggs = $redEggs;
- $colorNameMax = $redEggs;
- }
- }
- if ($color == "orange") {
- $orangeEggs++;
- if ($orangeEggs > $maxEggs){
- $maxEggs = $orangeEggs;
- $colorNameMax = $orangeEggs;
- }
- }
- if ($color == "blue") {
- $blueEggs++;
- if ($blueEggs > $maxEggs){
- $maxEggs = $blueEggs;
- $colorNameMax = $blueEggs;
- }
- }
- if ($color == "green") {
- $greenEggs++;
- if ($greenEggs > $maxEggs){
- $maxEggs = $greenEggs;
- $colorNameMax = $greenEggs;
- }
- }
- }
- 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