diff options
author | Kai WU <kaiwu2004@gmail.com> | 2022-03-27 23:03:54 +0800 |
---|---|---|
committer | Kai WU <kaiwu2004@gmail.com> | 2022-03-27 23:03:54 +0800 |
commit | ebc331c6c06a72cbf085793adbfd072b5ef547a9 (patch) | |
tree | 5b86943d59e515e3b3f3093b3e8e2962a2044af4 /src/2015/day21/aoc.cpp | |
parent | 2156cd51b55bad10d7397c9ebe8818c521a095fb (diff) | |
download | advent-of-code-ebc331c6c06a72cbf085793adbfd072b5ef547a9.tar.gz advent-of-code-ebc331c6c06a72cbf085793adbfd072b5ef547a9.zip |
backtrace 21
Diffstat (limited to 'src/2015/day21/aoc.cpp')
-rw-r--r-- | src/2015/day21/aoc.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/2015/day21/aoc.cpp b/src/2015/day21/aoc.cpp index 1c33c66..8c7e259 100644 --- a/src/2015/day21/aoc.cpp +++ b/src/2015/day21/aoc.cpp @@ -2,4 +2,22 @@ namespace aoc2015 { +int day21() { + Role me{100, 0, 0, 0}; + Role boss{100, 8, 2, 0}; + RPG game; + + int money{INT32_MAX}; + std::vector<Role> rs = game.shop(me); + std::for_each(rs.begin(), rs.end(), [&game, &boss, &money](Role& r) { + Role b = boss; + if (game.battle(r, b)) { + if (r.cost < money) { + money = r.cost; + } + } + }); + return money; } + +} // namespace aoc2015 |