mirror of
https://github.com/seigler/aoc2024
synced 2025-07-26 00:36:10 +00:00
day 6 brute force
This commit is contained in:
parent
ad6829def6
commit
ded85a988b
3 changed files with 22 additions and 10 deletions
|
@ -83,12 +83,12 @@
|
|||
"time": null
|
||||
},
|
||||
"part2": {
|
||||
"solved": false,
|
||||
"result": "1878",
|
||||
"solved": true,
|
||||
"result": "1753",
|
||||
"attempts": [
|
||||
"1878"
|
||||
],
|
||||
"time": 2128.985844
|
||||
"time": 37138.280767
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
12
README.md
12
README.md
|
@ -16,7 +16,7 @@
|
|||
[](src/day03)
|
||||
[](src/day04)
|
||||
[](src/day05)
|
||||
[](src/day06)
|
||||
[](src/day06)
|
||||

|
||||

|
||||

|
||||
|
@ -104,9 +104,9 @@ Both parts: 63.594ms
|
|||
|
||||
```
|
||||
Day 06
|
||||
Time part 1: 1.668ms
|
||||
Time part 2: -
|
||||
Both parts: 1.668ms
|
||||
Time part 1: -
|
||||
Time part 2: 37138.281ms
|
||||
Both parts: 37138.281ms
|
||||
```
|
||||
|
||||
```
|
||||
|
@ -243,8 +243,8 @@ Both parts: -
|
|||
```
|
||||
|
||||
```
|
||||
Total stars: 11/50
|
||||
Total time: 324.318ms
|
||||
Total stars: 12/50
|
||||
Total time: 37460.931ms
|
||||
```
|
||||
|
||||
<!--/RESULTS-->
|
||||
|
|
|
@ -75,7 +75,19 @@ const part2 = (rawInput: string) => {
|
|||
position = nextPosition
|
||||
}
|
||||
}
|
||||
return walk([Math.floor(rawCol / (width + 1)), rawCol % (width + 1)])
|
||||
// nevermind recursion I guess we will brute force
|
||||
const start = [Math.floor(rawCol / (width + 1)), rawCol % (width + 1)]
|
||||
console.log("Working...")
|
||||
for (let r = 0; r < input.length; r++) {
|
||||
for (let c = 0; c < width; c++) {
|
||||
if (input[r][c] !== '#') {
|
||||
walk(start, [r,c])
|
||||
}
|
||||
}
|
||||
process.stdout.write(`\r${Math.floor(r / input.length * 100)}%`)
|
||||
}
|
||||
console.log('\nDone!')
|
||||
return obstructions.size
|
||||
}
|
||||
|
||||
run({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue