Last active
March 30, 2016 20:59
-
-
Save monkeygroover/5fcd9470f5226dfcac45 to your computer and use it in GitHub Desktop.
euler22
This file contains hidden or 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
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