Created
July 24, 2021 06:24
-
-
Save igorvanloo/50a18b05f1dbb0c9eb55fe7cc7baaa8b to your computer and use it in GitHub Desktop.
Problem 42
This file contains hidden or 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
| 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