Tim Cooke

Marshal
+ Follow

Recent posts by Tim Cooke

Yes likewise. I'm not usually a fan of map position based problems but today, Day 8, turned out to be not so bad. Although I did have to get a pencil and paper to validate my position movement calculations.
12 hours ago
Fun with permutations on Day 7. I would imaging one could easily come up against memory space issues with this problem so lots of searching for an appropriate algorithm was order of the day today.
I didn't find Day 6 too bad. I had a decent mental model of what I intended to do before starting to code which helped a lot. Also I got to reuse the Position and Direction class and enum, respectively, that I wrote for Day 4 which was also handy.

However, my implementation is an unpleasant nest of for, if, and while. So much so that if you turn it on its side you could almost imagine it's a Christmas Tree.
I think we'll just have to keep singing the song to our peers that AI isn't the silver bullet it's purported to be, and that we all remain accountable for the code we produce regardless of how much of it AI filled in for you. It's a tool to be treated with healthy suspicion every step of the way.

The alternative is that you have software products that none of your team really understand because none of your team really wrote it.
I don't have the AI thing but I have been using the "full line completion" which is sort of "ai" driven and I've been caught out a few times with suggestions that look right at first glance but turn out to be ever so slightly wrong in a not immediately obvious way. I fear for the future if less experienced devs rely too heavily on it leaving a trail of ever so slightly broken stuff behind them without fully understanding it.

Piet Souris wrote:But for part A you do not need to sort.


Technically no, but my approach was this
"Domain Specific Language" aka a made up syntax/language specifically for your problem domain. Which in this case is Advent of Code.
Do you get IDE help for that code snip inside the ${} inside the String? I sure hope so otherwise that's a mightily unpleasant developer experience.
Writing a custom Comparator and comparing original and sorted was the approach I had come up with in my mind before I wrote a single thing and that worked out pretty well for part 1 and made part 2 trivial.

Liutauras Vilda wrote:
I resolved it and deleted instantly to not have nightmares

Was it really that bad?

Piet Souris wrote:Another fancy way is to create a TreeMap<Integer, Boolean>. with keys the index of "do()" or "don't()", and when finding the index of a correct mul, then use treemap.floorkey to get the status.


Took me a minute to grok this one, and yes that's rather neat.
Fun with Java Enums today. A bit of care required for part 1 and then most of the building blocks were already there for part 2.
String split seems like a reasonable approach to me. What's wrong with having a string array?
5 days ago
The regex for part 1 was pretty straight forward but I quickly found another solution for part 2 that didn't require gnarly complicated regex.
I didn't even attempt to figure out the regex for part 2, I split the input into smaller "enabled" substrings and ran each of them through my part 1 solution.