Skip to content

Latest commit

 

History

History
59 lines (42 loc) · 3.1 KB

README.md

File metadata and controls

59 lines (42 loc) · 3.1 KB

Day 2 - Cube Conundrum

Part One: Possible Games - Original Puzzle

In this puzzle, you're presented with information about the cubes in a bag based on several games played. Each game has multiple rounds, the cubes are replaced after each round. A game is considered possible if it can be played with only the cubes contained in the bag, 12 red, 13 green, and 14 blue cubes. Otherwise, the game is impossible.

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 Game 1, three rounds of cubes are revealed:
- Round One - 3 blue and 4 red cubes
- Round Two - 1 red, 2 green, 6 blue cubes
- Round Three - 2 green cubes

Games 1, 2, and 5 - would have been possible
Game 3 - would have been impossible because one round had 20 red cubes
Game 4 - impossible because a round had 15 blue cubes

If you add up the IDs of the games that would have been possible, you get 8.

Your task is to determine which games would have been possible. What is the sum of the IDs of those games?

My Solution - Input Data

Part Two: Minimum Cube Sets - Original Puzzle

The minimum set of cubes is the fewest number of cubes of each color that could have been in the bag to make the game possible. The power of a set of cubes is the product of the number of red, green, and blue cubes.

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  

Game 1 - could have been played with as few as 4 red, 2 green, and 6 blue cubes. any fewer and the game would have been impossible.
Game 2 - minimum of 1 red, 3 green, and 4 blue cubes.
Game 3 - at least 20 red, 13 green, and 6 blue cubes.
Game 4 - required at least 14 red, 3 green, and 15 blue cubes.
Game 5 - needed 6 red, 3 green, and 2 blue cubes in the bag.

The power of the minimum set of cubes in Game 1 is 48.
In Games 2-5; 12, 1560, 630, and 36, respectively. The sum is 2286.

For each game, find the minimum set of cubes that must have been present. Calculate the sum of the powers of these sets.

My Solution - Input Data


< Back to all solutions