Advent of Code 2020, day 10

Today is day 10 already! And it’s a pretty interesting one. We’re dealing with sequences of numbers, and differences between those numbers. Each number needs to have a difference of 1, 2, or 3 with the previous one. Parsing this list of numbers is trivial. For this problem, it helps to add 0 to that list (as it’s always the initial number to consider). And since we must consider them from 0 to their max value, it also helps to sort it:

Advent of Code 2020, days 7, 8 and 9

I’m a bit late, so here are days 7 to 9. As now usual, all my solutions are available on Day 7: Handy Haversacks Bags inside bags inside bags… Do we have recursive bags now? 😯 Anyway. The first step is to parse those descriptions into something more usable. I’ve decided to do it without regexps, and storing data in simple dicts: def parse_rule_line(line: str) -> Tuple[str, Dict[str, int]]: """Parse 1 rule line.

Advent of Code 2020, days 5 and 6

This weekend was days 5 and 6. As always, all my solutions are available on Day 5: binary boarding Today we are dealing with boarding passes, and parsing strings into seat numbers. The description is pretty straightfoward: for each part of the boarding pass we have a lower and upper bound, and each new characters divides the search space in 2. Classic binary search! def bisect(seq: str, up: str, hi: int) -> int: """Bisect using a string.

Advent of Code 2020, day 4

It’s day 4… As before, all my solutions are available on Today we’re dealing with passport validation. Spoiler alert: as often with data validation issues, it’s pretty boring… Okay, let’s parse those passports. Split input when there are 2 newlines, split each block on whitespace, parse key:value entries. Boring! class Passport(dict): @classmethod def from_kv_str(cls, data: str) -> "Passport": res = cls() for field in data.split(): k, v = field.split(":", 1) res[k] = v return res data = [Passport.

Advent of Code 2020, day 3

It’s day 3 already! As before, all my solutions are available on Today we’ll talk about toboggan trajectories!1 In typical AoC fashion, our input is a map in ASCII art. What’s important to us is its size and the position of the trees… So we’ll parse this input and store just that: the width and height of the map, and the coordinates of all trees as a set of (x, y) tuples.

Advent of Code 2020, day 2

Let’s go for Day 2! As before, all my solutions are available in a Git repository: Today’s puzzle is about password policies. Our input is made of line with a simple structure: we can parse them with a simple regular expression, and store the result in a dataclass. (We could also use a namedtuple or even a tuple, but using a class we can add methods and properties, which is often useful.

Advent of Code 2020, day 1

It’s that time of the year again: the Advent of Code 2020 has started! For those who don’t know, Advent of Code is an Advent calendar of programming puzzles. Simple at first, not-so-simple after one week or two usually. This year I’ve decided to try to write a small recap every day. Or, well, whenever I solve those puzzles, which may be a few days late, or even way later if things don’t go as planned 😅

New theme, new content

I was getting tired of Minimo, the theme used on this blog. So I created a new one from scratch. I like it a lot, but I’m obviously biased 😉 Some things I used: Marx, a classless CSS reset. Nice and minimal. SCSS, rendered with Hugo Pipes. Only readable source code in the Git repository! Iosevka fonts: Iosevka Sparkle for normal text (duospace, like iA Writer Duo), and the normal Iosevka monospace font for code.

Hackers: Heroes of the Computer Revolution

In this book, Steven Levy tells the history of modern computing. From the first MIT hackers who started working on model railroads before discovering early TX-0 and PDP-1 mainframes to video game creators working at Sierra; from Peter Samson, John “Captain Crunch” Draper, and Woz, to Richard Stallmann Steve Jobs and Bill Gates… decades the history of early computers and their progressive discovery by the general public. Originally published in 1984, this book also describes the hacker ethics:

Aya Nakamura vs Kaamelott

Pour se changer un peu les idées en cette période de confinement… C’est très con mais ça me fait rire !