Posts

Notes, reflections, and long-form write-ups on backend engineering and learning.

Advent of Code Commitment pt 2

For personal reasons reached day 7 part 2, very far from my objective of reaching day 12 and sometimes procrastinating on YouTube and not taking into consideration that the exercises get harder day by day. For example yesterday wanted to finish the day 7 part 2 and day 8. And it took probably 3 hours only to check that my recursive approach was taking too much time but I was not sure it was on a loop or not because its hard to track a state.

So I've redone it using a Depth-First-Search approach have the openPaths saved on a array so I could debug it and was sure that would be enough but when doing the logging of the state my worst feeling was right it was taking too much time like the recursive approach. I thought of using the BFS but that would not help me because I wanted the total number of timelines not the shortest one. Did not want to search for algorithms. Wanted to think more about the best approach because I could feel I had more options to explore.

On the DFS saw we had a lot of repetition passing on the same paths very often only changing one or two vertices from on timeline to another, so on the matrix input instead having a line when we pass a point what if we had the number of paths that passed there and then we would add that number to each number of paths that pass through there from other origin. It will be my next approach, hope it goes well!.

Since the exercises are getting harder I could think of doing one exercise two in two days doing one part each day but I'll keep the same objective of doing one exercise each day to keep the rhythm, I will start early on the morning to have some margin at the end of day if a need some more time. I'll end day 7 today and keep on day 8 tomorrow early in the morning after a morning run.

Doing the math, if I do day 7 exercise today and one exercise each day I'll complete the 12 days exercises on March 16th Monday. Lets do it.

Stay focused.

Advent of Code Commitment

I know it is not advent but wanted to practice my brain problem solving section because it is getting rusty since finishing college. And I’m afraid only the ones with a sharp problem solving mentality and a good abstract thinking will be able to survive into the AI era, adapting quickly to new circumstances and tools. So lets start by the foundations that is problem solving on code with C# and what is the best way to do that then the Advent of Code challenge? There is also Exercism but I found the AoC more challenging.

I started by doing a console application where I could pass the day I wanted to run and if I wanted to run the demo input or the final input. Went this way to avoid commenting and uncommenting code each time I wanted to run the application only needing to add a new case in a switch for each new day I’m developing:

Switch case for Advent of Code

Unit Tests

Since first we want to solve the problem and then after being 3 days thinking how to solve it and reach a solution we see it takes so much time and certainly somebody in the world took 1 percentile of our resources to solve the problem I’m pretty sure we can improve our solution but to avoid breaking it nothing better then doing unit tests so in the future when we improve the solutions we won’t break anything. Thinking about that, need to check how to run the unit tests automatically when trying to do a commit (not sure if is possible), i know we can do it on a merge request.

This week I purpose solving one exercise each day. Today is March 2nd so on March 9th I'm expecting to have solved all the exercises, kinda hard because the problems are getting harder but we are here to push ourselves beyond our limits , right? So we can improve.. Lets do it!

Stay Focused,

A. Reis