きったんの頭

#! /usr/bin/env python3
"""
pe42.py
https://mind.kittttttan.info/py/pe42

pe42.txt
https://mind.kittttttan.info/c/pe42.txt
"""

# https://mind.kittttttan.info/py/pe0
from pe import word_worth

def pe42(fname="pe42.txt"):
    """
    How many triangle words does the list of common English words contain?
    """
    with open(fname, 'r') as f:
        words = f.read()
    words = words.replace('"', '').split(',')
    triangles = set(i * (i + 1) >> 1 for i in range(1, 100))
    # print([w for w in words if worth(w) in triangles])
    print(sum([1 for w in words if word_worth(w) in triangles]))

if __name__ == "__main__":
    pe42()