day 14 cleaner

This commit is contained in:
Joshua Seigler 2024-12-15 00:00:48 -05:00
parent 992ab32a04
commit 4803b87dad

View file

@ -24,11 +24,10 @@ const part1 = (rawInput: string) => {
} }
const part2 = (rawInput: string) => { const part2 = (rawInput: string) => {
(async () => {
const input = parseInput(rawInput) const input = parseInput(rawInput)
const width = 101 const width = 101
const height = 103 const height = 103
for (let i = 0; i < 20000; i++) { for (let i = 0; i < width * height; i++) {
const canvas: string[][] = [] const canvas: string[][] = []
for (let y = 0; y < height; y++) { for (let y = 0; y < height; y++) {
canvas.push(" ".repeat(width).split('')) canvas.push(" ".repeat(width).split(''))
@ -39,11 +38,10 @@ const part2 = (rawInput: string) => {
canvas[desty][destx] = "#" canvas[desty][destx] = "#"
}) })
if (canvas.some(line => line.join('').includes("##########"))) { if (canvas.some(line => line.join('').includes("##########"))) {
await new Promise(resolve => setTimeout(resolve, 1000))
console.log(`\nTIME: ${i} seconds\n${canvas.map(line => console.log(line.join(""))).join('\n')}`) console.log(`\nTIME: ${i} seconds\n${canvas.map(line => console.log(line.join(""))).join('\n')}`)
return i
} }
} }
})()
} }
run({ run({