Solutions for 2022
Day 1
- Find the elf with the largest amount of calories
- 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
- Follow a strategy guide for how to win at Rock Paper Scissors
- The strategy guide shows if you should win or lose
- Create a function! Loop the things!
- Create a slightly different function :)
Day 3
- Find the common letter between the first half and second half of a string
- 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
- Find if one set of numbers is within another set
- Find if there are any overlap between the pairs of sets
- Data preparation, and create a function
- Create a slightly different function
Day 5
- Move some crates around on stacks. Which crate ends up on top of each stack?
- 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
- Loop through the input, and find four characters in a row that do not repeat
- Loop for fourteen unique characters
- A set is a unique ‘list’, and if these are the same, we find what we want
Day 7
- Find the total size of ‘small’ directories by going through the directory structure
Day 8
- Find the trees that are visible from outside the grid
- 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
- Move around a grid with tail following head
- 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
- Loop through some instructions and record where we get to at 20 steps
- 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
- Some monkeys are throwing your things around, keep track of them
- 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
- Three’s a map of where you have to go, but can only go one step up at a time.
Day 13
- The distress signals are all mixed up, which ones are in the correct order?
Day 14
- There is sand dropping down in the cave - how much before it slips over the rocks?
- 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
- Deploy some sensors and detect some beacons - how much space is covered in a particular row?
- 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
- Release some pressure in some valves - as much pressure as possible in 30 minutes.
Day 17
- There are 2022 rocks falling down, getting moved about by some gas, how tall does the tower of rocks get?
Day 18
- A funny shaped lava droplet might turn into obsidian! What’s the surface area?
- 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
- Construct some robots to gather ore, clay, obsidian, and geodes.
Day 20
- You have a list of coordinates but need to decrypt the file by ‘mixing’.
Day 21
- The monkeys are yelling some numbers, you need to figure out the math
- 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
- The monkeys have a plan to get you through a weird map. Where do you end up?
Day 23
- Help the elves spread apart to plant some trees. How far do they get after ten rounds?
Day 24
- Make your way through a blizzard, how many minutes does it take to get through?
Day 25
- Figure out some weird base 5 math for the hot air balloon fuel to get outta here.
- Earn the other stars