fork download
  1. import Control.Applicative
  2. import Data.List
  3.  
  4. main = putStrLn $ unlines [concat [show $ count (x, y)|x<-[0..7]]| y<-[0..7]]
  5.  
  6. count pos = maybe 0 id $ findIndex (elem pos) positions
  7.  
  8. positions = iterate next [(0,0)]
  9. next x = g ((map p $ ((,)<$>[1,-1]<*>[2,-2]) ++ ((,)<$>[2,-2]<*>[1,-1])) <*> x)
  10. p (a,b) (c,d) = (a+c, b+d)
  11. g = filter (\(x, y) -> 0 <= x && 0 <= y)
  12.  
Success #stdin #stdout 0s 6268KB
stdin
Standard input is empty
stdout
03232345
34123434
21432345
32323434
23234345
34343454
43434545
54545456