Advent of … — Day 7-9

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...