Articles tagged #rust
Day 8 (Advent of Code 2022)
In the day 8 problem, our input is a height map:
30373
25512
65332
33549
35390
This is a 5x5 grid, and every number denotes the height of a tree. For part 1, we must find out how many trees are visible from the outside of the grid.
If we consider the first row, from the left: only the 3
is visible: it
obscures the 0
. From the right, 3
and 7
are visible.
Day 7 (Advent of Code 2022)
The day 7 challenge talks about trees! File trees that is.
The temptation to solve it before starting to write this article so I don't look silly is high, but I'm explicitly not doing so, so that we can bang our collective heads against any walls at the same time, and see how we can get out of it! Trees are serious business!
Part 1
The sample input looks like this:
Day 6 (Advent of Code 2022)
Today I am joining you from the relative discomfort of my living room (since my better half has commandeered the home office due to Way Too Many Calls) to tackle the day 6 challenge, which I'm excited about: maybe despite, maybe because of, the low-grade fever I'm under.
Part 1
Our input is a jumble of letters, and we're supposed to find the position of the first substring that's "four different characters".
Day 5 (Advent of Code 2022)
Part 1
The day 5 challenge actually looks fun!
Our input looks like this:
[D]
[N] [C]
[Z] [M] [P]
1 2 3
move 1 from 2 to 1
move 3 from 1 to 3
move 2 from 2 to 1
move 1 from 1 to 2
Which is a visual representation of stacks, and so, for once, we have some serious parsing to do, and that means I finally have a good reason to bust out the nom crate.
Day 4 (Advent of Code 2022)
Part 1
Let's tackle the day 4 challenge!
In this one, we get an input like this:
2-4,6-8
2-3,4-5
5-7,7-9
2-8,3-7
6-6,4-6
2-6,4-8
Each line has two ranges: the first line has ranges containing 2, 3, 4, and 6, 7, 8. We must count how many pairs have ranges where one fully contains the other.
In Rust, we can express this with "inclusive ranges" (), and those implement , so we can do:
Day 3 (Advent of Code 2022)
Part 1
I'm not sure where the day 3 challenge is going, because the problem statement for the first part is kinda convoluted.
As usual we have an input, like this:
vJrwpWtwJgWrhcsFMMfFFhFp
jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL
PmmdzqPrVvPwwTWBwg
wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn
ttgJtRGJQctTZtZT
CrZsJsPPZsGzwwsLwLmpwMDw
Each line represents the contents of a "rucksack", divided in two halves (which are called "compartments"), so for line 1:
Day 2 (Advent of Code 2022)
Part 1
In the day 2 challenge, we're playing Rock Papers Scissors.
We're given a strategy guide like so:
A Y
B X
C Z
Left column is "their move": A means Rock, B means Paper, C means Scissors. Right column is "our move": X means Rock, Y means Paper, Z means Scissors.
Each line corresponds to a turn, and we must calculate the total score we get. Picking "Rock" gives 1 point, "Paper" gives 2 points, and "Scissors" gives 3. Losing the round gives 0 points, drawing gives 3, winning it gives 6.
Day 1 (Advent of Code 2022)
Two years ago, I did part of Advent of Code 2020 using the Rust language. It was a lot of fun, so let's try it again!
The problem statement
Our input looks something like this:
1000
2000
3000
4000
5000
6000
7000
8000
9000
10000
Each group of lines separated by an empty line is a list of food items an elf is carrying: each line corresponds to the number of calories in that food.
Go back to the homepage.