Skip to content

Instantly share code, notes, and snippets.

@mavant
Created November 22, 2013 00:55
Show Gist options
  • Save mavant/7592828 to your computer and use it in GitHub Desktop.
Save mavant/7592828 to your computer and use it in GitHub Desktop.
Project Euler problem 22
import csv
names = []
sum = 0
with open ('names.txt', 'rb') as csvfile:
namereader = csv.reader(csvfile, delimiter=',', quotechar='"')
for row in namereader:
names = names + row
names.sort()
for i in range(len(names)):
value = 0
for char in names[i]:
value += (ord(char)-64)
sum += value*(i+1)
print (sum)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment