2008-10-01から1ヶ月間の記事一覧

project euler problem10 エラトステネスの篩

200万以下の全ての素数の和を計算しなさい.とのことpythonでやってみたまずは10万まででテスト #!/usr/bin/env python # -*- coding: utf-8 -*-from sys import exit import timeMIN = 1 MAX = 100000ans = long(0) primeNum = [];print "START : " + str(ti…

DBのTABLE、COLUMNにコメント追加

[postgres] ・テーブルに追加 COMMENT ON TABLE t1 IS 'aaa';・カラムに追加 COMMENT ON COLUMN t1.id IS 'aaa'; [MySQL] ・テーブルに追加 ALTER TABLE t1 COMMENT 'aaaa'・カラムに追加 ALTER TABLE t1 MODIFY id integer not null COMMENT 'aaaa'ORACLEも…

PostgreSQLのバグ?

バグか?これ create table t3 (id integer not null primary key,name varchar(255) null); insert into t3 select 1,null; insert into t3 select 2,'aaa'; insert into t3 select 3,'';1個目のnameはnull、2個目はaaa、3個目は''(空文字)でselect test…

pythonでクロージャ

pythonでクロージャ書いてみた #!/usr/bin/env python # -*- coding: utf-8 -*-class Closure: i = 0 def Seq(self): def func(i): self.i = i + 1 return self.i return func(self.i) cl = Closure() print cl.Seq() print cl.Seq() print cl.Seq() print c…