Project Euler 解答

Project Euler Problem 068

Project Euler Problem 068

import Data.List t :: [Integer] t=[1..10] anspre :: [[[Integer]]] anspre = [[[a,b,c],[d,c,e],[f,e,g],[h,g,i],[j,i,b]] | a<-t, b<-delete a t, c<-t \\ [a,b], let l = a+b+c, d<-t \\ [a,b,c], e<-t \\ [a,b,c,d], d+c+e==l, f<-t \\ [a,b,c,d,e], g<-t \\ [a,b,c,d,e,f], f+e+g==l, h<-t \\ [a,b,c,d,e,f,g], i<-t \\ [a,b,c,d,e,f,g,h], h+g+i==l, j<-t \\ [a,b,c,d,e,f,g,h,i], j+i+b==l] --60個解 concatenate :: (Ord a, Show a) => [[a]] -> [Char] concatenate lst = concatMap show $ concat $ take 5 $ dropWhile ((/= minhead).head) cyl where minhead = minimum $ map head lst cyl = cycle lst ans1 :: [Char] ans1 = maximum $ map concatenate anspre --ほんとは数値比較すべき -- 6531031914842725 main :: IO () main = print ans1

since 2013