Source: Day 11: Cosmic Expansion
Full solution for today (spoilers!)
Part 1
Read a grid of
#
(stars) and.
(empty space). For each completely empty line or row, add another. Calculate the sum of the Manhattan distances between all pairs of stars.
Full solution for today (spoilers!)
Read a grid of
#
(stars) and.
(empty space). For each completely empty line or row, add another. Calculate the sum of the Manhattan distances between all pairs of stars.
Full solution for today (spoilers!)
You are given as input an ASCII art pipe diagram with straight pipes
|-
, right angle turnsLJ7F
, ground.
, and a start tileS
.The start tile will be part of a loop of pipes.
Find the distance to the furthest connected pipe segment from
S
(or half the length of the loop).
Full solution for today (spoilers!)
Given a list of terms, repeatedly calculate the differences of terms until these differences are 0. So:
0 3 6 9 12 15 3 3 3 3 3 0 0 0 0
Calculate the sum of next terms for each sequence (18 for this one).
Full solution for today (spoilers!)
Given a (repeated) sequence of moves (
L
for left andR
for right) and a directed graph where each node has two neighbors (left and right), count how many total steps it takes to get from the nodeAAA
to the nodeZZZ
. The sequence of moves can (and will) need to repeat.
Full solution for today (spoilers!)
Simulate a limited poker game with no suits and break otherwise tied hands lexicographically (
AAAA2
beatsAKAAA
) because the the hands are both four of a kind, the first cards are bothA
, but the secondA
beats theK
. It doesn’t matter that the first hand’s off card was a2
Order all hands then calculate the sum of the ordering of hands (1 for best etc) times the bet for each.
Full solution for today (spoilers!)
Simulate charging up race boats with the behavior that waiting X seconds to start means you move at X units per second. Given time allowed and a target distance, determine how many (integer) numbers of seconds will beat the target distance.
Full solution for today (spoilers!)
You are given a set of initial values (seeds) and a series of range maps (where a range of numbers
src..src+len
maps todst..dst+len
). Apply each range map in tur, return the lowest resulting value.
Full solution for today (spoilers!). Note: I did slightly change my solutions template after writing this blog post, so the final solution is structured slightly differently than the code in this post. The functionality itself hasn’t changed.
Simulate scratchcards. Given a list of winning numbers and guessed numbers, count how many guessed numbers are in the winning list. Your score is 1, 2, 4, 8, … for 1, 2, 3, 4, … matching numbers.
Full solution for today (spoilers!). Note: I did slightly change my solutions template after writing this blog post, so the final solution is structured slightly differently than the code in this post. The functionality itself hasn’t changed.
Take as input a 2D grid of numbers or symbols (
.
represents empty space). Numbers will be 1 or more digits written horizontally which should be concatenated (.467*
is the number467
followed by the symbol*
).Sum all numbers that are adjacent (including diagonally) to at least one symbol.
Full solution for today (spoilers!). Note: I did slightly change my solutions template after writing this blog post, so the final solution is structured slightly differently than the code in this post. The functionality itself hasn’t changed.
Play a game where you have some number of red, green, and blue dice in a cup, which you draw and roll (without replacement). Which game is possible with only 12 red, 13 gree, and 14 blue cubes?
Input will look like: Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green