Project Euler Problem 036
import Control.Monad import Data.Char ispalin :: (Eq a, Num a) => [a] -> Bool ispalin l@(x:_) = x/=0 && reverse l == l num2b :: Integer -> [Integer] num2b = reverse . imp where imp 0 = [] imp n = rem n 2:imp(quot n 2) an :: Integer -> [Integer] an n = [x | x<-[1..n],ispalin $ num2b x,ispalin (map digitToInt $ show x)] ans1 :: Integer ans1 = sum $ an 1000000 -- コンパイルして0.6sec -- 872187 main :: IO () main = print ans1