2011-09-25から1日間の記事一覧

problem 40

着陸したら全く終わらなかった。 main = print $ p p = map (d.(10^)) [0..6] d x = (g 190000)!!(x-1) g x = foldl f "" [1..x] where f x y = x++(show y)ちょっとカンニングして以下。 Prelude Data.Char> product [digitToInt $ ([0..] >>= show) !! x |…

problem39

まあ、そのまま。 sortByなりmaximumByなりがData.Ordのcomparingを使わないといけないのがrubyと比較して面倒 import Data.List import Data.Ord main = print $ p p = maximumBy (comparing length) $ group $ sort [x+y+z|x<-[1..998],y<-[x..998-x],z<-[…

problem38

パンデジタル数になるのは 少なくともn 連結される数はn=2のとき、最初が4桁と次が5桁になるので 4999 import Data.List main = print $ maximum $concat $ map g [9..9999] f::Int->Int->Int f x y = read $foldl (++) [] $map show $zipWith (*) [x,x..] […