From 00e53cdbd72692ef467eeb5fd9bd0b4710f38f46 Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Sat, 27 Jan 2024 22:17:21 +0100 Subject: [PATCH] parse tiles into grid --- Day17/Part1.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Day17/Part1.js b/Day17/Part1.js index abd2d8a..3f2221a 100644 --- a/Day17/Part1.js +++ b/Day17/Part1.js @@ -2,8 +2,19 @@ import { readFileSync } from "fs"; const t0 = performance.now(); const input = readFileSync("input.txt") - .toString(); -console.log(input); + .toString() + .split(/\r*\n/) + .filter((e) => e.length > 0) + .map((a, j) => a + .split("") + .map((b, i) => ({ + c: +b, + x: i, + y: j, + d: 0, + h: 0 + }))); +console.log(input[0].slice(-1)[0]); const t1 = performance.now(); console.log(`Runtime: ${t1 - t0}ms`);