2009-01-12から1日間の記事一覧

Problem 171

http://projecteuler.net/index.php?section=problems&id=171 数字の出てくる順番は本質的ではない。 平方数を1^2,2^2,3^2,..9^2を使って分割。 その分割からできる数字の和を考える(permutations)。 総和をとる。 digit :: Int digit = 20 partitionToSqu…

Problem 172

http://projecteuler.net/index.php?section=problems&id=172 流れは前問と似ている。 まず、分割して、その出現回数を数え、和をとる。 久々に一瞬で走る。 import Data.List divid :: Int -> Int -> Int -> [[Int]] divid 0 _ k = [replicate k 0] divid x…