Use a common main
This commit is contained in:
@@ -46,9 +46,10 @@ TEST_SUITE("2017-01 examples") {
|
||||
}
|
||||
}
|
||||
|
||||
auto main(int argc, char** argv) -> int {
|
||||
auto Main(std::istream & in) -> void
|
||||
{
|
||||
std::string input;
|
||||
std::getline(*aocpp::Startup(argc, argv), input);
|
||||
std::getline(in, input);
|
||||
std::cout << "Part 1: " << Part1(input) << std::endl;
|
||||
std::cout << "Part 2: " << Part2(input) << std::endl;
|
||||
}
|
||||
|
@@ -66,10 +66,9 @@ TEST_SUITE("2017-02 examples") {
|
||||
}
|
||||
}
|
||||
|
||||
auto main(int argc, char** argv) -> int {
|
||||
auto in_ptr = aocpp::Startup(argc, argv);
|
||||
auto & in = *in_ptr;
|
||||
auto [p1,p2] = Omnibus(in);
|
||||
auto Main(std::istream & in) -> void
|
||||
{
|
||||
auto const [p1,p2] = Omnibus(in);
|
||||
std::cout << "Part 1: " << p1 << std::endl;
|
||||
std::cout << "Part 2: " << p2 << std::endl;
|
||||
}
|
||||
|
@@ -57,8 +57,9 @@ TEST_SUITE("2017-05 examples") {
|
||||
}
|
||||
}
|
||||
|
||||
auto main(int argc, char** argv) -> int {
|
||||
auto input = Parse(*aocpp::Startup(argc, argv));
|
||||
auto Main(std::istream & in) -> void
|
||||
{
|
||||
auto input {Parse(in)};
|
||||
std::cout << "Part 1: " << Run1(input) << std::endl;
|
||||
std::cout << "Part 2: " << Run2(std::move(input)) << std::endl;
|
||||
}
|
||||
|
@@ -80,9 +80,10 @@ TEST_SUITE("2017-06 examples") {
|
||||
}
|
||||
}
|
||||
|
||||
auto main(int argc, char** argv) -> int {
|
||||
auto input = Parse(*aocpp::Startup(argc, argv));
|
||||
auto answer = CycleSearch(input);
|
||||
auto Main(std::istream & in) -> void
|
||||
{
|
||||
auto input {Parse(in)};
|
||||
auto const answer = CycleSearch(input);
|
||||
std::cout << "Part 1: " << answer.first << std::endl;
|
||||
std::cout << "Part 2: " << answer.second << std::endl;
|
||||
}
|
||||
|
@@ -9,9 +9,10 @@
|
||||
#include <aocpp/Parsing.hpp>
|
||||
#include <knothash.hpp>
|
||||
|
||||
auto main(int argc, char** argv) -> int {
|
||||
auto Main(std::istream & in) -> void
|
||||
{
|
||||
std::string line;
|
||||
std::getline(*aocpp::Startup(argc, argv), line);
|
||||
std::getline(in, line);
|
||||
|
||||
std::vector<std::uint8_t> lengths1;
|
||||
for (auto && x : aocpp::SplitOn(line, ",")) {
|
||||
@@ -22,4 +23,4 @@ auto main(int argc, char** argv) -> int {
|
||||
std::cout << "Part 1: " << long{result[0]} * long{result[1]} << std::endl;
|
||||
|
||||
std::cout << "Part 2: " << knothash::render(knothash::hash(line)) << std::endl;
|
||||
}
|
||||
}
|
||||
|
@@ -60,10 +60,11 @@ TEST_SUITE("2017-11 examples") {
|
||||
}
|
||||
}
|
||||
|
||||
auto main(int argc, char** argv) -> int {
|
||||
auto Main(std::istream & in) -> void
|
||||
{
|
||||
std::string line;
|
||||
std::getline(*Startup(argc, argv), line);
|
||||
auto [part1, part2] = Walk(line);
|
||||
std::getline(in, line);
|
||||
auto const [part1, part2] = Walk(line);
|
||||
std::cout << "Part 1: " << part1 << std::endl;
|
||||
std::cout << "Part 2: " << part2 << std::endl;
|
||||
}
|
||||
}
|
||||
|
@@ -101,9 +101,10 @@ TEST_SUITE("2017-12 examples") {
|
||||
}
|
||||
}
|
||||
|
||||
auto main(int argc, char** argv) -> int {
|
||||
auto input = Parse(*Startup(argc, argv));
|
||||
auto [part1, part2] = LinkNodes(input);
|
||||
auto Main(std::istream & in) -> void
|
||||
{
|
||||
auto const input {Parse(in)};
|
||||
auto const [part1, part2] = LinkNodes(input);
|
||||
std::cout << "Part 1: " << part1 << std::endl;
|
||||
std::cout << "Part 2: " << part2 << std::endl;
|
||||
}
|
||||
}
|
||||
|
11
2017/13.cpp
11
2017/13.cpp
@@ -40,7 +40,7 @@ auto Caught(std::vector<Scanner> const& scanners) -> std::size_t {
|
||||
return severity;
|
||||
}
|
||||
|
||||
auto Delay(std::vector<Scanner> & scanners) {
|
||||
auto Delay(std::vector<Scanner> scanners) {
|
||||
std::uint64_t delay = 0;
|
||||
|
||||
for (;;) {
|
||||
@@ -72,8 +72,9 @@ TEST_SUITE("2017-12 examples") {
|
||||
}
|
||||
}
|
||||
|
||||
auto main(int argc, char** argv) -> int {
|
||||
auto input = Parse(*Startup(argc, argv));
|
||||
auto Main(std::istream & in) -> void
|
||||
{
|
||||
auto input {Parse(in)};
|
||||
std::cout << "Part 1: " << Caught(input) << std::endl;
|
||||
std::cout << "Part 2: " << Delay(input) << std::endl;
|
||||
}
|
||||
std::cout << "Part 2: " << Delay(std::move(input)) << std::endl;
|
||||
}
|
||||
|
@@ -94,10 +94,11 @@ TEST_CASE("flqrgnkx") {
|
||||
}
|
||||
}
|
||||
|
||||
auto main(int argc, char** argv) -> int {
|
||||
auto Main(std::istream & in) -> void
|
||||
{
|
||||
std::string input;
|
||||
std::getline(*aocpp::Startup(argc, argv), input);
|
||||
auto rows = MakeRows(std::move(input));
|
||||
std::getline(in, input);
|
||||
auto const rows {MakeRows(std::move(input))};
|
||||
std::cout << "Part 1: " << CountBits(rows) << std::endl;
|
||||
std::cout << "Part 2: " << CountComponents(rows) << std::endl;
|
||||
}
|
||||
}
|
||||
|
@@ -59,9 +59,10 @@ TEST_SUITE("2017-17 examples") {
|
||||
}
|
||||
}
|
||||
|
||||
auto main(int argc, char** argv) -> int {
|
||||
auto Main(std::istream & in) -> void
|
||||
{
|
||||
int steps;
|
||||
*Startup(argc, argv) >> steps;
|
||||
in >> steps;
|
||||
std::cout << "Part 1: " << Part1(steps, 2017) << std::endl;
|
||||
std::cout << "Part 2: " << Part2(steps, 50'000'000) << std::endl;
|
||||
}
|
||||
}
|
||||
|
@@ -237,8 +237,9 @@ TEST_SUITE("documented examples") {
|
||||
}
|
||||
}
|
||||
|
||||
auto main(int argc, char** argv) -> int {
|
||||
auto const program = Parse(*aocpp::Startup(argc, argv));
|
||||
auto Main(std::istream & in) -> void
|
||||
{
|
||||
auto const program {Parse(in)};
|
||||
std::cout << "Part 1: " << Part1(program) << std::endl;
|
||||
std::cout << "Part 2: " << Part2(program) << std::endl;
|
||||
}
|
||||
|
@@ -65,15 +65,15 @@ TEST_SUITE("2017-19 examples") {
|
||||
" +B-+ +--+ \n"
|
||||
" \n"
|
||||
};
|
||||
auto [p1,p2] = Drive(Grid::Parse(in));
|
||||
auto const [p1, p2] = Drive(Grid::Parse(in));
|
||||
CHECK(p1 == "ABCDEF");
|
||||
CHECK(p2 == 38);
|
||||
}
|
||||
}
|
||||
|
||||
auto main(int argc, char** argv) -> int {
|
||||
auto input = Grid::Parse(*aocpp::Startup(argc, argv));
|
||||
auto [part1, part2] = Drive(input);
|
||||
auto Main(std::istream & in) -> void
|
||||
{
|
||||
auto const [part1, part2] = Drive(Grid::Parse(in));
|
||||
std::cout << "Part 1: " << part1 << std::endl;
|
||||
std::cout << "Part 2: " << part2 << std::endl;
|
||||
}
|
||||
|
Reference in New Issue
Block a user