Skip to content

Instantly share code, notes, and snippets.

@monkeygroover
Last active March 30, 2016 20:59
Show Gist options
  • Save monkeygroover/5fcd9470f5226dfcac45 to your computer and use it in GitHub Desktop.
Save monkeygroover/5fcd9470f5226dfcac45 to your computer and use it in GitHub Desktop.
euler22
open System.IO
let wordValue (word: string) = Seq.map(fun c -> (int c) - (int 'A') + 1) word
|> Seq.sum
let result = File.ReadLines("p022_names.txt")
|> Seq.collect(fun line -> line.Split ',')
|> Seq.map(fun quotedWord -> quotedWord.Trim [|'"'|] )
|> Seq.sort
|> Seq.mapi(fun i word -> (i + 1) * wordValue word)
|> Seq.sum
printfn "%A" (wordValue "COLIN")
printfn "%A" result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment