It's not really a matrix of strings, is it?
# advent-of-code
n
It's not really a matrix of strings, is it?
a
the map is a matrix of chars - is it not?
n
Well, you said strings before
string's pretty inefficient because it's a bigger/heavier type, I'm not sure what char is like exactly in Kotlin
but Boolean is the best choice, there's only two values you care about
Boolean or an enum class with two values, is probably a little better
a
You still need to convert each char to a boolean, so the total amount of char comparisons you’d make converting to boolean vs keeping as chars is the same
n
well not in the second part right
I mean I guess technically you can end up doing more char comparisons because you are "eagerly" converting everything, you can also do fewer in the second part
I mostly say Boolean is the better choice for semantic reasons though not performance reasons. There's only two values you care about, so you should opt to convert stuff early into a type that only has two values.
m
Meh, the stuff is read-only so I prefer just going with a list of strings since accessing a spot is just list[y][x] syntax.
n
Whether it's a List[String] or a List[List[Boolean]], it's still [y][x] syntax
m
Yes, thats why imho it was better to just to .lines() on the input file content instead of reading and mapping to booleans based on whatever you encounter
👆 1
Dont get me wrong
a
agree with michael
n
Eh, you have a type system, use it to help you
This is fairly toy code so it doesn't matter much either way
But in real code continuing to pass around chars all over your program when there's only two "legal" values is just bad
a
Right
m
Ohno, I agree with that. Luckily adventofcode guaranteea correct semantics on input. Normally I'd treat the problem differently
👍 1