Revision: 27431
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 8, 2010 01:32 by chroto
Initial Code
#!/usr/bin/python # Project Euler - Problem 18 f = open('problem18.tri', 'r') tri =[] maxvals = [] # Load data into 15 row pryamid list for m in xrange(15): tri.append([]) maxvals.append([]) for n in xrange(m+1): tri[m].append(int(f.read(3))) if m == 0: maxvals[m].append(tri[0][0]) elif n == 0: maxvals[m].append(tri[m][0]+maxvals[m-1][0]) elif n == m: maxvals[m].append(tri[m][m]+maxvals[m-1][m-1]) else: maxvals[m].append(tri[m][n]+max(maxvals[m-1][n-1],maxvals[m-1][n])) print max(maxvals[m])
Initial URL
Initial Description
Initial Title
Project Euler - Problem 18
Initial Tags
Initial Language
Python