2010-12-27から1日間の記事一覧

euler40

汚いな。 L = [9*(i+1)*10**i for i in xrange(10)] def nth(n): n = n-1 def idx_and_rest(n): for i, e in enumerate(L): n -= e if n < 0: return (i, e+n) i, rest = idx_and_rest(n) for j in xrange(10**i, 10**(i+1)): size = len(str(j)) if size > …

euler39

まだ、python慣れないな。最大だから、本当はリストで持つ意味ないし、もっと効率よく求められそうだけれど。 # If p is the perimeter of a right angle triangle with integral length sides, {a,b,c}, there are exactly three solutions for p = 120. # …