Articles tagged #rust

The thumbnail for this page

Making our own executable packer

In this series, we’ll attempt to understand how Linux executables are organized, how they are executed, and how to make a program that takes an executable fresh off the linker and compresses it - just because we can.

The thumbnail for this page

Day 14 (Advent of Code 2020)

It’s time for the Day 14 problem!

After the hassle that was Day 13, I hope this time we’ll have a relatively chill time. And, at least for Part 1, that is true.

Our input looks something like this:

mask = XXXXXXXXXXXXXXXXXXXXXXXXXXXXX1XXXX0X mem[8] = 11 mem[7] = 101 mem[8] = 0

mem is our memory. Our addresses are 36-bit wide, but as you’ll see, that doesn’t matter much.

The thumbnail for this page

Day 13 (Advent of Code 2020)

In the Day 13 problem, we’re trying to take the bus.

Our input looks like this:

939 7,13,x,x,59,x,31,19

The first line indicates the earliest minute we can leave from the bus terminal, and the second line indicates the “identifier” of the buses that are active.

Each bus departs every “bus ID” minutes - bus 7 leaves at minute 0, minute 7, minute 14, minute 21, etc. The question is: which bus can we take first (apparently they either all go to the same destination, or we don’t really care where we’re going), and how long do we have to wait for it?

The thumbnail for this page

Day 12 (Advent of Code 2020)

Time for the Day 12 problem!

In this problem, we have a ship. And we have navigation instructions:

  • Action N means to move north by the given value.
  • Action S means to move south by the given value.
  • Action E means to move east by the given value.
  • Action W means to move west by the given value.
  • Action L means to turn left the given number of degrees.
  • Action R means to turn right the given number of degrees.
The thumbnail for this page

Day 11 (Advent of Code 2020)

Another day, another problem.

This time the problem looks suspiciously like Conway’s Game of Life, or, I guess, any old Cellular automaton.

We have a map like so:

L.LL.LL.LL LLLLLLL.LL L.L.L..L.. LLLL.LL.LL L.LL.LL.LL L.LLLLL.LL ..L.L..... LLLLLLLLLL L.LLLLLL.L L.LLLLL.LL

And for each iteration:

  • L symbols turn into # if there’s no # in any of the 8 adjacent cells
The thumbnail for this page

Day 10 (Advent of Code 2020)

Cool bear

Day, 10! Day, 10!

Okay, Day 10.

Again, the problem statement is very confusing - but what it all boils down to is this. We have a list of numbers:

16 10 15 5 1 11 7 19 6 12 4

To which we need to add 0 and whatever the maximum was, plus three:

16 10 15 5 1 11 7 19 6 12 4 0 22

From there on, if we take them in order, we’ll have gaps of 1 and gaps of 3:

The thumbnail for this page

Day 9 (Advent of Code 2020)

Day 9’s problem statement is convoluted - the “ah maybe that’s why I don’t usually do Advent of Code” kind of convoluted, but let’s give it a go anyway.

So, we have a series of numbers, like so:

35 20 15 25 47 40 62 55 65 95 102 117 150 182 127 219 299 277 309 576

And uh the first N numbers are a “preamble” and every number that comes after that must be the sum of any two of the numbers that come before it.

The thumbnail for this page

Day 8 (Advent of Code 2020)

Time for another Advent of Code 2020 problem!

That one sounds like it’s going to be fun. Our input is pretty much assembly, like this:

nop +0 acc +1 jmp +4 acc +3 jmp -3 acc -99 acc +1 jmp -4 acc +6

So, the first thing we’re going to do is write down some types.

There’s more than one way to approach this problem, but let’s go with this:

#[derive(Debug, Clone, Copy)] enum InstructionKind { Nop, Acc, Jmp, } #[derive(Debug, Clone, Copy)] struct Instruction { kind: InstructionKind, operand: isize, } type Program = Vec<Instruction>;

Go back to the homepage.