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

パスカルの三角形とシェルピンスキーのギャスケット

パスカルの3角形は次のコードで生成できる。 pascal = iterate next [1] where next xs = zipWith (+) (0:xs) (xs++[0]) showPascal n = mapM_ print.take n$pascal *Main> showPascal 10とすれば、次のようなパスカルの三角形が得られる。 [1] [1,1] [1,2,1…

Problem 151

http://projecteuler.net/index.php?section=problems&id=151 はじめは変数名ミスでループに陥っていた。 main = print.expect$(1,1,1,1) expect (0,0,0,1) = 0 expect (0,0,1,0) = 1 expect (0,1,0,0) = expect(0,0,1,1) + 1 expect (1,0,0,0) = expect(0,1…

Problem 150

http://projecteuler.net/index.php?section=problems&id=150 三角形の高さをnとするとO(n^3)のアルゴリズム。 別のO(n^3)のアルゴリズムも実装したが、そちらより20倍ぐらい速い。 こちらのほうが、領域計算量に関して悪いのだが(rが必要)、なぜか速い。 im…

進捗

卒論が全然すすまねー。 目次とか書こうっていわれたけど、 正直書くことあんまないのよね。 あー、困った。 全然成果出てないし。 あー、困った。PCのなかの小人さんがんばってくれー