Considering the day I had… it is not surprising that part 2 of Day 1 of Advent of Code took me hours to figure out. I solved part 2 half asleep … I guess that’s something, too.
What is not helping is that the auto-complete of my IDE almost solved part 1 on its own without me telling it about the actual puzzle (and i doubt the chatbots can get the solutions that are published today into their models this fast)
So my brain went on auto-pilot. For part 1. And then for part 2 I had not really thought the problem through I had just sleep-walked my way through some object orientation that more or less told the IDE what it was supposed to program.
But part 2 is confusing enough that the auto completion cannot solve it. Yay for confusing problems.
Because I had not thought it through … and additional object oriented programming was not going to crack it… it took me very needlessly long.
I ended up creating a parameterized unit test to debug the thing. I only solved it however when I added a test-case beyond the websites example … not because I had not thought of it before but because when I saw the result my brain’s pattern matching realized what I had been doing wrong with the failing test cases (yes half asleep it still works, maybe I usually imagine I am sleeping)
@ParameterizedTest()
@CsvSource({"L68,1,82","L30,0,52","R48,1,0","L5,0,95","R60,1,55","L55,1,0","L1,0,99","L99,1,0","R14,0,14","L82,1,32","L300,3,32"})
public void testSomething(String turnAsString, int zeroesExpected, int valueExpected){
...
Assertions.assertThat(dial.value).isEqualTo(valueExpected);
Assertions.assertThat(zeros).isEqualTo(zeroesExpected);
}
I software-developed my way through the problem or what I call “brute force problem solving by way of endless test cases”
Solution.