mirror of
https://github.com/seigler/aoc2024
synced 2025-07-27 00:56:10 +00:00
day 14 cleaner
This commit is contained in:
parent
992ab32a04
commit
4803b87dad
1 changed files with 17 additions and 19 deletions
|
@ -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({
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue