Skip to content

Instantly share code, notes, and snippets.

@gulbanana
Last active August 9, 2016 06:47
Show Gist options
  • Save gulbanana/8b7f50bb3478fb48553a5e91fe4207d8 to your computer and use it in GitHub Desktop.
Save gulbanana/8b7f50bb3478fb48553a5e91fe4207d8 to your computer and use it in GitHub Desktop.
using System;
using System.IO;
using System.Linq;
class Euler
{
static void Main(string[] args)
{
var raw_input = File.ReadAllText("./p022_names.txt");
var names = raw_input.Replace("\"","").Split(',').OrderBy(n => n);
var total_score = names.Select((n, i) => ScoreName(n) * (i+1)).Sum();
Console.WriteLine(total_score);
}
static int ScoreName(string name) => name.Select(c => (int)c - 64).Sum();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment