Posts
Power of approval
During a 1-on-1 with my lead, I (or better to say we) came to a great realization that I wanted to share. Let me start by setting some context. Last half year, I’ve been running a new interim leadership position. It was on a temporary base to see if I was a good enough fit for the role. Due to personal reasons, the decision to make it permanent had been delayed from two months to half a year.
Setting up a self-hosted blog is easy
In contrast to what I said in my previous post setting up a self-hosted blog is easy. It is almost so easy that I was doubting if I should write about it (or that could be my anxiety again. 😉) What do we need to for our setup:
- A domain name (w8mr.nl for me, which I already own)
- A place to host (For me, my NAS)
- CMS software (After some small research I stopped at Ghost)
- Docker host (Already running on my NAS)
- Http2/TLS termination (NginX already running on my NAS)
- A template (Caffeine theme, because I liked it)
Most of it was already in place for me. Via the website i found the instructions of setting it up via Docker, as most software has these days. Not all software has docker images supporting ARMv7 cpu architecture
Day 12 - Easy, but so many mistakes
Sometimes you know you shouldn’t do something but you do it anyway. Today I made that mistake on the assignment. It was a simple assignment we have a ship, with a direction (N,E,S,W) and a location on a grid. And some simple instructions on how to change the direction and location. My plan was to write a simple function that takes the current state (direction and location) and an instruction to return the new state. I would use pattern matching to write out each individual situation. It would be a solution with lots of duplication, but it would be fast to write. This was the result.
Day 11 - Very slow
Grids are back again, but quite different this time, and still no pathfinding though. Today’s assignment is based on Game of Life van John Conway. A board game where cells are turned on and off based on a few rules. The rules of this grid are a little different. There are cells that do not change. And the rules on when a cell is flipped are a little different.
There are different ways to keep track of the data in a grid. Each way has its own advantages and disadvantages. Today’s grid will change in rounds. In each round, a cell will get a new value based on the neighboring cells. A cell has a seat or no seat (this will not change), the cells with a seat can either be empty or occupied.
Setting up a self-hosted blog is hard
Today I will explain why even for a seasoned developer it can take months to set up a self-hosted blog. Let me first start with a small introduction on why I wanted to have a blog. Basically what it comes down to is that I wrote a series of articles on my Advent of Code experience and I really liked doing that. Although I was not able to complete the whole 25 days of articles like I had planned, because It took way too much energy, getting up at half-past 5, doing the Advent of Code, making breakfast for the family, do my work, pick up quite some chores in the house since my wife was 38+ weeks pregnant, and writing an article late at night, but still I knew I liked it enough to keep on writing articles. The series was written on LinkedIn, but that didn’t feel like me, so I needed a place for myself to blog. Being a developer and capable of setting up a blog myself, I took things into my own hands and went for a self-hosted solution.
Day 9 - Heads or tails....or inits
We have to crack some cipher today, to do that we have to find a weakness in the encryption. I shall go into the solution a little bit deeper to explain how list comprehension works as it is such a powerful feature of the language..
Our input is a list of numbers, the numbers follow a rule and the first number that breaks the rule is our weakness. The first number that is checked is the 26th number, for this number to be valid it has to be a sum of two numbers in the first 25 numbers (called the preamble). For the next number (27th) it has to be the sum of two numbers in the range of the 2nd number until the 26th. And so on. The first number that doesn’t follow this rule is the weakness and also the answer to our puzzle. My cleaned implementation looks like this.
Day 8 - Thinking ahead
A first glance at today’s assignment meant that it was going to be fun. We are going to build our own CPU emulator. Last year on day 2 there was also a CPU emulator, which got extended and reused every other day starting from day 5. These assignments were very much fun to do and I had already hoped to see such an assignment again this year, and maybe even a series of assignments. If you also did join last year, let me know your thoughts on this, did you also liked it just like me?
Day 7 - Megaparsec
Today my 2 year old helped me to get up at 5.30, so I had about 20 minutes more than I would have normally have for getting settled at my laptop. Except for the loss of sleep that was a good thing, I was way more energetic when starting day 7.
For this assignment, we have a list of rules which describe how color coded bags should contain other color coded bags (and how many). This can be represented as a graph, a weighted Directed Acyclic Graph to be exact, also known as a DAG. In the graph each node (also called a vertex) is a bag and connected to the bags it should contain by an arrow (also called an edge.) In the diagram above the article, you see our example input as a graph. In the acronym DAG, directed means that the edges have a direction, acyclic means that there are no cycles, so if you follow the edges you can never reach a node twice and you will eventually reach a node from which there are no outgoing edges. Weighted means that a weight is associated with each edge.
Day 6 - Lights on
Today I suddenly woke up, the lights were turned on by my two year old who was sleeping in our bed because he was crying in his own bed. My first thoughts were turn off those lights and go back to sleep it is the middle of the night. Is it the middle of the night? My alarm didn’t go off yet. Was it time almost time, lets check my phone to see how long I’ve still got left. Damn, my battery was dead, looked at my watch…. 7:20. No good score for today again. After some internal swearing, I got up went to the living room with my son and made some coffee, opened the laptop, and started on day 6.
Day 5 - Simple and yet still too complex
In today’s assignment, it was not very complex to find a solution. But even in a solution you still can make things too complex. Would I’ve made a small drawing of what I was doing, I could have made my solution even more simple. Also using some of Haskells features helps to clean up the code.
The first thing you have to do is to read in a very long story that you need to convert a letter code into a seat number. Once you drill down to the essence, you will see that basically, the letters represent the 0’s and 1’s in a binary number. F and B for the row number, L and R for column number. The final seat number is calculated by multiplying the row number by 8 and adding the column number. Your input is a list of all letter codes, and you need to find the maximum seat number. This is my initial solution
Day 4 - Daily routine
In today’s assignment, we have to check passports to see if they are valid. There are different fields with information in it. For a password to be valid there should be 7 fields present and there is 1 specific field that may be present. In part 2 there were some extra rules for the 7 fields.
There are two things stopping me from getting a decent time in the competition. The first is that although I knew how to solve the problem, I had a hard time finding the right functions (and syntax for them) in Haskell. Finishing part 1 already took 44 minutes because of that. That gets me to the second problem. Today I, of course, got up a little before 6, but normally I get up at around 7, and I prepare breakfast and wake my wife and kids and we have breakfast together. So today I worked on the assignment till a little to 7 and switched over to my normal routine. Had breakfast, prepared the kids for school. And brought my youngest daughter to school. Usually, this is done by my wife, but my daughter wanted to ride on her own bike to school today. Since my wife is over 37 weeks pregnant, she is not able to have enough control over my daughter riding her bike herself if she makes a mistake. She is 5 so she doesn’t always have full control over the bike. So today I offered to bring her to school. After getting home, my normal working day starts on which I have a meeting at 9, so I had to follow that. So at 9.30 I finally got some time to spend on Advent of Code (I can be flexible in my working hours, so there is no problem having a break from work.) So at three minutes to 10, I was done with part 2, just in time for my next meeting. But oh man, 43rd place of the day and dropped way down to 12th place in the full competition.
Day 3 - Read, read, read!
Opening the page for day 3 gives me a small scare… grids, it’s the first thing that catches my eye. As you may have guessed, I’m not a fan of grid assignments. I knew that they were coming, but so soon in the competition? After my initial reaction, I started reading the assignment, luckily for me, I learned while reading the assignment that solving it would not require building a grid and finding a path through it.
Day 2 - Bigger is better... or isn't it?
After a rusty start of day 1, we have to fix a broken password database today Our input exists of a list of passwords and for each password a policy. This is our example input:
1-3 a: abcde
1-3 b: cdefg
2-9 c: ccccccccc
Looking the first part of each line is the policy, it means that there should be between 1 and 3 a’s in the password. So the first one is a match. The second is not. There are no b’s. The third is a match, there are 9 c’s. The final answer is the number of matching passwords, for this example that would be 2.
Day 1 - Rusty at start
Haskell is my language of choice for the annual Advent of Code event. Most people probably don’t know what I’m talking about. Within the developer community, it might be known a bit more, but even there a lot of people might not know it. So let me explain, Advent of Code is an annual competition held for the sixth time this year. It is a coding competition held over a period of 25 days. One assignment each day, hence the name Advent of Code, named after the Advent calendar. Well, actually each daily assignment consists of two parts, with each part you can earn a star. So in total 50 stars can be earned. The theme for all assignments is of course Christmas. Something in the line of the elves making all sorts of devices to help Santa Claus save Christmas, this year we are helping Santa to get a well deserved holiday.