diff options
Diffstat (limited to 'cube-conundrum/README.org')
-rw-r--r-- | cube-conundrum/README.org | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/cube-conundrum/README.org b/cube-conundrum/README.org new file mode 100644 index 0000000..ab000f5 --- /dev/null +++ b/cube-conundrum/README.org @@ -0,0 +1,34 @@ +See: https://adventofcode.com/2023/day/2 +** Part 1 +*** Purpose +Say there exists a bag containing an indeterminate number of colored cubes. In a series of "games", we reach our hand in an pull out an assortment, a number of times per game. We record our answers, using a semicolon (;) to denote putting the cubes back in the bag and re-grabbing more: + +#+begin_example +Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green +Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue +Game 3: 8 green, 6 blue, 20 red; 5 blue, 4 red, 13 green; 5 green, 1 red +Game 4: 1 green, 3 red, 6 blue; 3 green, 6 red; 3 green, 15 blue, 14 red +Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green +#+end_example + +Say now that we learn that the bag has only 12 red cubes, 13 green cubes, and 14 blue cubes? + +Some of the games above are impossible. Count the sum of the game IDs of games that /are/ possible. + +*** Method + +Originally, this part of the problem looked challenging. But, we really only need to keep a record of the minimum number of cubes of each color for each game to be valid, like so: + +#+begin_example +Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green ;; 6 blue, 4 red, 2 green +Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue ;; 4 blue, 1 red, 3 green +Game 3: 8 green, 6 blue, 20 red; 5 blue, 4 red, 13 green; 5 green, 1 red ;; 6 blue, 20 red, 13 green +#+end_example + +Then simply compare these numbers with the cubes we were presented, and determine which games were possible. I cannot think of any other way to complete this problem. + +So, it seems, the hardest difficulty is... parsing the above input string! + +** Part 2 + +Part two asks us to multiple the minimum number of each cubes required in each game and add them all up. This is very easy, given the work already done! We'll just add this output to the main function. |