From d28803dba66070cff00d4344a6183f190e74e7a1 Mon Sep 17 00:00:00 2001 From: mtrx Date: Fri, 6 Dec 2024 20:58:42 +0100 Subject: [PATCH] for loopified --- solutions/04.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/solutions/04.ts b/solutions/04.ts index 08b65a3..f3e3379 100644 --- a/solutions/04.ts +++ b/solutions/04.ts @@ -27,14 +27,12 @@ class DayFour implements Solvable { let [b,a] = [0, mat[0].length - 1] const lines = [] while (b < mat.length) { - let [y,x] = [b,a] + + let line = '' - // walk top left of diagonal to bottom right - while (x < mat[y].length && y < mat.length - 1) { + for (let [y,x] = [b,a]; x < mat[y].length && y < mat.length - 1; y++,x++) line += mat[y][x] - y++ - x++ - } + lines.push(line.split('')) if (a > 0) {