blob: 2cebc3c67db9751fd45e0e7eae7ed006a05e4d7b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#include "aoc.h"
#include <algorithm>
namespace aoc2022 {
std::pair<int, int> day12(line_view file) {
int row{0};
heightmap hm;
per_line(file, [&hm, &row](line_view lv){
hm.load(row++, lv);
return true;
});
hm.flood(hm.start);
int a1 = hm.was(hm.end);
hm.reset();
// hm.print();
int a2{INT32_MAX};
hm.flood_down(hm.end, &a2);
return {a1, a2};
}
}
|