Skip to content

Instantly share code, notes, and snippets.

@rizkyabdilah
Created June 16, 2012 21:56
Show Gist options
  • Save rizkyabdilah/2942620 to your computer and use it in GitHub Desktop.
Save rizkyabdilah/2942620 to your computer and use it in GitHub Desktop.
Project Euler Problem #67
#!/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