Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
214 lines (204 sloc) 18.5 KB
# Solution to Project Euler problem 42
# Copyright (c) Project Nayuki. All rights reserved.
import itertools
def compute():
ans = sum(1
for s in WORDS
if is_triangular_number(sum((ord(c) - ord('A') + 1) for c in s)))
return str(ans)
def is_triangular_number(n):
temp = 0
for i in itertools.count():
temp += i
if n == temp:
return True
elif n < temp:
return False
WORDS = [ # 10 strings per line, except final line
if __name__ == "__main__":