Skip to content

Instantly share code, notes, and snippets.

@jarvist
Created May 19, 2011 10:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jarvist/980497 to your computer and use it in GitHub Desktop.
Save jarvist/980497 to your computer and use it in GitHub Desktop.
Calculate Additions of Non Repeating Triangular numbers:
tn=1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 0, 0
soln={}
for i in tn[:]:
for j in tn[tn.index(i)+1:]:
for k in tn[tn.index(j)+1:]:
for l in tn[tn.index(k)+1:]:
print i,j,k,l
soln[i+j+k+l]=i,j,k,l
print soln
print "I can't form the following integars below 100: "
for i in range(100):
if i not in soln:
print i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment