Created
October 21, 2014 12:39
-
-
Save joostrijneveld/bafb12b807472e60deb1 to your computer and use it in GitHub Desktop.
This file contains the solution to Problem 67 of Project Euler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
with open('p067_triangle.txt') as f: | |
triangle = [[int(y) for y in x.strip().split(' ')] for x in f.readlines()] | |
upsidedown = list(reversed(triangle)) | |
rowpairs = zip(upsidedown, upsidedown[1:]) | |
for bot, top in rowpairs: | |
for i, x in enumerate(top): | |
top[i] = x + max(bot[i], bot[i+1]) | |
print(triangle[0][0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment