Skip to content

Instantly share code, notes, and snippets.

@jimmason
Last active December 14, 2015 10:57
Show Gist options
  • Save jimmason/b02f69ca059b5d5e8f21 to your computer and use it in GitHub Desktop.
Save jimmason/b02f69ca059b5d5e8f21 to your computer and use it in GitHub Desktop.
//http://adventofcode.com/day/14
open System
let puzzleInput = "Vixen can fly 19 km/s for 7 seconds, but then must rest for 124 seconds.
Rudolph can fly 3 km/s for 15 seconds, but then must rest for 28 seconds.
Donner can fly 19 km/s for 9 seconds, but then must rest for 164 seconds.
Blitzen can fly 19 km/s for 9 seconds, but then must rest for 158 seconds.
Comet can fly 13 km/s for 7 seconds, but then must rest for 82 seconds.
Cupid can fly 25 km/s for 6 seconds, but then must rest for 145 seconds.
Dasher can fly 14 km/s for 3 seconds, but then must rest for 38 seconds.
Dancer can fly 3 km/s for 16 seconds, but then must rest for 37 seconds.
Prancer can fly 25 km/s for 6 seconds, but then must rest for 143 seconds"
let GetDistanceTraveledIn(time:int) =
[for reindeer in puzzleInput.Split '.' do
let r = reindeer.Split ' '
yield (((time + Int32.Parse(r.[13]))/(Int32.Parse(r.[6]) + Int32.Parse(r.[13]))) * (Int32.Parse(r.[3]) * Int32.Parse(r.[6])))]
|> List.sortDescending
|> List.head
printfn "The winning reindeer traveled %d km" (GetDistanceTraveledIn 2503)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment