aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/2015/day22/aoc.cpp35
-rw-r--r--src/2015/day22/aoc.h1
2 files changed, 33 insertions, 3 deletions
diff --git a/src/2015/day22/aoc.cpp b/src/2015/day22/aoc.cpp
index 1e6ae41..e9aa969 100644
--- a/src/2015/day22/aoc.cpp
+++ b/src/2015/day22/aoc.cpp
@@ -1,4 +1,5 @@
#include "aoc.h"
+#include <vector>
namespace aoc2015 {
@@ -11,14 +12,42 @@ static spell spells[5] = {
{229, 5, 0, 0, 101, 0, 0},
};
-bool effects(wizard&);
+void effects(wizard& w) {
+ for (int i = 0; i < 5; i++) {
+ spell* s = w.spells[i];
+ if (s != nullptr && s->tick > 0) {
+ w.points -= s->damage;
+ w.wp->points += s->heals;
+ w.wp->mana += s->payback;
+ w.wp->armor += s->protect;
+ s->tick -= 1;
+ }
+ }
+}
+
+void fight(int turn, wizard& me, wizard& boss, int* cost, std::vector<int>& costs) {
+ // wizard* w = turn % 2 == 1 ? &me : &boss;
+}
std::pair<int, int> day22(wizard me, wizard boss) {
- me.spells[0] = & bosskill;
+ me.wp = &boss;
+ boss.wp = &me;
+ me.spells[0] = &bosskill;
for (int i = 0; i < 5; i++) {
boss.spells[i] = spells + i;
}
- return {0, 0};
+ int cost{0};
+ std::vector<int> costs;
+ fight(1, me, boss, &cost, costs);
+
+ int min{INT32_MAX};
+ for(auto& c : costs) {
+ if (c < min) {
+ min = c;
+ }
+ }
+
+ return {min, 0};
}
}
diff --git a/src/2015/day22/aoc.h b/src/2015/day22/aoc.h
index 1c53c20..8596f55 100644
--- a/src/2015/day22/aoc.h
+++ b/src/2015/day22/aoc.h
@@ -8,6 +8,7 @@ struct wizard {
int points;
int armor;
int mana;
+ wizard* wp = nullptr;
spell* spells[5] = {nullptr, nullptr, nullptr, nullptr, nullptr};
};