# Project Euler Problem 22

Using names.txt, a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical value for each name, multiply this value by its alphabetical position in the list to obtain a name score.
For example, when the list is sorted into alphabetical order, COLIN, which is worth 3 + 15 + 12 + 9 + 14 = 53, is the 938th name in the list. So, COLIN would obtain a score of 938 × 53 = 49714.
What is the total of all the name scores in the file?
http://projecteuler.net/problem=22

names.txtには5000以上の名前が書かれていて、それをまずソートし、アルファベットに値を割り当て、リストの順番と掛け合わせた値の和を求める問題。
まずはアルファベットに値を割り当てる函数を作り、次に名前のスコアを求める函数を作る。
そしてファイルからデータを読み込む部分を作ればよい。
osモジュールを使えば比較的簡単にできる。

```#Problem 22 Names scores
import os
def char_to_number(cap):
return ord(cap) % ord('A') + 1
def word_to_score(word):
return sum([char_to_number(x) for x in list(word)[1:-1]])
target = []
for line in open('Problem_022_names.txt','r'):
target = line.split(',')

target.sort()
print sum([word_to_score(x)*(target.index(x)+1) for x in target])
```