In years' past I've fleshed out my `Grid` class an...
# advent-of-code
n
In years' past I've fleshed out my
Grid
class and made it quite powerful and flexible. But this year I've really been enjoying using the input
String
directly as a virtual 2-D grid. You just need to track the width, after that, you can move around in any direction. The line breaks delineate the left and right sides of (almost) every row. Top and bottom are handled by using
getOrNull
. This also handles left of 0 and right of
lastIndex
. Does anyone else prefer working with a 1-D String rather than
lines()
or
List<List<E>>
?
e
I try not to assume every line has the same length
b
I pretty much always convert any grid into a
Map
of coordinate to content.
n
The yang to my yin.
@ephemient that may be good hygiene but for AoC to my knowledge all graphical representations of maps have been rectangular.
b
except for that one cube one...
n
And maybe that one that had teleporters on the outside that matched up with ones on the inside. Can’t remember if that one had consistent spacing.
And, I suppose, technically, today's.
e
yes, aoc inputs for mazes are usually nice. but my test data is just strings inside source code and might have spaces auto-stripped by the editor, for example, so I make my code safe
k
@Neil Banman
And maybe that one that had teleporters on the outside that matched up with ones on the inside. Can’t remember if that one had consistent spacing.
It had extra spacing on the end yes. I know that very well cause I was relying on it, but IntelliJ was stripping the spaces at the end when I pasted them into the file, giving me the weirdest errors that took me way to long to figure out
From then on out, I used a script to download my data