Problem 49
コンテンツ
import Number hiding (diff) import Data.List perm ::Eq a =>[a]->Int->[[a]] perm _ = [[]] perm [] _ = [] perm xs@(_:_) (n+1)=concat[map (h:)$perm(delete h xs)n|h<-xs] get _ = [[]] get [] _ = [] get (x:xs) (n+1) = [x:ys|ys<-get xs n]++get xs (n+1) diff xs = zipWith (-) (tail xs) $ xs p049 n =filter (same.diff).flip get 3.nub.sort.filter isPrime .map read. perm ns $length ns where ns = show n same [a,b] = a == b main =print.filter ((==12).length.concatMap show).nub.concatMap p049 .takeWhile(<10000).dropWhile(<1000)$primes
作成者 Toru Mano
最終更新時刻 2023-01-01 (c70d5a1)