Skip to content

Instantly share code, notes, and snippets.

@gulbanana
Created August 9, 2016 06:57
Show Gist options
  • Save gulbanana/c778f3437a61d4514ed534fb61817f57 to your computer and use it in GitHub Desktop.
Save gulbanana/c778f3437a61d4514ed534fb61817f57 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
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((n, i) => n.Select(c => (int)c - 64).Sum() * (i+1))
.MySum()
);
}
static class Extensions
{
public static int MySum(this IEnumerable<int> ns) => ns.Aggregate((x, y) => x + y);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment