Skip to content

Instantly share code, notes, and snippets.

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