Problem 151

http://projecteuler.net/index.php?section=problems&id=151
はじめは変数名ミスでループに陥っていた。

main = print.expect$(1,1,1,1)

expect (0,0,0,1) = 0
expect (0,0,1,0) = 1
expect (0,1,0,0) = expect(0,0,1,1) + 1
expect (1,0,0,0) = expect(0,1,1,1) + 1
expect (x,y,z,w) = (x*select2 + y*select3 + z*select4 + w*select5)/(x+y+z+w)
    where select2 | x > 0 = expect (x-1,y+1,z+1,w+1)
                  | otherwise = 0
          select3 | y > 0 = expect(x,y-1,z+1,w+1)
                  | otherwise = 0
          select4 | z > 0 = expect(x,y,z-1,w+1)
                  | otherwise = 0
          select5 | w > 0 = expect(x,y,z,w-1)
                  | otherwise = 0

指数だとかいう話もあるが高々16か15なので、気にしないことにした。