diff options
author | kaiwu <kaiwu2004@gmail.com> | 2022-12-12 23:38:22 +0800 |
---|---|---|
committer | kaiwu <kaiwu2004@gmail.com> | 2022-12-12 23:38:22 +0800 |
commit | 8579b920f5ae6bd14b795b92e8864e650e82b837 (patch) | |
tree | df463f76df4281db706357bf7dcd3749c5dfff71 /src/2022/day12/aoc.cpp | |
parent | 26c6c7f4d0df674b74434e05ea4965ba7ec8080a (diff) | |
download | advent-of-code-8579b920f5ae6bd14b795b92e8864e650e82b837.tar.gz advent-of-code-8579b920f5ae6bd14b795b92e8864e650e82b837.zip |
2022 day12 part1
Diffstat (limited to 'src/2022/day12/aoc.cpp')
-rw-r--r-- | src/2022/day12/aoc.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/2022/day12/aoc.cpp b/src/2022/day12/aoc.cpp index 76a2384..c0d1db5 100644 --- a/src/2022/day12/aoc.cpp +++ b/src/2022/day12/aoc.cpp @@ -1,9 +1,23 @@ #include "aoc.h" +#include <algorithm> namespace aoc2022 { std::pair<int, int> day12(line_view file) { - return {0, 0}; + int row{0}; + heightmap hm; + per_line(file, [&hm, &row](line_view lv){ + hm.load(row++, lv); + return true; + }); + + hm.print(); + std::vector<int> paths; + hm.was(hm.start) += 1; + hm.find(0, hm.start, paths); + + std::sort(paths.begin(), paths.end()); + return {paths[0], 0}; } } |