Advent of Code 2022

Solutions for 2022

Day 1

  1. Find the elf with the largest amount of calories
  2. Find the sum of the three largest amounts of calories
  • Add up the items, separated by blank lines
  • Sort the array from part one

Day 2

  1. Follow a strategy guide for how to win at Rock Paper Scissors
  2. The strategy guide shows if you should win or lose
  • Create a function! Loop the things!
  • Create a slightly different function :)

Day 3

  1. Find the common letter between the first half and second half of a string
  2. Find the common letter between three sets of strings
  • ord() is a good function to give the score of a letter
  • We can operate on pandas dataframes as an interesting way to keep results organised
  • Love a good lambda function.

Day 4

  1. Find if one set of numbers is within another set
  2. Find if there are any overlap between the pairs of sets
  • Data preparation, and create a function
  • Create a slightly different function

Day 5

  1. Move some crates around on stacks. Which crate ends up on top of each stack?
  2. Move the crates around but they all get moved at once
  • Wrangle the data into a thoughtful organisation to enable stack movements
  • Make sure we follow instructions properly
  • Write a slightly different implementation of movement, which was actually what I did in the first step.

Day 6

  1. Loop through the input, and find four characters in a row that do not repeat
  2. Loop for fourteen unique characters
  • A set is a unique ‘list’, and if these are the same, we find what we want

Day 7

  1. Find the total size of ‘small’ directories by going through the directory structure

Day 8

  1. Find the trees that are visible from outside the grid
  2. Find the tree with the best ‘scenic score’
  • Work through the logic carefully, it probably could be a little function and list comp
  • A bit more complicated, so create a function to count trees and scores

Day 9

  1. Move around a grid with tail following head
  2. Move around, but with a whole rope, ten units from head to tail
  • Move the head, create a function to check if the tail goes along too, record the results
  • Part two is much more difficult, with checking movement of all the pieces

Day 10

  1. Loop through some instructions and record where we get to at 20 steps
  2. The instructions describe the pixels on a small screen, what does it say?
  • Reasonably simple loop recording some values along the way
  • A little bit more complicated with the sprites and the cycles but ultimately OK

Day 11

  1. Some monkeys are throwing your things around, keep track of them
  2. Keep track of the things after many more rounds of throwing things.
  • We’re not meant to write the problem specification in public but I don’t see a way around it
  • There are lots and lots of rules
  • I’m sure there’s a pattern trick to this, the objects keep going through the same monkeys’ hands, but just run for a long time.

Day 12

  1. Three’s a map of where you have to go, but can only go one step up at a time.

Day 13

  1. The distress signals are all mixed up, which ones are in the correct order?

Day 14

  1. There is sand dropping down in the cave - how much before it slips over the rocks?
  2. There is a floor in the cave and much more sand falling down - how much more?
  • It’s important to set the problem up properly and make the cave look intuitive
  • Change the stopping conditions for part two and the final counter calculation.

Day 15

  1. Deploy some sensors and detect some beacons - how much space is covered in a particular row?
  2. There is only one space where the distress beacon could be - where is it?
  • Some nice regex for getting the locations of sensors and beacons
  • I have two gold stars but no other code? How did I figure this out? Did I not save properly? Ugh.

Day 16

  1. Release some pressure in some valves - as much pressure as possible in 30 minutes.

Day 17

  1. There are 2022 rocks falling down, getting moved about by some gas, how tall does the tower of rocks get?

Day 18

  1. A funny shaped lava droplet might turn into obsidian! What’s the surface area?
  2. There are some internal air pockets and the surface area is actually less.
  • Construct a nice array and count the sides.
  • Create a different array and count the sides.

Day 19

  1. Construct some robots to gather ore, clay, obsidian, and geodes.

Day 20

  1. You have a list of coordinates but need to decrypt the file by ‘mixing’.

Day 21

  1. The monkeys are yelling some numbers, you need to figure out the math
  2. You need to yell a number as well, and make the last two numbers match.
  • I probably spent a while on this initially getting the calculations right
  • It’s really fun to come back to and make improvements!
  • Part two could probably still be done better but it’s fine with some manual loops.

Day 22

  1. The monkeys have a plan to get you through a weird map. Where do you end up?

Day 23

  1. Help the elves spread apart to plant some trees. How far do they get after ten rounds?

Day 24

  1. Make your way through a blizzard, how many minutes does it take to get through?

Day 25

  1. Figure out some weird base 5 math for the hot air balloon fuel to get outta here.
  2. Earn the other stars