Tag: Advent of Code
Day 8 took a lot longer than the other days. Not all that much code and not too complex, at least after getting through a scary sounding lead up but going from problem statement to solution took both time and thought.
As I started to read the problem, I wasn't sure I'd finish it let alone have time to write it up.
Take a minute to read over the problem.
# COMMENTSToday's problem was similar to yesterday's in that it's ease or difficulty really depended on how you looked at the question.
For yesterday, the problem was hard if you approached it by modeling each and every lanternfish but it was much easier if you modeled the 8 days of the reproduction cycle. Sure, there was still work to be done but looking at the problem the right way made things much easier.
# COMMENTSToday we had to model the growth of the lanternfish population (problem here).
Lanternfish spawn new lanternfish every seven days. The trick is that the original starting population consists of fish at different points in the cycle. For instance, if your input data was 3,2,4 then each fish would spawn a new fish in three, two, and four days respectively. The new fish would set their timers to 8 and start counting down to their spawn date on the next day and the original fish would reset it's timer to 6.
# COMMENTSYesterday I wrote about the virtues of a simple straightforward solution as opposed to a super "clever" one. Today reminded me that what seems simple to one person might be clever to another.
Having successfully survived bingo with a giant squid, Today's challenge had us navigating our sub so as to avoid dangerous parts of the ocean. We were given a bunch of lines represented by endpoints as input. If we graphed all the lines, some of them would overlap.
# COMMENTSI always tell my students that the cleverest program is worthless if it doesn't actually work.
There are always some kids in class that all too often try to write the fanciest solutions.
They're the ones that write
int l(char *s){return !*s?0:(l(++s)+1);} instead of something like:
int string_length(char *s){ int i = 0; while (s[i] != 0){ i=i+1; } return i; } to calculate the length of a string.
# COMMENTSIt's that time of year again. Yep, you got it. Time for Advent of Code. I'm not feeling nearly as motivated as in past years but so far so good. Finished the first three days.
Today I got a good reminder - work through your examples. You can find today's problem here.
For part 1 you got a list of binary numbers and had to figure out how many ones and zeros there were in any given digit.
# COMMENTSTime for some final thoughts on Advent of Code 2020. This was my sixth Advent of Code but the first time I completed all 25 days. Better than last year's 31 and a whole lot better than my weakest effort of 11 stars in 2017. I managed to find the time to finish all but two on the day they were released and finished those two on Christmas morning. This was also the first year I wrote all my solutions in Clojure and I also made a bunch of blog posts and videos (linked on the bottom of this post).
# COMMENTSDay 24 didn't take that much time so I had a chance to go back and finish day 21.
As usual, all my code is up here. Day 21 Problem Link
It took me a while to get my head around this example. You have a set of recipes. Each recipe has a list of ingredients and a list of allergens. Your job for part 1 was basically to determine which ingredients don't contain any allergens.
# COMMENTSA few days have past so it's time for an update. Two more days to go and while I haven't completed all the problems, I have accumulated 43 stars which is a personal best. Given the nature of the problems I'm missing, I might even go back and do them at some point. Of course, I may very well also just crash out on the final two days.
As usual, all my code is up here.
# COMMENTSDay 17 Day 17 brought back Cellular Automata. It was a nice follow up to day 11. In my writeup I talked about data representation - how a Cellular Automoton like Conway's game of life is a nice 2D array project in a class like APCS-A but multi dimensional arrays are only one way to represent a cellular automaton. Day 17 really drove that home. The actual rules were pretty simple - if a cell is active and has 2 or 3 active neighbors it stays active.
# COMMENTS