示例#1
0
文件: 22.py 项目: higgsd/euler
# 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
示例#2
0
文件: 42.py 项目: higgsd/euler
# 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