Skip to content

Instantly share code, notes, and snippets.

@igorvanloo
Created July 24, 2021 06:24
Show Gist options
  • Select an option

  • Save igorvanloo/50a18b05f1dbb0c9eb55fe7cc7baaa8b to your computer and use it in GitHub Desktop.

Select an option

Save igorvanloo/50a18b05f1dbb0c9eb55fe7cc7baaa8b to your computer and use it in GitHub Desktop.
Problem 42
Triangle_number = [ "the triangle numbers from the txt file" ]
def sumofname(x):
namesum = 0
for i in range(len(words[x])):
namesum += ord(words[x][i])-64
return namesum
def compute():
count = 0
triangle_number = [int((n*(n+1))/2) for n in range(1,23)]
for x in range(len(words)):
if sumofname(x) in triangle_number:
count += 1
return count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment