From 3d295dc92f1f4eec27f871cdd303f82d39e6dc96 Mon Sep 17 00:00:00 2001 From: David Vidmar Date: Wed, 13 Dec 2023 20:04:54 +0100 Subject: [PATCH] Day 11 solution --- Day11/Day11/main.swift | 91 ++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 60 deletions(-) diff --git a/Day11/Day11/main.swift b/Day11/Day11/main.swift index 290755d..88e21a5 100644 --- a/Day11/Day11/main.swift +++ b/Day11/Day11/main.swift @@ -39,63 +39,9 @@ for r in (0.. c { points[i].1 = p.1 + 999999 } + } + } +} + +// expand ROWS +for r in (0.. r { points[i].0 = p.0 + 999999 } + } + } +} -func printMap(map: [[Int]]) { - for row in map { - print(row) +var result2 = 0 +for (i, p) in points.enumerated() { + for (j, r) in points.enumerated() { + if i < j && p != r { + result2 += abs(p.0 - r.0) + abs(p.1 - r.1) + } } } + +print("Part 2: \(result2)")