Created
April 29, 2017 20:03
-
-
Save jackmott/52066b655632a527410a51b5458f1668 to your computer and use it in GitHub Desktop.
nim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proc nameScore(name : string) : int = | |
for c in name: | |
result += int(c)-64 | |
var names = "names.txt".readFile().replace("\"").split(',') | |
names.sort(system.cmp) | |
var sum =0 | |
for i,name in names: | |
sum += nameScore(name)*(i+1) | |
echo sum | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment