fork download
  1. data Color = White | Blue | Red | Green | Yellow deriving (Show, Eq)
  2.  
  3. next :: Color -> [Color]
  4. next color = case color of
  5. White -> [Blue]
  6. Blue -> [White, Red]
  7. Red -> [Blue, Green]
  8. Green -> [Red, Yellow]
  9. Yellow -> [Green]
  10.  
  11. count :: [Color] -> Int -> Int
  12. count col 1 = length col
  13. count col n = count (col >>= next) (n-1)
  14.  
  15. main = mapM_ print $ map (count [White, Blue, Red, Green, Yellow]) [1..8]
Success #stdin #stdout 0.01s 3584KB
stdin
Standard input is empty
stdout
5
8
14
24
42
72
126
216