ONLY DO WHAT ONLY YOU CAN DO

こけたら立ちなはれ 立ったら歩きなはれ

Project Euler Problem 22

ファイル中の全名前のスコアの合計を求めよ

5000個以上の名前が書かれている46Kのテキストファイnames.txt を用いる. まずアルファベット順にソートせよ.

のち, 各名前についてアルファベットに値を割り振り, リスト中の出現順の数と掛け合わせることで, 名前のスコアを計算する.

たとえば, リストがアルファベット順にソートされているとすると, COLINはリストの938番目にある. またCOLINは という値を持つ. よってCOLINは というスコアを持つ.

ファイル中の全名前のスコアの合計を求めよ.

Names scores

Using names.txt (right click and 'Save Link/Target As...'), 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 , is the 938th name in the list. So, COLIN would obtain a score of .

What is the total of all the name scores in the file?