Skip to content

Instantly share code, notes, and snippets.

@kmonsoor
Created January 20, 2014 03:48
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 kmonsoor/8514591 to your computer and use it in GitHub Desktop.
Save kmonsoor/8514591 to your computer and use it in GitHub Desktop.
My solution for ProjectEuler problem# 41
def is_triangle(w):
return sum([ord(c)-64 for c in w]) in TN
L = list(eval(open('words.txt').readlines()[0])) #loading data
# creating triangle number list as i don't want to check triagulity every time
i,TN = 0,[]
for j in range(1,30):
i += j; TN.append(i)
#final check
print sum([1 for w in L if is_triangle(w)])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment