projecteuler018 - maximum path sum I
"""
projecteuler018 - maximum path sum I
By starting at the top of the triangle below and moving to adjacent
numbers on the row below, the maximum total from top to bottom is 23.
(see project euler site for triangle)
That is, 3 + 7 + 4 + 9 = 23.
Find the maximum total from top to bottom of the triangle below:
(see project euler site for triangle)
"""
import csv
values = []
y = 0
for row in reversed(open('./projecteuler018.txt').readlines()):
values.append([])
for val in row.split():
values[y].append(int(val))
y = y + 1
print str(values)
for y in range(0,len(values)-1):
row = values[y]
for x in range(0,len(row)-1):
lval = values[y+1][x] + values[y][x]
rval = values[y+1][x] + values[y][x+1]
values[y+1][x] = lval if lval > rval else rval
print values