From 5f6b200fff20afd3f63af2556343b8b9886d417d Mon Sep 17 00:00:00 2001 From: Greg Burri Date: Sun, 3 Dec 2017 23:15:02 +0100 Subject: [PATCH] Cleaning --- AdventOfCode2017/Day3.fs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AdventOfCode2017/Day3.fs b/AdventOfCode2017/Day3.fs index df96b61..3342111 100644 --- a/AdventOfCode2017/Day3.fs +++ b/AdventOfCode2017/Day3.fs @@ -6,7 +6,7 @@ let spiral = Seq.unfold ( fun (pos, dir, n, i) -> let x, y = directions.[dir] - let pos' = fst pos + x, snd pos + y + let pos' = fst pos + x, snd pos + y let nMax = (i + 1) * 2 - 1 let i', n' = if n = nMax then i + 1, 0 else i, n + 1 let dir' = if i <> i' || n' = nMax / 2 + 1 then (dir + 1) % 4 else dir @@ -20,7 +20,7 @@ let spiralManhattanDistanceSum (n : int) = let spiralAdjacentSumBiggerThan (n : int) = let neighborsSum (dic : Map) (pos : int * int) = let x, y = pos - [ x + 1, y; x + 1, y + 1; x, y + 1; x - 1, y + 1; x - 1, y; x - 1, y - 1; x, y - 1; x + 1, y - 1] + [ for dx in -1 .. 1 do for dy in -1 .. 1 -> x + dx, y + dy ] |> List.map (fun (x, y) -> match dic |> Map.tryFind (x, y) with Some v -> v | None -> 0) |> List.sum -- 2.45.2