Articles tagged #rust
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 movenorth
by the given value. - Action
S
means to movesouth
by the given value. - Action
E
means to moveeast
by the given value. - Action
W
means to movewest
by the given value. - Action
L
means to turnleft
the given number of degrees. - Action
R
means to turnright
the given number of degrees.
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
Day 10 (Advent of Code 2020)
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:
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.
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>;
Day 7 (Advent of Code 2020)
Another day, another Advent of Code 2020 problem.
That one seems fun! For some nerdy values of fun.
Our input is a set of rules:
light red bags contain 1 bright white bag, 2 muted yellow bags.
dark orange bags contain 3 bright white bags, 4 muted yellow bags.
bright white bags contain 1 shiny gold bag.
muted yellow bags contain 2 shiny gold bags, 9 faded blue bags.
shiny gold bags contain 1 dark olive bag, 2 vibrant plum bags.
dark olive bags contain 3 faded blue bags, 4 dotted black bags.
vibrant plum bags contain 5 faded blue bags, 6 dotted black bags.
faded blue bags contain no other bags.
dotted black bags contain no other bags.
Day 6 (Advent of Code 2020)
The end of Advent of Code 2020 is fast approaching, and we’re nowhere near done. Time to do Day 6!
The problem statement here is a little contrived, as uh, as the days that came before it, but that won’t stop us.
Basically, the input looks like this:
abc
a
b
c
ab
ac
a
a
a
a
b
Each line represents one person, and “groups of persons” are separated by blank lines.
Day 5 (Advent of Code 2020)
Time for another day of Advent of Code 2020.
For Day 5, we’re going to have to do…
Let me guess: more parsing?
Correct!
So there’s an airline that uses binary space partitioning when referring to seats - there’s 128 rows and 8 columns. The first 7 characters are either F (Front, for the lower half) and B (back, for the upper half), and the last 3 are L (Left, for the lower half) or R (Right, for the upper half).
Go back to the homepage.