Advent-of-Code-2023/day18/notes.org

2.0 KiB

Notes

part 2 and i'm struggling.

maybe i need to mark 'inside' cells while i dig? i don't know which is 'outside' from the getgo?

if i mark 'all the rightside', will that help to calculate inside?

well, if we dont' have instruction with steps:1 i can just count points above and belove the line

without more complicated things

just count 'seenUp' and 'seenDown' if equal - then we changed side

and - we shouldn't have 'step1' because all numbers are soooo big.

ok. let's do that? with maps of cols.

CANCELLED add map[row]map[col]any

CANCELLED separate method to set it up after we have all of the BorderCellCols

CANCELLED during digInsides on each consecutive - check above and below and count

when there's a jump - compare counts, to make decision on whether to switch 'isInside'

no. just because they are long doesn't mean they won't ever get one near another

another idea is to save | and corners, as if we're going from left to right

this seems reasonable.

DONE i guess []SpecialSymbol which has Col and Symbol

DONE no, let's make it map. yes will have to init, but yuck anyway

TODO then different logic on border building.

if U \ D - on all but last add '|' on last - calc with the next turn, what should be saved 'as if traversing from the left'

for L \ R - on last - calc what the turn was

TODO !! between last and first movement the corner is unknown.

so, copy the first instruction to the end?

moment of hope.

my calculation for example input for part 2 day18 result: 952408144115

952408144115

YES.

about 1M for 4 minutes

so, my input is ~16M rows

3.5 seconds per 10k

well, maybe i can parallel.

parallel example

day18 result: 952407566854

and with separate done channel from the summing goroutine

952408144115

YES

and

2023/12/18 23:35:31 border is 195341588; inside is 148441957805559 2023/12/18 23:35:31

day18 result: 148442153147147

i should have used a formula. maybe then it would taken less than 4 hours