Sunday, 6 May 2012

Project Euler #13 in F#

Given a string containing 50-digit numbers on separate lines, find the first ten digits of their sum. In F#, split the string at newlines, sum the lines by parsing each as a big int, convert the result to a string and take the first ten characters:
string(Seq.sumBy bigint.Parse (data.Split[|'\n'|])).Substring(0, 10)

No comments: