Exemple #1
0
# 162
import euler
m = 0
s = {}
for word in euler.load_word_file('../files/words.txt'):
    v = euler.word_score(word)
    if s.has_key(v):
        s[v] += 1
    else:
        s[v] = 1
    if v > m:
        m = v

t = 0
n = 1
tn = 1
while tn <= m:
    if s.has_key(tn):
        t += s[tn]
    n += 1
    tn = n * (n + 1) / 2
print t
Exemple #2
0
# 871198282
import euler
names = euler.load_word_file('../files/names.txt')
names.sort()
s = 0
for i in xrange(len(names)):
    s += (i + 1) * euler.word_score(names[i])
print s
Exemple #3
0
def compute():
    word_list = sorted(f.read().split(","))
    return sum(word_score(word_list[i][1:-1]) * (i + 1) for i in range(len(word_list)))