make output stream a Main parameter
This commit is contained in:
@@ -84,9 +84,9 @@ TEST_SUITE("2022-01 examples") {
|
||||
}
|
||||
}
|
||||
|
||||
auto Main(std::istream & in) -> void
|
||||
auto Main(std::istream & in, std::ostream & out) -> void
|
||||
{
|
||||
auto const [p1,p2] = Solve(Parse(in));
|
||||
std::cout << "Part 1: " << p1 << std::endl;
|
||||
std::cout << "Part 2: " << p2 << std::endl;
|
||||
out << "Part 1: " << p1 << std::endl;
|
||||
out << "Part 2: " << p2 << std::endl;
|
||||
}
|
||||
|
@@ -136,9 +136,9 @@ C Z
|
||||
}
|
||||
}
|
||||
|
||||
auto Main(std::istream & in) -> void
|
||||
auto Main(std::istream & in, std::ostream & out) -> void
|
||||
{
|
||||
auto const input {Parse(in)} ;
|
||||
std::cout << "Part 1: " << Part1(input) << std::endl;
|
||||
std::cout << "Part 2: " << Part2(input) << std::endl;
|
||||
out << "Part 1: " << Part1(input) << std::endl;
|
||||
out << "Part 2: " << Part2(input) << std::endl;
|
||||
}
|
||||
|
@@ -97,9 +97,9 @@ TEST_SUITE("2022-03 examples") {
|
||||
}
|
||||
}
|
||||
|
||||
auto Main(std::istream & in) -> void
|
||||
auto Main(std::istream & in, std::ostream & out) -> void
|
||||
{
|
||||
auto input {Parse(in)};
|
||||
std::cout << "Part 1: " << Part1(input) << std::endl;
|
||||
std::cout << "Part 2: " << Part2(input) << std::endl;
|
||||
out << "Part 1: " << Part1(input) << std::endl;
|
||||
out << "Part 2: " << Part2(input) << std::endl;
|
||||
}
|
||||
|
@@ -48,9 +48,9 @@ TEST_SUITE("2022-04 examples") {
|
||||
}
|
||||
}
|
||||
|
||||
auto Main(std::istream & in) -> void
|
||||
auto Main(std::istream & in, std::ostream & out) -> void
|
||||
{
|
||||
auto const [p1,p2] = Solve(in);
|
||||
std::cout << "Part 1: " << p1 << std::endl;
|
||||
std::cout << "Part 2: " << p2 << std::endl;
|
||||
out << "Part 1: " << p1 << std::endl;
|
||||
out << "Part 2: " << p2 << std::endl;
|
||||
}
|
||||
|
@@ -57,10 +57,10 @@ TEST_SUITE("2022-06 examples") {
|
||||
}
|
||||
}
|
||||
|
||||
auto Main(std::istream & in) -> void
|
||||
auto Main(std::istream & in, std::ostream & out) -> void
|
||||
{
|
||||
std::string input;
|
||||
std::getline(in, input);
|
||||
std::cout << "Part 1: " << Solve(input, 4) << std::endl;
|
||||
std::cout << "Part 2: " << Solve(input, 14) << std::endl;
|
||||
out << "Part 1: " << Solve(input, 4) << std::endl;
|
||||
out << "Part 2: " << Solve(input, 14) << std::endl;
|
||||
}
|
||||
|
@@ -71,9 +71,9 @@ TEST_SUITE("2022-08 examples") {
|
||||
}
|
||||
}
|
||||
|
||||
auto Main(std::istream & in) -> void
|
||||
auto Main(std::istream & in, std::ostream & out) -> void
|
||||
{
|
||||
auto const grid = Grid::Parse(in);
|
||||
std::cout << "Part 1: " << Part1(grid) << std::endl;
|
||||
std::cout << "Part 2: " << Part2(grid) << std::endl;
|
||||
out << "Part 1: " << Part1(grid) << std::endl;
|
||||
out << "Part 2: " << Part2(grid) << std::endl;
|
||||
}
|
||||
|
@@ -97,9 +97,9 @@ TEST_SUITE("2022-09 examples") {
|
||||
}
|
||||
}
|
||||
|
||||
auto Main(std::istream & in) -> void
|
||||
auto Main(std::istream & in, std::ostream & out) -> void
|
||||
{
|
||||
auto const [p1,p2] = Solve(in);
|
||||
std::cout << "Part 1: " << p1 << std::endl;
|
||||
std::cout << "Part 2: " << p2 << std::endl;
|
||||
out << "Part 1: " << p1 << std::endl;
|
||||
out << "Part 2: " << p2 << std::endl;
|
||||
}
|
||||
|
@@ -96,9 +96,9 @@ TEST_SUITE("2022-10 examples") {
|
||||
}
|
||||
}
|
||||
|
||||
auto Main(std::istream & in) -> void
|
||||
auto Main(std::istream & in, std::ostream & out) -> void
|
||||
{
|
||||
auto const snapshots {Execute(in)};
|
||||
std::cout << "Part 1: " << Part1(snapshots) << std::endl;
|
||||
Part2(snapshots, std::cout << "Part 2:\n");
|
||||
out << "Part 1: " << Part1(snapshots) << std::endl;
|
||||
Part2(snapshots, out << "Part 2:\n");
|
||||
}
|
||||
|
@@ -146,9 +146,9 @@ Monkey 3:
|
||||
}
|
||||
}
|
||||
|
||||
auto Main(std::istream & in) -> void
|
||||
auto Main(std::istream & in, std::ostream & out) -> void
|
||||
{
|
||||
auto const input {Parse(in)};
|
||||
std::cout << "Part 1: " << Part1(input) << std::endl;
|
||||
std::cout << "Part 2: " << Part2(input) << std::endl;
|
||||
out << "Part 1: " << Part1(input) << std::endl;
|
||||
out << "Part 2: " << Part2(input) << std::endl;
|
||||
}
|
||||
|
@@ -84,9 +84,9 @@ TEST_SUITE("2022-12 examples") {
|
||||
}
|
||||
}
|
||||
|
||||
auto Main(std::istream & in) -> void
|
||||
auto Main(std::istream & in, std::ostream & out) -> void
|
||||
{
|
||||
auto const [start, end, grid] = Parse(in);
|
||||
std::cout << "Part 1: " << Solve({start}, end, grid) << std::endl;
|
||||
std::cout << "Part 2: " << Solve(Part2Starts(grid), end, grid) << std::endl;
|
||||
out << "Part 1: " << Solve({start}, end, grid) << std::endl;
|
||||
out << "Part 2: " << Solve(Part2Starts(grid), end, grid) << std::endl;
|
||||
}
|
||||
|
@@ -140,10 +140,10 @@ TEST_SUITE("2022-13 examples") {
|
||||
}
|
||||
}
|
||||
|
||||
auto Main(std::istream & in) -> void
|
||||
auto Main(std::istream & in, std::ostream & out) -> void
|
||||
{
|
||||
auto input = Parse(in);
|
||||
std::cout << "count " << input.size() << std::endl;
|
||||
std::cout << "Part 1: " << Part1(input) << std::endl;
|
||||
std::cout << "Part 2: " << Part2(std::move(input)) << std::endl;
|
||||
out << "count " << input.size() << std::endl;
|
||||
out << "Part 1: " << Part1(input) << std::endl;
|
||||
out << "Part 2: " << Part2(std::move(input)) << std::endl;
|
||||
}
|
||||
|
@@ -334,12 +334,12 @@ Valve JJ has flow rate=21; tunnel leads to valve II
|
||||
|
||||
/// @brief Print solutions to parts 1 and 2
|
||||
/// @param in selected input stream
|
||||
auto Main(std::istream & in) -> void
|
||||
auto Main(std::istream & in, std::ostream & out) -> void
|
||||
{
|
||||
auto rooms = Parse(in);
|
||||
auto const n = FlowsFirst(rooms);
|
||||
auto const [start, distances] = GenerateDistances(rooms);
|
||||
rooms.resize(n);
|
||||
std::cout << "Part 1: " << Part1(start, rooms, distances) << std::endl;
|
||||
std::cout << "Part 2: " << Part2(start, rooms, distances) << std::endl;
|
||||
out << "Part 1: " << Part1(start, rooms, distances) << std::endl;
|
||||
out << "Part 2: " << Part2(start, rooms, distances) << std::endl;
|
||||
}
|
||||
|
@@ -96,9 +96,9 @@ TEST_SUITE("2022-12 examples") {
|
||||
}
|
||||
}
|
||||
|
||||
auto Main(std::istream & in) -> void
|
||||
auto Main(std::istream & in, std::ostream & out) -> void
|
||||
{
|
||||
auto const obj {Parse(in)};
|
||||
std::cout << "Part 1: " << Part1(obj) << std::endl;
|
||||
std::cout << "Part 2: " << Part2(obj) << std::endl;
|
||||
out << "Part 1: " << Part1(obj) << std::endl;
|
||||
out << "Part 2: " << Part2(obj) << std::endl;
|
||||
}
|
||||
|
@@ -108,9 +108,9 @@ TEST_SUITE("2022-20 examples") {
|
||||
}
|
||||
}
|
||||
|
||||
auto Main(std::istream & in) -> void
|
||||
auto Main(std::istream & in, std::ostream & out) -> void
|
||||
{
|
||||
auto input {Parse(in)};
|
||||
std::cout << "Part 1: " << Part1(input) << std::endl;
|
||||
std::cout << "Part 2: " << Part2(std::move(input)) << std::endl;
|
||||
out << "Part 1: " << Part1(input) << std::endl;
|
||||
out << "Part 2: " << Part2(std::move(input)) << std::endl;
|
||||
}
|
||||
|
@@ -87,7 +87,7 @@ TEST_SUITE("2022-25 examples") {
|
||||
}
|
||||
}
|
||||
|
||||
auto Main(std::istream & in) -> void
|
||||
auto Main(std::istream & in, std::ostream & out) -> void
|
||||
{
|
||||
std::cout << "Part 1: " << Solve(in) << std::endl;
|
||||
out << "Part 1: " << Solve(in) << std::endl;
|
||||
}
|
||||
|
Reference in New Issue
Block a user