more tests
This commit is contained in:
parent
234217e6cc
commit
9601c42fc5
144
2019/20.cpp
144
2019/20.cpp
|
@ -1,19 +1,22 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <bitset>
|
||||||
|
#include <cctype>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <iostream>
|
|
||||||
#include <iomanip>
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <iomanip>
|
||||||
|
#include <iostream>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <stdexcept>
|
#include <map>
|
||||||
#include <vector>
|
#include <queue>
|
||||||
|
#include <queue>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <sstream>
|
||||||
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <bitset>
|
#include <vector>
|
||||||
#include <queue>
|
|
||||||
#include <cctype>
|
#include <doctest.h>
|
||||||
#include <queue>
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
#include <aocpp/Startup.hpp>
|
#include <aocpp/Startup.hpp>
|
||||||
#include <aocpp/Coord.hpp>
|
#include <aocpp/Coord.hpp>
|
||||||
|
@ -149,6 +152,129 @@ auto SolveMaze(Distances const& distances, bool const recursive) -> std::int64_t
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
TEST_SUITE("2019-20 examples") {
|
||||||
|
TEST_CASE("part 1 a") {
|
||||||
|
std::istringstream in {
|
||||||
|
" A \n"
|
||||||
|
" A \n"
|
||||||
|
" #######.######### \n"
|
||||||
|
" #######.........# \n"
|
||||||
|
" #######.#######.# \n"
|
||||||
|
" #######.#######.# \n"
|
||||||
|
" #######.#######.# \n"
|
||||||
|
" ##### B ###.# \n"
|
||||||
|
"BC...## C ###.# \n"
|
||||||
|
" ##.## ###.# \n"
|
||||||
|
" ##...DE F ###.# \n"
|
||||||
|
" ##### G ###.# \n"
|
||||||
|
" #########.#####.# \n"
|
||||||
|
"DE..#######...###.# \n"
|
||||||
|
" #.#########.###.# \n"
|
||||||
|
"FG..#########.....# \n"
|
||||||
|
" ###########.##### \n"
|
||||||
|
" Z \n"
|
||||||
|
" Z \n"
|
||||||
|
};
|
||||||
|
auto map = Grid::Parse(in);
|
||||||
|
auto portals = FindPortals(map);
|
||||||
|
auto distances = FindDistances(map, portals);
|
||||||
|
CHECK(SolveMaze(distances, false) == 23);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("part 1") {
|
||||||
|
std::istringstream in {
|
||||||
|
" A \n"
|
||||||
|
" A \n"
|
||||||
|
" #################.############# \n"
|
||||||
|
" #.#...#...................#.#.# \n"
|
||||||
|
" #.#.#.###.###.###.#########.#.# \n"
|
||||||
|
" #.#.#.......#...#.....#.#.#...# \n"
|
||||||
|
" #.#########.###.#####.#.#.###.# \n"
|
||||||
|
" #.............#.#.....#.......# \n"
|
||||||
|
" ###.###########.###.#####.#.#.# \n"
|
||||||
|
" #.....# A C #.#.#.# \n"
|
||||||
|
" ####### S P #####.# \n"
|
||||||
|
" #.#...# #......VT\n"
|
||||||
|
" #.#.#.# #.##### \n"
|
||||||
|
" #...#.# YN....#.# \n"
|
||||||
|
" #.###.# #####.# \n"
|
||||||
|
"DI....#.# #.....# \n"
|
||||||
|
" #####.# #.###.# \n"
|
||||||
|
"ZZ......# QG....#..AS\n"
|
||||||
|
" ###.### ####### \n"
|
||||||
|
"JO..#.#.# #.....# \n"
|
||||||
|
" #.#.#.# ###.#.# \n"
|
||||||
|
" #...#..DI BU....#..LF\n"
|
||||||
|
" #####.# #.##### \n"
|
||||||
|
"YN......# VT..#....QG\n"
|
||||||
|
" #.###.# #.###.# \n"
|
||||||
|
" #.#...# #.....# \n"
|
||||||
|
" ###.### J L J #.#.### \n"
|
||||||
|
" #.....# O F P #.#...# \n"
|
||||||
|
" #.###.#####.#.#####.#####.###.# \n"
|
||||||
|
" #...#.#.#...#.....#.....#.#...# \n"
|
||||||
|
" #.#####.###.###.#.#.#########.# \n"
|
||||||
|
" #...#.#.....#...#.#.#.#.....#.# \n"
|
||||||
|
" #.###.#####.###.###.#.#.####### \n"
|
||||||
|
" #.#.........#...#.............# \n"
|
||||||
|
" #########.###.###.############# \n"
|
||||||
|
" B J C \n"
|
||||||
|
" U P P \n"
|
||||||
|
};
|
||||||
|
auto map = Grid::Parse(in);
|
||||||
|
auto portals = FindPortals(map);
|
||||||
|
auto distances = FindDistances(map, portals);
|
||||||
|
CHECK(SolveMaze(distances, false) == 58);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("part 2") {
|
||||||
|
std::istringstream in {
|
||||||
|
" Z L X W C \n"
|
||||||
|
" Z P Q B K \n"
|
||||||
|
" ###########.#.#.#.#######.############### \n"
|
||||||
|
" #...#.......#.#.......#.#.......#.#.#...# \n"
|
||||||
|
" ###.#.#.#.#.#.#.#.###.#.#.#######.#.#.### \n"
|
||||||
|
" #.#...#.#.#...#.#.#...#...#...#.#.......# \n"
|
||||||
|
" #.###.#######.###.###.#.###.###.#.####### \n"
|
||||||
|
" #...#.......#.#...#...#.............#...# \n"
|
||||||
|
" #.#########.#######.#.#######.#######.### \n"
|
||||||
|
" #...#.# F R I Z #.#.#.# \n"
|
||||||
|
" #.###.# D E C H #.#.#.# \n"
|
||||||
|
" #.#...# #...#.# \n"
|
||||||
|
" #.###.# #.###.# \n"
|
||||||
|
" #.#....OA WB..#.#..ZH\n"
|
||||||
|
" #.###.# #.#.#.# \n"
|
||||||
|
"CJ......# #.....# \n"
|
||||||
|
" ####### ####### \n"
|
||||||
|
" #.#....CK #......IC\n"
|
||||||
|
" #.###.# #.###.# \n"
|
||||||
|
" #.....# #...#.# \n"
|
||||||
|
" ###.### #.#.#.# \n"
|
||||||
|
"XF....#.# RF..#.#.# \n"
|
||||||
|
" #####.# ####### \n"
|
||||||
|
" #......CJ NM..#...# \n"
|
||||||
|
" ###.#.# #.###.# \n"
|
||||||
|
"RE....#.# #......RF\n"
|
||||||
|
" ###.### X X L #.#.#.# \n"
|
||||||
|
" #.....# F Q P #.#.#.# \n"
|
||||||
|
" ###.###########.###.#######.#########.### \n"
|
||||||
|
" #.....#...#.....#.......#...#.....#.#...# \n"
|
||||||
|
" #####.#.###.#######.#######.###.###.#.#.# \n"
|
||||||
|
" #.......#.......#.#.#.#.#...#...#...#.#.# \n"
|
||||||
|
" #####.###.#####.#.#.#.#.###.###.#.###.### \n"
|
||||||
|
" #.......#.....#.#...#...............#...# \n"
|
||||||
|
" #############.#.#.###.################### \n"
|
||||||
|
" A O F N \n"
|
||||||
|
" A A D M \n"
|
||||||
|
};
|
||||||
|
auto map = Grid::Parse(in);
|
||||||
|
auto portals = FindPortals(map);
|
||||||
|
auto distances = FindDistances(map, portals);
|
||||||
|
CHECK(SolveMaze(distances, true) == 396);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
auto main(int argc, char** argv) -> int {
|
auto main(int argc, char** argv) -> int {
|
||||||
auto map = Grid::Parse(*Startup(argc, argv));
|
auto map = Grid::Parse(*Startup(argc, argv));
|
||||||
auto portals = FindPortals(map);
|
auto portals = FindPortals(map);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user