2: Cube Conundrum

Day 2: Cube Conundrum #

Part 1 #

The Problem #

An elf presents you with a bag that holds red, green, and blue cubes. During each game, the elf will load the bag with some number of cubes. Then, he reaches in a grabs some gems as shows them to you, then places them back in the bag. He does this a few times per game.

The puzzle input details the count of each color of cube for each handful of gems, for each game. Each game is given an ID number.

Determine which games would be possible given that there are only 12 red cubes, 13 green cubes, and 14 blue cubes.

The answer is the sum of all possible game IDs.

For 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

In this example, only games 1,2, and 5 are possible games. Game 3 is impossible because you saw 20 red cubes at one time. Game 4 is impossible because you saw 15 blue cubes at once. Thus, the answer is 1+2+5 = 8.

What is the sum of the IDs of those games?

Because the elf returns each handful of cubes back into the bag, each handful is entirely independent of the others.

Solutions #

Part 2 #

The Problem #

What is the sum of the power of these sets?

Insights #

Solutions #