Advent of Code 2021
Solutions for 2021
Day 1 ⭐ ⭐
- How many numbers are bigger than the previous number?
- How many sums of three numbers are bigger than the previous three?
difffunction is very nicedifffunction has alagargument :)
Day 2 ⭐ ⭐
- Follow the forward, down, up instructions. Where do you end up?
- Actually, the instructions are different. Where do you end up?
- Use a tibble rather than a loop, and sum the columns, because it’s linear
- Similar, but a couple of extra steps, because it’s cumulative
Day 3 ⭐ ⭐
- Find the ‘gamma’ and ‘epsilon’, calculating the most common bits in the columns.
- Finding the ‘oxygen’ and ‘carbon dioxide’ is a bit more difficult.
strtoiis the perfect function for this.- Determine each column sequentially, so, recursive function with colnum as input.
Day 4 ⭐ ⭐
- Which bingo card will win first?
- We should let the giant squid win, which card will win last?
- Lots of preparation and calculation and checking functions for this
- We have to go through all the numbers to see which one is last
- I don’t think there’s any way around this, there’s no secret
Day 5 ⭐ ⭐
- Calculate what is happening with some hydrothermal vents
- Calculate what is happening with all the hydrothermal vents
- Create a matrix and add 1 to all the plumes
- Do the same thing with all the diagonals as well
Day 6 ⭐ ⭐
- Find how many lanternfish there are after 80 days
- How many lanternfish are there after 256 days?
- Loop, apply the rules
- Again, loop again
Day 7 ⭐ ⭐
Day 8 ⭐ ⭐
Day 9 ⭐ ⭐
Day 10 ⭐ ⭐
Day 11 ⭐ ⭐
Day 13 ⭐ ⭐
Day 14 ⭐
Day 17 ⭐ ⭐
- Find the highest trajectory that lands in the box
- How many trajectories land in the box?
- This could probably be solved in a nicer way than what I did, but I got there
- Three of the x velocities gave the same max height which is cool but also probably mathematical
- Part one you were only shooting up but part two you can shoot down as well
Day 20 ⭐
Day 22 ⭐
Day 23 ⭐