From 8b72c18d65e6ce6f2bd518e30fac429ca3983a44 Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Tue, 12 Dec 2023 10:13:38 +0100 Subject: [PATCH] flip, duplicate columns, flip again --- Day11/Part1.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Day11/Part1.js b/Day11/Part1.js index 34f63ee..a7148ca 100644 --- a/Day11/Part1.js +++ b/Day11/Part1.js @@ -15,8 +15,13 @@ const expand = (arr) => ], [] ); +const flip = (current) => + Array.from({ length: current[0].length }, (_, x) => + Array.from({ length: current.length }, (_, y) => current[y][x]) + ); -console.log(expand(input)); +const universe = flip(expand(flip(expand(input)))); +console.log(universe); const t1 = performance.now(); console.log(`Runtime: ${t1 - t0}ms`);