Problem 142
http://projecteuler.net/index.php?section=problems&id=142
悪いコードである。最小性の保証?何それ、食べられるの?
import Control.Monad import Data.List isSqrt n = (n==).(^2).sqrt'$n sqrt' = floor.sqrt.fromIntegral main = print.head.sort$ p142 lim = 1000 p142 = do b <-map(^2)[1..lim] a <-dropWhile(<2*(sqrt' b)).map(^2)$[1..lim] guard.isSqrt$ a+b c <-dropWhile(<2*(sqrt'$ a+b)).map(^2)$[1..sqrt' b] guard$ mod (b+c) 2 == 0 && mod (b-c) 2 == 0 guard$ isSqrt (a+c) && isSqrt (a+b+c) return$ a+div (3*b+c) 2
オイラーはこれを解いたそうな。まったく「すごい」の一言に尽きる。