mirror of
https://github.com/correl/euler.git
synced 2024-11-23 19:19:53 +00:00
Problem 022
git-svn-id: file:///srv/svn/euler@49 e5f4c3ec-3c0c-11df-b522-21efaa4426b5
This commit is contained in:
parent
dfa586dc1f
commit
4b1ce72158
2 changed files with 20 additions and 0 deletions
19
e022.py
Normal file
19
e022.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
import csv
|
||||||
|
|
||||||
|
names = []
|
||||||
|
reader = csv.reader(open('p022/names.txt'), delimiter=',', quotechar='"')
|
||||||
|
for row in reader:
|
||||||
|
names = names + row
|
||||||
|
names = sorted(names)
|
||||||
|
total = 0
|
||||||
|
|
||||||
|
i = 1
|
||||||
|
for name in names:
|
||||||
|
score = 0
|
||||||
|
for c in name:
|
||||||
|
score = score + (ord(c) - 64)
|
||||||
|
score = i * score
|
||||||
|
total = total + score
|
||||||
|
i = i + 1
|
||||||
|
|
||||||
|
print 'Total:', total
|
1
p022/names.txt
Normal file
1
p022/names.txt
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue