Created
June 16, 2012 21:56
-
-
Save rizkyabdilah/2942620 to your computer and use it in GitHub Desktop.
Project Euler Problem #67
This file contains 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
#!/opt/python/bin/python | |
# @author: Rizky Abdilah | |
# @description: Project Euler Problem #67 | |
if __name__ == "__main__": | |
nlist, lnumber = [], 0 | |
fp = open("/tmp/euler/67.txt", "r") | |
for line in fp: | |
lnumber += 1 | |
nlist += map(int, line.split()) | |
fp.close() | |
nlist_size = len(nlist) #(lnumber**2 + lnumber) / 2 | |
start = nlist_size - lnumber | |
end = nlist_size | |
result = nlist[start:end] | |
for i in xrange(lnumber - 1): | |
pos = lnumber - i - 1 | |
end = start | |
start = start - pos | |
rows = nlist[start:end] | |
tmp_result = [] | |
for key, val in enumerate(rows): | |
tmp_result.append(val) | |
tmp_result[key] += result[key] if result[key] > result[key + 1] else result[key + 1] | |
result = tmp_result | |
print "biggest possibility %d" % result[0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment