Advertisement
Spocoman

Easter Eggs

Oct 7th, 2024
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 1.01 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. func main() {
  6.     var quantity, red, orange, blue, green, maxCount int
  7.     fmt.Scanln(&quantity)
  8.    
  9.     var color, maxColor string
  10.  
  11.     for i := 0; i < quantity; i++ {
  12.         fmt.Scanln(&color)
  13.         switch color {
  14.         case "red":
  15.             red++
  16.         case "orange":
  17.             orange++
  18.         case "blue":
  19.             blue++
  20.         case "green":
  21.             green++
  22.         }
  23.     }
  24.  
  25.     if red > orange && red > blue && red > green {
  26.         maxCount = red
  27.         maxColor = "red"
  28.     } else if orange > blue && orange > green && orange > red {
  29.         maxCount = orange
  30.         maxColor = "orange"
  31.     } else if blue > green && blue > red && blue > orange {
  32.         maxCount = blue
  33.         maxColor = "blue"
  34.     } else {
  35.         maxCount = green
  36.         maxColor = "green"
  37.     }
  38.  
  39.     fmt.Printf("Red eggs: %d\nOrange eggs: %d\nBlue eggs: %d\nGreen eggs: %d\nMax eggs: %d -> %s",
  40.                   red, orange, blue, green, maxCount, maxColor)
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement