diff options
Diffstat (limited to '042.py')
| -rw-r--r-- | 042.py | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -0,0 +1,18 @@ +def score(name): + sum = 0 + for char in name: + sum += ord(char) - 64 + return sum + +triangle_numbers = [ int(0.5*n*(n-1)) for n in range(2, 200) ] +count = 0 + +f = open('042.txt', 'r') +for word in f: + word = word.rstrip("\n") + if score(word) in triangle_numbers: + count += 1 +f.close() + +print count + |
