aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/2015/day20/README.md4
-rw-r--r--src/2015/day21/README.md48
-rw-r--r--src/2015/day21/aoc.cpp5
-rw-r--r--src/2015/day21/aoc.h6
-rw-r--r--src/2015/day21/input3
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--test/test_2015.cpp5
7 files changed, 72 insertions, 0 deletions
diff --git a/src/2015/day20/README.md b/src/2015/day20/README.md
index 04496e6..b5e78ad 100644
--- a/src/2015/day20/README.md
+++ b/src/2015/day20/README.md
@@ -25,3 +25,7 @@ What is the lowest house number of the house to get at least as many presents as
Your puzzle input is 36000000.
+--- Part Two ---
+The Elves decide they don't want to visit an infinite number of houses. Instead, each Elf will stop after delivering presents to 50 houses. To make up for it, they decide to deliver presents equal to eleven times their number at each house.
+
+With these changes, what is the new lowest house number of the house to get at least as many presents as the number in your puzzle input?
diff --git a/src/2015/day21/README.md b/src/2015/day21/README.md
new file mode 100644
index 0000000..1dcddcb
--- /dev/null
+++ b/src/2015/day21/README.md
@@ -0,0 +1,48 @@
+--- Day 21: RPG Simulator 20XX ---
+Little Henry Case got a new video game for Christmas. It's an RPG, and he's stuck on a boss. He needs to know what equipment to buy at the shop. He hands you the controller.
+
+In this game, the player (you) and the enemy (the boss) take turns attacking. The player always goes first. Each attack reduces the opponent's hit points by at least 1. The first character at or below 0 hit points loses.
+
+Damage dealt by an attacker each turn is equal to the attacker's damage score minus the defender's armor score. An attacker always does at least 1 damage. So, if the attacker has a damage score of 8, and the defender has an armor score of 3, the defender loses 5 hit points. If the defender had an armor score of 300, the defender would still lose 1 hit point.
+
+Your damage score and armor score both start at zero. They can be increased by buying items in exchange for gold. You start with no items and have as much gold as you need. Your total damage or armor is equal to the sum of those stats from all of your items. You have 100 hit points.
+
+Here is what the item shop is selling:
+
+Weapons: Cost Damage Armor
+Dagger 8 4 0
+Shortsword 10 5 0
+Warhammer 25 6 0
+Longsword 40 7 0
+Greataxe 74 8 0
+
+Armor: Cost Damage Armor
+Leather 13 0 1
+Chainmail 31 0 2
+Splintmail 53 0 3
+Bandedmail 75 0 4
+Platemail 102 0 5
+
+Rings: Cost Damage Armor
+Damage +1 25 1 0
+Damage +2 50 2 0
+Damage +3 100 3 0
+Defense +1 20 0 1
+Defense +2 40 0 2
+Defense +3 80 0 3
+You must buy exactly one weapon; no dual-wielding. Armor is optional, but you can't use more than one. You can buy 0-2 rings (at most one for each hand). You must use any items you buy. The shop only has one of each item, so you can't buy, for example, two rings of Damage +3.
+
+For example, suppose you have 8 hit points, 5 damage, and 5 armor, and that the boss has 12 hit points, 7 damage, and 2 armor:
+
+The player deals 5-2 = 3 damage; the boss goes down to 9 hit points.
+The boss deals 7-5 = 2 damage; the player goes down to 6 hit points.
+The player deals 5-2 = 3 damage; the boss goes down to 6 hit points.
+The boss deals 7-5 = 2 damage; the player goes down to 4 hit points.
+The player deals 5-2 = 3 damage; the boss goes down to 3 hit points.
+The boss deals 7-5 = 2 damage; the player goes down to 2 hit points.
+The player deals 5-2 = 3 damage; the boss goes down to 0 hit points.
+In this scenario, the player wins! (Barely.)
+
+You have 100 hit points. The boss's actual stats are in your puzzle input. What is the least amount of gold you can spend and still win the fight?
+
+
diff --git a/src/2015/day21/aoc.cpp b/src/2015/day21/aoc.cpp
new file mode 100644
index 0000000..1c33c66
--- /dev/null
+++ b/src/2015/day21/aoc.cpp
@@ -0,0 +1,5 @@
+#include "aoc.h"
+
+namespace aoc2015 {
+
+}
diff --git a/src/2015/day21/aoc.h b/src/2015/day21/aoc.h
new file mode 100644
index 0000000..c439c03
--- /dev/null
+++ b/src/2015/day21/aoc.h
@@ -0,0 +1,6 @@
+#pragma once
+#include "common.h"
+
+namespace aoc2015 {
+
+}
diff --git a/src/2015/day21/input b/src/2015/day21/input
new file mode 100644
index 0000000..db43742
--- /dev/null
+++ b/src/2015/day21/input
@@ -0,0 +1,3 @@
+Hit Points: 100
+Damage: 8
+Armor: 2
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 57b55a0..84cc9d5 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -20,6 +20,7 @@ set(SOLUTION_FILES
"2015/day18/aoc.cpp"
"2015/day19/aoc.cpp"
"2015/day20/aoc.cpp"
+ "2015/day21/aoc.cpp"
)
add_library(solution SHARED ${SOLUTION_FILES})
diff --git a/test/test_2015.cpp b/test/test_2015.cpp
index 4253db4..4fa831a 100644
--- a/test/test_2015.cpp
+++ b/test/test_2015.cpp
@@ -11,6 +11,7 @@
#include "2015/day19/aoc.h"
#include "2015/day2/aoc.h"
#include "2015/day20/aoc.h"
+#include "2015/day21/aoc.h"
#include "2015/day3/aoc.h"
#include "2015/day4/aoc.h"
#include "2015/day5/aoc.h"
@@ -214,3 +215,7 @@ TEST_CASE("Infinite Elves and Infinite Houses", "[day20]") {
REQUIRE(831600 == p.first);
REQUIRE(884520 == p.second);
}
+
+TEST_CASE("RPG Simulator 20XX", "[day21]") {
+ // line_view lv = load_file("../src/2015/day21/input");
+}