2008-12-23から1日間の記事一覧

Problem 156

http://projecteuler.net/index.php?section=problems&id=156 import Data.Char import Data.List count :: Int -> [Int] -> Integer count d = genericLength.filter(==d) listToInt :: [Int] -> Integer listToInt = foldl' add 0 where add a b = a*10+to…

Meadow フォント

;;; フォントの設定 (w32-add-font "Osaka 16" '*1 *2 *3 *4 *5 *1:spec ((:char-spec ascii :height any) strict (w32-logfont "Osaka−等幅" 0 -16 400 0 nil nil nil 0 1 3 0 *2::char-spec ascii :height any :weight bold) strict (w32-logfont "Osaka−…

Problem 155

http://projecteuler.net/index.php?section=problems&id=155 メモリ不足になったりした。 素直なアルゴリズム。 import Data.Array import qualified Data.Set as S n = 18 main = print.sum.map S.size.elems$ caps caps = listArray (1,n) $ (S.singleton…

Problem 154

http://projecteuler.net/index.php?section=problems&id=154 3項係数の約数について。 haskellでの実装。 import Control.Monad import Data.Array.Unboxed import Data.List n = 2*10^4 d = 10 main = print p154 factor p x | mod x p == 0 = succ.factor…