Enjoy the detours!

AdventOfTypescript

Typescript

https://toot.cafe/@danbruegge/113627528663963611 https://toot.cafe/@danbruegge/113634647472295596

Day 10

Bit manipulation. I like this topic. It hit the right spot, not too hard, not too easy. πŸ‘Œ

Day 11

Day 11 forced me to do some research. First, I didn't know what I should do. Then, I got it but didn't know, how to write the types. It is this kind of solution, I'm not doing really often. In the end, this is why I'm doing it. To get a refresher and/or learn something new. 😎

Code

https://toot.cafe/@danbruegge/113628616030122785

Finally, my first ⭐ for Day 6. It took me so long because I was out of time and also introduced a bug, while coding everything without running it step by step. This took a lot of time, and starting over was the best Idea.

Currently, I'm looking at Part 2 and have some Ideas, how this could be solved. Such an exciting topic and I need more time. πŸ˜…


53 of #100DaysToOffload

#log #AdventOfCode #AdventOfTypescript

Thoughts? Discuss...

Typescript

https://toot.cafe/@danbruegge/113622635786773947 https://toot.cafe/@danbruegge/113622656791503108 https://toot.cafe/@danbruegge/113622669697365751

Day 7

Day 7 gave me a bit of a struggle and I went with the easy solution by creating a union and hard-coded the expected array into the type. I'm sure there is a better solution, but I didn't find anything.

Here is my solution. So it is not wrong because it takes the test green. But we know that this will not mean that the solution is correct. :D

const createRoute = <
  Route extends
  | ["Atherton", "Scarsdale", "Cherry Hills Village"]
  | ["Detroit", "Cleveland", "Dayton"],
>(
  author: string,
  route: Route,
) => ({
  author,
  route,
  createdAt: Date.now(),
});

Day 8-9

Like the days 1-6, they were effortless. I expect that the next days will be harder.

Code

No real progress since Friday. I've looked into Day 5 and skipped it for now. I've started to write code for Day 6, which makes a lot of fun I'm not at the end. The last time I've looked into 2D Tile maps, was +10Β years ago.


52 of #100DaysToOffload

#log #AdventOfCode #AdventOfTypescript

Thoughts? Discuss...

Typescript

https://toot.cafe/@danbruegge/113604656521141559

Done in the morning without problems, again and again. 😎

Code

Finally. :) I've got ⭐⭐ on Day 4. Once you get the hang of it, Part 2 is easily solvable. 😎

I'm so happy right now. And I'm excited about the next challenge.

100DaysToOffload

Regarding the #100DaysToOffload challenge, I'm halfway through. Another achievement today. πŸ₯³


50 of #100DaysToOffload

#log #AdventOfCode #AdventOfTypescript

Thoughts? Discuss...

Typescript

https://toot.cafe/@danbruegge/113599034688863789

Done in the morning without problems, again. 😎

Code

Because of my current work schedule, I had no time, so no progress here. I have looked into today's challenge, but still need to do Day 4. Over the day I had some ideas which I like to test and play with. It's doable. Reminds me a bit of 2D tile maps. Which is a long time since I did anything with it. Maybe I was 14–16 years old. In my RPG-Maker days. Because of family stuff on the weekend, I don't see me completing the Day 4 challenge before next week. I completely underestimated how hard these challenges are, for me. πŸ˜…


49 of #100DaysToOffload

#log #adventOfCode #adventOfTypescript

Thoughts? Discuss...

Typescript

https://toot.cafe/@danbruegge/113593611272804600

Done in the morning without problems. 😎

Code

First time, where I will not get it done on time. So far, I've committed my current state and pushed it to my gitea instance. Let's see if I can get it done tomorrow. I think my solution is simple enough, but I lack experience in this area. In the last hour, I was just try and error'ing my way through the code.

It really annoys me that I didn't make it. As an excuse, my workday was quite heavy, and I need to recharge first.

Maybe tomorrow will be better. ✌️


48 of #100DaysToOffload

#log #adventOfCode #adventOfTypescript

Thoughts? Discuss...

Typescript

https://toot.cafe/@danbruegge/113587602136584312

I solved this one β€œearly” in the morning. This one, was also a no-brainer.

Code

https://toot.cafe/@danbruegge/113588572520140901

This was a nice and fast one. I always enjoy playing with Regexp. Only Part 2 gave me a struggle, because of my thought process. I tend to do things much more complicated than they should be. :D

Here is a little example:

export function getDoMulCalls(input: string): any {
  const startRe = /^(.*?)don\'t\(\)/g;
  const middleRe = /do\(\)(.*?)don\'t\(\)/g;
  const endRe = /do\(\)(.*?)$/g;

  const startDos = Array.from(input.matchAll(startRe), match => match[1]);
  const middleDos = Array.from(input.matchAll(middleRe), match => match[1]);
  const endDos = Array.from(input.matchAll(endRe), match => match[1]).filter(endDo => !endDo.includes("don't()"));

  return [...startDos, ...middleDos, ...endDos].map(getMulCalls).flat();
}

This will not give you the solution to Part 2. I thought this was simple and clever at the same time. But I needed to start fresh and remove the cleverness from the code. Bonus, I've learned something new with JavaScript and Regexp. :)


47 of #100DaysToOffload

#log #adventOfCode #adventOfTypescript

Thoughts? Discuss...

Right on time. Sadly, this post is on the next day, but I've completed both challenges before midnight. :D

Code 2024

https://toot.cafe/@danbruegge/113585692081934453

Part 2 gave me a real struggle. I just got it by luck and think that my original solution is still right, provided all the information there was on the page. Out of desperation, I have thrown my solution for Part 2 overboard and decided to try a different approach. It makes sense. But if you compare it with the information on that page, it makes less to no sense. Until this point, I've had a lot of fun and hopefully the challenge tomorrow is not easier, but the information on the page tells everything you need to know.

Typescript 2024

https://toot.cafe/@danbruegge/113585716545107593

Like Day 1, this one a no-brainer. But I remember from last year, it gets more difficult by each day.

Conclusion

For AoC Day 2, Part 2, I took too much time into the solution. Because it was not obvious. But...mimimi. :D


46 of #100DaysToOffload

#log #adventOfCode #adventOfTypescript

Thoughts? Discuss...

In 2023, I've participated in the Advent of Typescript for 8 Days. Currently, I don't understand why I didn't continue with it because it made a lot of fun. This year, I've resolved to complete as much as I can in Advent of Typescript, but also to join the Advent of Code 2024 and do here also as much as I can.

Code 2024

https://adventofcode.com/2024

For the Advent of Code 2024, I've decided to make it plain and simple with vite + typescript. To do more Test Driven Development, I will first write a test and add the code after.

https://toot.cafe/@danbruegge/113577659265521768

Typescript 2024

https://www.adventofts.com/

Visually, Advent of Typescript looks really nice. They let you write and test your types inside the browser, which makes writing there quite satisfying.

https://toot.cafe/@danbruegge/113577755016361905

Conclusion

I'll have set up a git repository, which I update after each Day is done. After the Advent of … is done, I'll publish the repo on GitHub.

Day 1 for both was basic. Let's see how the other days will be. I'm looking forward to that, they will be challenging, and I will learn a ton of new stuff.


45 of #100DaysToOffload

#log #adventOfCode #adventOfTypescript

Thoughts? Discuss...