1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#include "aoc.h"
#include <vector>
namespace aoc2015 {
static spell bosskill = {0, 1, 8, 0, 0, 0, 0};
static spell spells[5] = {
{53, 1, 4, 0, 0, 0, 0},
{73, 1, 2, 2, 0, 0, 0},
{113, 6, 0, 0, 0, 7, 0},
{173, 6, 3, 0, 0, 0, 0},
{229, 5, 0, 0, 101, 0, 0},
};
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.wp = &boss;
boss.wp = &me;
me.spells[0] = &bosskill;
for (int i = 0; i < 5; i++) {
boss.spells[i] = spells + i;
}
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};
}
}
|