From: Ummon Date: Mon, 11 Dec 2017 08:15:31 +0000 (+0100) Subject: Cleaning... X-Git-Url: https://git.euphorik.ch/?a=commitdiff_plain;h=e77c343ebe1d77ee8f61939091c44a47c3d9e6bc;p=advent_of_code_2017.git Cleaning... --- diff --git a/AdventOfCode2017/Day11.fs b/AdventOfCode2017/Day11.fs index e2ccf32..400e0eb 100644 --- a/AdventOfCode2017/Day11.fs +++ b/AdventOfCode2017/Day11.fs @@ -8,7 +8,14 @@ let distanceInHex (moves : string) = let destination, furthest = moves.Split ',' |> Seq.fold ( fun ((x, y), furthest) m -> - let pos = match m with "n" -> (x, y + 2) | "ne" -> (x + 1, y + 1) | "se" -> (x + 1, y - 1) | "s" -> (x, y - 2) | "sw" -> (x - 1, y - 1) | _ -> (x - 1, y + 1) - pos, distance pos |> max furthest + let next = + match m with + | "n" -> (x , y + 2) + | "ne" -> (x + 1, y + 1) + | "se" -> (x + 1, y - 1) + | "s" -> (x , y - 2) + | "sw" -> (x - 1, y - 1) + | _ -> (x - 1, y + 1) + next, distance next |> max furthest ) ((0, 0), 0) distance destination, furthest \ No newline at end of file