diff --git a/.clang-format b/.clang-format
index b8bcb7e..5de6fa0 100644
--- a/.clang-format
+++ b/.clang-format
@@ -3,14 +3,18 @@ Language: Cpp
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
+AlignOperands: DontAlign
AllowAllArgumentsOnNextLine: false
+#AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortFunctionsOnASingleLine: false
+#BinPackArguments: true
+#BinPackParameters: true
BreakBeforeBraces: Allman
BreakBeforeConceptDeclarations: Always
BreakBeforeTernaryOperators: true
BreakInheritanceList: BeforeColon
-ColumnLimit: 100
+ColumnLimit: 120
Cpp11BracedListStyle: false
EmptyLineBeforeAccessModifier: Never
FixNamespaceComments: false
@@ -39,4 +43,5 @@ SpaceBeforeCaseColon: true
SpaceBeforeParens: ControlStatements
# Deprecated
+#AllowAllConstructorInitializersOnNextLine: true
AlwaysBreakTemplateDeclarations: true
diff --git a/include/aoc/GridPathData.hpp b/include/aoc/GridPathData.hpp
new file mode 100644
index 0000000..274e6d9
--- /dev/null
+++ b/include/aoc/GridPathData.hpp
@@ -0,0 +1,25 @@
+// Solutions to the Advent Of Code 2024.
+// Copyright (C) 2024 Stefan Müller
+//
+// This program is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free Software
+// Foundation, either version 3 of the License, or (at your option) any later
+// version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program. If not, see .
+
+#pragma once
+
+#include
+
+class GridPathData
+{
+public:
+ bool isVisited{ false };
+ std::bitset<4> isLoopingInDirection{ 0 };
+};
diff --git a/include/aoc/GuardGallivant.hpp b/include/aoc/GuardGallivant.hpp
index fdd8110..b5520aa 100644
--- a/include/aoc/GuardGallivant.hpp
+++ b/include/aoc/GuardGallivant.hpp
@@ -15,7 +15,12 @@
#pragma once
+#include
+
+#include
+#include
#include
+#include
class GuardGallivant
: public LinesSolver
@@ -29,8 +34,12 @@ class GuardGallivant
Point2 start_{};
const size_t getStartDirectionIndex() const;
const char getStartChar() const;
- const char getVisitedChar() const;
const char getObstructionChar() const;
- void visitPosition(const Point2& current);
- size_t turnDirection(const size_t current) const;
+ void tracePath();
+ void visitPosition(const Point2& current, const size_t directionIndex, Grid& pathGrid);
+ void backtracePath(const Point2& current, const size_t directionIndex, Grid& pathGrid);
+ void backtraceTurn(const Point2& current, const size_t reverseTurnDirectionIndex, Grid& pathGrid);
+ size_t turnDirectionRight(const size_t currentDirectionIndex) const;
+ size_t turnDirectionLeft(const size_t currentDirectionIndex) const;
+ size_t revertDirection(const size_t currentDirectionIndex) const;
};
diff --git a/include/aoc/Point2.hpp b/include/aoc/Point2.hpp
index 45e06c4..77b421b 100644
--- a/include/aoc/Point2.hpp
+++ b/include/aoc/Point2.hpp
@@ -15,6 +15,8 @@
#pragma once
+#include
+
class Point2
{
public:
@@ -42,3 +44,5 @@ class Point2
Point2& operator-=(const Point2& rhs);
Point2& operator*=(const int rhs);
};
+
+std::ostream& operator<<(std::ostream& os, const Point2& rhs);
diff --git a/src/GuardGallivant.cpp b/src/GuardGallivant.cpp
index d8bbbb9..06e2ec2 100644
--- a/src/GuardGallivant.cpp
+++ b/src/GuardGallivant.cpp
@@ -15,6 +15,12 @@
#include
+#include
+#include
+#include
+#include
+#include
+
const std::string GuardGallivant::getPuzzleName() const
{
return "Day 6: Guard Gallivant";
@@ -27,33 +33,45 @@ const std::string GuardGallivant::getInputFileName() const
void GuardGallivant::processDataLine(const std::string& line)
{
- LinesSolver::processDataLine(line);
- auto pos{ line.find(getStartChar()) };
+ auto pos = line.find(getStartChar());
if (pos != std::string::npos)
{
- start_ = Point2{ static_cast(pos), static_cast(lines.size() - 1) };
+ start_ = Point2{ static_cast(pos), static_cast(lines.size()) };
}
+
+ LinesSolver::processDataLine(line);
}
void GuardGallivant::finish()
{
- auto dirIndex{ getStartDirectionIndex() };
- auto current{ start_ };
- visitPosition(current);
- auto next{ current + Point2::cardinalDirections[dirIndex] };
- while (isInBounds(next))
- {
- if (getPosition(next) == getObstructionChar())
- {
- dirIndex = turnDirection(dirIndex);
- }
- else
- {
- current = next;
- visitPosition(current);
- }
- next = current + Point2::cardinalDirections[dirIndex];
- }
+ tracePath();
+
+ //std::vector copy{ options_ };
+ //std::vector loops;
+ //auto part1Copy = part1;
+ //part2 = 0;
+ //for (size_t i = 0; i < copy.size(); i++)
+ //{
+ // std::cout << std::setw(5) << i << "/" << part1Copy - 1 << " (" << copy[i].x << "," << copy[i].y << ")";
+ // setPosition(copy[i], getObstructionChar());
+ // if (tracePath())
+ // {
+ // std::cout << " loops, " << ++part2;
+ // loops.push_back(copy[i]);
+ // }
+ // setPosition(copy[i], '.');
+ // std::cout << std::endl;
+ //}
+ //part1 = part1Copy;
+
+ //std::cout << std::endl << "LOOPS" << std::endl;
+ //// std::vector loops{ { 0, 0 }, { 3, 3 } };
+ //std::cout << "std::vector loops{";
+ //for (auto loop : loops)
+ //{
+ // std::cout << " { " << loop.x << ", " << loop.y << " },";
+ //}
+ //std::cout << " };" << std::endl;
}
const size_t GuardGallivant::getStartDirectionIndex() const
@@ -66,26 +84,150 @@ const char GuardGallivant::getStartChar() const
return '^';
}
-const char GuardGallivant::getVisitedChar() const
-{
- return 'X';
-}
-
const char GuardGallivant::getObstructionChar() const
{
return '#';
}
-void GuardGallivant::visitPosition(const Point2& current)
+void GuardGallivant::tracePath()
{
- if (getPosition(current) != getVisitedChar())
+ std::vector loopingSolutions{ { 73, 74 }, { 73, 70 }, { 77, 47 }, { 82, 47 }, { 97, 47 }, { 98, 52 }, { 98, 54 }, { 98, 55 }, { 98, 78 }, { 98, 84 }, { 96, 90 }, { 66, 90 }, { 64, 90 }, { 52, 89 }, { 52, 87 }, { 52, 80 }, { 52, 70 }, { 52, 67 }, { 52, 37 }, { 83, 36 }, { 88, 45 }, { 88, 46 }, { 88, 52 }, { 88, 54 }, { 88, 65 }, { 88, 84 }, { 88, 91 }, { 80, 109 }, { 66, 109 }, { 64, 109 }, { 54, 89 }, { 54, 80 }, { 54, 70 }, { 54, 67 }, { 69, 67 }, { 77, 67 }, { 81, 67 }, { 89, 67 }, { 94, 67 }, { 99, 67 }, { 100, 72 }, { 100, 73 }, { 100, 91 }, { 100, 97 }, { 100, 110 }, { 95, 109 }, { 95, 105 }, { 95, 103 }, { 95, 101 }, { 95, 92 }, { 95, 89 }, { 95, 84 }, { 95, 82 }, { 95, 78 }, { 95, 74 }, { 95, 66 }, { 95, 62 }, { 95, 49 }, { 95, 46 }, { 95, 41 }, { 95, 37 }, { 95, 30 }, { 98, 25 }, { 99, 25 }, { 100, 25 }, { 117, 35 }, { 117, 38 }, { 117, 42 }, { 117, 43 }, { 117, 45 }, { 117, 51 }, { 117, 52 }, { 117, 54 }, { 117, 61 }, { 117, 72 }, { 117, 78 }, { 96, 102 }, { 94, 102 }, { 80, 102 }, { 78, 102 }, { 74, 102 }, { 67, 102 }, { 66, 102 }, { 64, 102 }, { 55, 102 }, { 53, 102 }, { 48, 102 }, { 44, 101 }, { 44, 82 }, { 44, 80 }, { 44, 70 }, { 44, 66 }, { 44, 62 }, { 44, 60 }, { 75, 41 }, { 75, 44 }, { 75, 46 }, { 75, 49 }, { 75, 52 }, { 75, 54 }, { 72, 63 }, { 71, 63 }, { 70, 63 }, { 67, 63 }, { 66, 63 }, { 65, 63 }, { 63, 63 }, { 62, 63 }, { 55, 63 }, { 51, 63 }, { 45, 63 }, { 43, 63 }, { 35, 62 }, { 35, 38 }, { 35, 35 }, { 40, 24 }, { 47, 24 }, { 59, 24 }, { 76, 31 }, { 73, 31 }, { 72, 31 }, { 71, 31 }, { 70, 31 }, { 66, 31 }, { 65, 31 }, { 62, 31 }, { 58, 31 }, { 57, 31 }, { 53, 31 }, { 51, 31 }, { 48, 30 }, { 48, 26 }, { 48, 23 }, { 48, 22 }, { 68, 16 }, { 70, 16 }, { 75, 16 }, { 76, 16 }, { 77, 16 }, { 78, 16 }, { 79, 16 }, { 81, 16 }, { 83, 16 }, { 85, 16 }, { 88, 16 }, { 90, 16 }, { 92, 16 }, { 96, 16 }, { 98, 16 }, { 99, 16 }, { 100, 16 }, { 101, 17 }, { 101, 18 }, { 101, 22 }, { 101, 24 }, { 101, 28 }, { 101, 35 }, { 101, 38 }, { 101, 41 }, { 101, 42 }, { 101, 43 }, { 101, 44 }, { 101, 45 }, { 101, 46 }, { 101, 47 }, { 101, 51 }, { 101, 52 }, { 101, 53 }, { 101, 54 }, { 101, 55 }, { 97, 55 }, { 94, 55 }, { 93, 55 }, { 85, 55 }, { 80, 55 }, { 72, 55 }, { 71, 55 }, { 70, 55 }, { 66, 55 }, { 65, 55 }, { 62, 55 }, { 58, 55 }, { 53, 55 }, { 51, 55 }, { 50, 55 }, { 47, 55 }, { 45, 55 }, { 43, 55 }, { 42, 55 }, { 38, 48 }, { 38, 43 }, { 39, 43 }, { 40, 43 }, { 46, 43 }, { 48, 43 }, { 59, 43 }, { 65, 43 }, { 70, 45 }, { 70, 47 }, { 70, 49 }, { 70, 52 }, { 70, 53 }, { 70, 54 }, { 70, 56 }, { 70, 58 }, { 70, 59 }, { 70, 64 }, { 70, 68 }, { 70, 69 }, { 70, 70 }, { 70, 71 }, { 70, 73 }, { 70, 76 }, { 70, 78 }, { 70, 84 }, { 70, 89 }, { 70, 91 }, { 70, 96 }, { 70, 103 }, { 70, 104 }, { 66, 107 }, { 64, 107 }, { 58, 107 }, { 55, 107 }, { 53, 107 }, { 48, 107 }, { 43, 107 }, { 66, 105 }, { 69, 105 }, { 71, 105 }, { 89, 105 }, { 97, 105 }, { 101, 105 }, { 102, 105 }, { 108, 105 }, { 110, 105 }, { 112, 105 }, { 119, 105 }, { 119, 110 }, { 119, 115 }, { 104, 119 }, { 103, 119 }, { 101, 119 }, { 98, 119 }, { 88, 119 }, { 81, 119 }, { 80, 119 }, { 78, 119 }, { 74, 119 }, { 70, 119 }, { 66, 119 }, { 65, 119 }, { 61, 118 }, { 61, 108 }, { 61, 104 }, { 61, 101 }, { 61, 94 }, { 61, 89 }, { 61, 87 }, { 61, 82 }, { 61, 80 }, { 61, 74 }, { 61, 71 }, { 61, 70 }, { 61, 66 }, { 61, 64 }, { 61, 62 }, { 61, 60 }, { 61, 47 }, { 61, 46 }, { 61, 42 }, { 65, 41 }, { 71, 41 }, { 74, 41 }, { 76, 41 }, { 78, 41 }, { 79, 41 }, { 81, 41 }, { 82, 41 }, { 83, 41 }, { 83, 44 }, { 83, 45 }, { 83, 46 }, { 83, 52 }, { 83, 53 }, { 83, 54 }, { 83, 56 }, { 83, 59 }, { 83, 63 }, { 83, 64 }, { 83, 65 }, { 83, 68 }, { 83, 76 }, { 81, 76 }, { 80, 76 }, { 73, 76 }, { 72, 76 }, { 71, 76 }, { 68, 76 }, { 67, 76 }, { 66, 76 }, { 65, 76 }, { 63, 76 }, { 62, 76 }, { 60, 76 }, { 59, 76 }, { 58, 76 }, { 56, 76 }, { 55, 76 }, { 53, 76 }, { 51, 76 }, { 47, 75 }, { 47, 70 }, { 47, 67 }, { 47, 66 }, { 47, 62 }, { 47, 60 }, { 59, 49 }, { 64, 49 }, { 71, 49 }, { 76, 49 }, { 79, 49 }, { 81, 49 }, { 82, 49 }, { 84, 49 }, { 87, 49 }, { 89, 49 }, { 91, 49 }, { 94, 49 }, { 97, 49 }, { 99, 49 }, { 100, 49 }, { 102, 49 }, { 104, 49 }, { 108, 51 }, { 108, 52 }, { 108, 54 }, { 108, 59 }, { 108, 61 }, { 108, 63 }, { 108, 64 }, { 108, 65 }, { 108, 72 }, { 108, 78 }, { 108, 82 }, { 101, 84 }, { 97, 84 }, { 94, 84 }, { 81, 84 }, { 80, 84 }, { 72, 84 }, { 67, 84 }, { 66, 84 }, { 65, 84 }, { 60, 84 }, { 59, 84 }, { 58, 84 }, { 56, 84 }, { 55, 84 }, { 53, 84 }, { 51, 84 }, { 51, 82 }, { 51, 80 }, { 51, 75 }, { 51, 70 }, { 51, 67 }, { 51, 66 }, { 51, 62 }, { 51, 60 }, { 64, 54 }, { 66, 54 }, { 71, 54 }, { 76, 54 }, { 81, 54 }, { 82, 54 }, { 84, 54 }, { 87, 54 }, { 89, 54 }, { 91, 54 }, { 94, 54 }, { 97, 54 }, { 99, 54 }, { 100, 54 }, { 102, 54 }, { 102, 55 }, { 102, 56 }, { 102, 57 }, { 102, 59 }, { 102, 60 }, { 102, 61 }, { 102, 63 }, { 102, 64 }, { 102, 65 }, { 102, 68 }, { 102, 72 }, { 102, 73 }, { 102, 78 }, { 102, 82 }, { 102, 83 }, { 102, 85 }, { 102, 90 }, { 102, 91 }, { 102, 92 }, { 102, 94 }, { 102, 97 }, { 102, 103 }, { 102, 110 }, { 102, 111 }, { 101, 112 }, { 98, 112 }, { 94, 112 }, { 91, 112 }, { 88, 112 }, { 81, 112 }, { 80, 112 }, { 78, 112 }, { 74, 112 }, { 70, 112 }, { 66, 112 }, { 64, 112 }, { 64, 108 }, { 64, 104 }, { 64, 101 }, { 64, 99 }, { 64, 94 }, { 64, 89 }, { 64, 87 }, { 64, 82 }, { 64, 80 }, { 66, 80 }, { 69, 80 }, { 71, 80 }, { 77, 80 }, { 82, 80 }, { 86, 80 }, { 89, 80 }, { 94, 80 }, { 99, 80 }, { 101, 80 }, { 103, 80 }, { 103, 82 }, { 103, 83 }, { 103, 85 }, { 103, 90 }, { 103, 91 }, { 103, 92 }, { 101, 92 }, { 98, 92 }, { 96, 92 }, { 94, 92 }, { 81, 92 }, { 80, 92 }, { 67, 92 }, { 66, 92 }, { 63, 92 }, { 60, 92 }, { 59, 92 }, { 58, 92 }, { 55, 92 }, { 53, 92 }, { 51, 92 }, { 50, 92 }, { 48, 92 }, { 43, 92 }, { 42, 92 }, { 32, 92 }, { 29, 92 }, { 10, 79 }, { 20, 79 }, { 22, 79 }, { 27, 79 }, { 29, 82 }, { 29, 83 }, { 29, 85 }, { 29, 86 }, { 29, 87 }, { 29, 89 }, { 29, 90 }, { 29, 93 }, { 29, 103 }, { 28, 108 }, { 23, 108 }, { 19, 108 }, { 12, 103 }, { 12, 99 }, { 12, 98 }, { 12, 97 }, { 12, 93 }, { 12, 90 }, { 12, 87 }, { 12, 85 }, { 12, 84 }, { 12, 83 }, { 12, 78 }, { 12, 74 }, { 12, 72 }, { 12, 71 }, { 12, 68 }, { 12, 67 }, { 12, 63 }, { 12, 62 }, { 12, 60 }, { 12, 58 }, { 12, 55 }, { 12, 54 }, { 12, 52 }, { 12, 48 }, { 12, 42 }, { 12, 40 }, { 12, 39 }, { 12, 28 }, { 12, 27 }, { 12, 22 }, { 13, 22 }, { 23, 22 }, { 27, 22 }, { 40, 22 }, { 42, 22 }, { 47, 22 }, { 52, 26 }, { 52, 28 }, { 52, 29 }, { 47, 29 }, { 46, 29 }, { 42, 29 }, { 41, 29 }, { 34, 29 }, { 32, 29 }, { 30, 29 }, { 27, 29 }, { 25, 29 }, { 20, 29 }, { 18, 29 }, { 17, 29 }, { 14, 27 }, { 14, 21 }, { 14, 17 }, { 14, 14 }, { 16, 13 }, { 23, 13 }, { 27, 13 }, { 40, 13 }, { 42, 13 }, { 43, 13 }, { 47, 13 }, { 48, 13 }, { 49, 13 }, { 53, 13 }, { 64, 13 }, { 68, 13 }, { 70, 13 }, { 71, 13 }, { 72, 13 }, { 73, 13 }, { 74, 13 }, { 75, 13 }, { 76, 13 }, { 77, 13 }, { 78, 13 }, { 79, 13 }, { 81, 13 }, { 82, 13 }, { 83, 13 }, { 84, 13 }, { 85, 13 }, { 87, 13 }, { 89, 13 }, { 90, 13 }, { 92, 13 }, { 94, 15 }, { 94, 17 }, { 94, 18 }, { 94, 20 }, { 94, 22 }, { 94, 24 }, { 94, 25 }, { 94, 28 }, { 94, 32 }, { 94, 35 }, { 93, 36 }, { 92, 33 }, { 92, 30 }, { 92, 24 }, { 92, 23 }, { 92, 22 }, { 92, 15 }, { 92, 14 }, { 92, 12 }, { 95, 12 }, { 96, 12 }, { 97, 12 }, { 98, 12 }, { 99, 12 }, { 100, 12 }, { 102, 12 }, { 103, 12 }, { 107, 12 }, { 112, 12 }, { 112, 13 }, { 112, 18 }, { 112, 20 }, { 112, 22 }, { 112, 29 }, { 112, 35 }, { 112, 38 }, { 112, 42 }, { 112, 43 }, { 112, 44 }, { 112, 45 }, { 112, 46 }, { 105, 47 }, { 104, 47 }, { 104, 46 }, { 104, 42 }, { 104, 39 }, { 104, 38 }, { 104, 37 }, { 104, 33 }, { 104, 32 }, { 104, 26 }, { 104, 24 }, { 105, 17 }, { 107, 17 }, { 113, 17 }, { 118, 17 }, { 121, 17 }, { 122, 17 }, { 122, 18 }, { 122, 20 }, { 122, 22 }, { 122, 26 }, { 122, 29 }, { 122, 31 }, { 122, 34 }, { 122, 36 }, { 122, 37 }, { 122, 38 }, { 122, 42 }, { 122, 43 }, { 122, 45 }, { 122, 46 }, { 122, 51 }, { 122, 54 }, { 122, 57 }, { 122, 60 }, { 122, 61 }, { 122, 62 }, { 122, 63 }, { 122, 64 }, { 122, 66 }, { 122, 71 }, { 122, 78 }, { 114, 78 }, { 112, 78 }, { 111, 78 }, { 104, 78 }, { 103, 78 }, { 101, 78 }, { 97, 78 }, { 94, 78 }, { 93, 78 }, { 92, 78 }, { 91, 78 }, { 89, 78 }, { 85, 78 }, { 83, 78 }, { 81, 78 }, { 80, 78 }, { 75, 78 }, { 75, 75 }, { 75, 74 }, { 76, 73 }, { 77, 73 }, { 78, 73 }, { 82, 73 }, { 84, 73 }, { 85, 73 }, { 89, 73 }, { 93, 73 }, { 94, 73 }, { 99, 73 }, { 101, 73 }, { 103, 73 }, { 105, 73 }, { 107, 73 }, { 109, 73 }, { 109, 79 }, { 109, 81 }, { 109, 82 }, { 109, 83 }, { 109, 85 }, { 109, 86 }, { 109, 87 }, { 109, 90 }, { 109, 92 }, { 109, 93 }, { 109, 97 }, { 109, 99 }, { 108, 99 }, { 104, 99 }, { 101, 99 }, { 98, 99 }, { 96, 99 }, { 94, 99 }, { 91, 99 }, { 85, 99 }, { 80, 99 }, { 78, 99 }, { 74, 99 }, { 67, 99 }, { 66, 99 }, { 63, 99 }, { 60, 99 }, { 58, 99 }, { 55, 99 }, { 53, 99 }, { 52, 99 }, { 50, 99 }, { 48, 99 }, { 46, 99 }, { 45, 99 }, { 43, 99 }, { 42, 99 }, { 34, 99 }, { 32, 99 }, { 31, 99 }, { 31, 94 }, { 31, 93 }, { 31, 90 }, { 31, 87 }, { 31, 84 }, { 31, 83 }, { 31, 80 }, { 31, 79 }, { 31, 75 }, { 31, 73 }, { 31, 72 }, { 31, 71 }, { 31, 70 }, { 31, 68 }, { 31, 67 }, { 31, 66 }, { 31, 62 }, { 31, 60 }, { 31, 53 }, { 31, 48 }, { 34, 46 }, { 39, 46 }, { 40, 46 }, { 42, 46 }, { 46, 46 }, { 48, 46 }, { 59, 46 }, { 64, 46 }, { 64, 52 }, { 64, 53 }, { 64, 56 }, { 64, 58 }, { 64, 59 }, { 63, 59 }, { 62, 59 }, { 60, 59 }, { 59, 59 }, { 58, 59 }, { 55, 59 }, { 53, 59 }, { 50, 59 }, { 48, 59 }, { 46, 59 }, { 45, 59 }, { 43, 59 }, { 42, 59 }, { 37, 59 }, { 34, 59 }, { 32, 59 }, { 30, 59 }, { 29, 59 }, { 25, 59 }, { 21, 55 }, { 21, 54 }, { 21, 53 }, { 21, 52 }, { 21, 50 }, { 21, 48 }, { 21, 45 }, { 21, 43 }, { 21, 42 }, { 21, 40 }, { 21, 39 }, { 21, 37 }, { 21, 34 }, { 22, 33 }, { 23, 33 }, { 25, 33 }, { 30, 33 }, { 32, 33 }, { 33, 33 }, { 34, 33 }, { 38, 33 }, { 39, 33 }, { 40, 33 }, { 42, 33 }, { 45, 33 }, { 46, 33 }, { 47, 33 }, { 50, 35 }, { 50, 36 }, { 50, 37 }, { 50, 38 }, { 50, 40 }, { 50, 41 }, { 50, 45 }, { 50, 48 }, { 50, 52 }, { 50, 53 }, { 50, 56 }, { 50, 60 }, { 50, 61 }, { 50, 64 }, { 50, 68 }, { 50, 69 }, { 50, 70 }, { 50, 71 }, { 50, 77 }, { 50, 78 }, { 50, 80 }, { 48, 81 }, { 47, 81 }, { 46, 81 }, { 45, 81 }, { 43, 81 }, { 42, 81 }, { 38, 81 }, { 34, 81 }, { 33, 81 }, { 32, 81 }, { 30, 81 }, { 28, 81 }, { 27, 81 }, { 25, 81 }, { 20, 81 }, { 19, 80 }, { 19, 78 }, { 19, 76 }, { 19, 74 }, { 19, 72 }, { 19, 71 }, { 19, 68 }, { 19, 67 }, { 19, 66 }, { 19, 63 }, { 19, 62 }, { 19, 60 }, { 19, 59 }, { 19, 58 }, { 19, 55 }, { 19, 54 }, { 19, 53 }, { 19, 52 }, { 19, 50 }, { 19, 48 }, { 19, 45 }, { 20, 45 }, { 22, 45 }, { 23, 45 }, { 24, 45 }, { 25, 45 }, { 25, 49 }, { 25, 50 }, { 25, 52 }, { 25, 53 }, { 25, 54 }, { 25, 55 }, { 25, 56 }, { 25, 57 }, { 25, 60 }, { 25, 62 }, { 25, 63 }, { 25, 64 }, { 25, 65 }, { 25, 67 }, { 25, 68 }, { 25, 71 }, { 25, 75 }, { 25, 76 }, { 25, 77 }, { 25, 78 }, { 25, 82 }, { 25, 83 }, { 25, 84 }, { 25, 85 }, { 25, 86 }, { 25, 87 }, { 25, 89 }, { 25, 90 }, { 25, 93 }, { 25, 95 }, { 24, 96 }, { 22, 96 }, { 20, 96 }, { 19, 96 }, { 13, 96 }, { 11, 96 }, { 9, 96 }, { 7, 96 }, { 7, 95 }, { 7, 91 }, { 7, 90 }, { 7, 88 }, { 7, 87 }, { 7, 86 }, { 7, 85 }, { 7, 84 }, { 7, 83 }, { 7, 82 }, { 7, 81 }, { 7, 79 }, { 7, 78 }, { 7, 74 }, { 7, 68 }, { 7, 67 }, { 7, 65 }, { 7, 63 }, { 7, 62 }, { 7, 60 }, { 7, 59 }, { 7, 58 }, { 7, 57 }, { 7, 56 }, { 7, 55 }, { 7, 54 }, { 7, 52 }, { 7, 51 }, { 7, 48 }, { 7, 45 }, { 7, 44 }, { 7, 42 }, { 7, 40 }, { 7, 32 }, { 7, 28 }, { 7, 25 }, { 7, 21 }, { 7, 19 }, { 7, 17 }, { 7, 14 }, { 16, 10 }, { 19, 20 }, { 19, 24 }, { 19, 28 }, { 19, 30 }, { 19, 31 }, { 19, 33 }, { 18, 37 }, { 17, 37 }, { 14, 37 }, { 13, 37 }, { 11, 37 }, { 9, 32 }, { 9, 31 }, { 9, 29 }, { 9, 28 }, { 9, 27 }, { 9, 26 }, { 9, 25 }, { 9, 24 }, { 9, 22 }, { 9, 21 }, { 10, 21 }, { 11, 24 }, { 11, 28 }, { 11, 29 }, { 10, 29 }, { 8, 29 }, { 6, 29 }, { 5, 28 }, { 5, 25 }, { 5, 24 }, { 5, 22 }, { 5, 21 }, { 5, 20 }, { 5, 19 }, { 5, 17 }, { 5, 15 }, { 5, 14 }, { 5, 13 }, { 5, 9 }, { 16, 6 }, { 18, 6 }, { 20, 6 }, { 24, 6 }, { 27, 6 }, { 33, 6 }, { 35, 6 }, { 36, 8 }, { 36, 9 }, { 36, 10 }, { 36, 12 }, { 36, 15 }, { 36, 26 }, { 36, 30 }, { 36, 32 }, { 36, 36 }, { 36, 37 }, { 36, 38 }, { 36, 39 }, { 36, 40 }, { 36, 41 }, { 36, 45 }, { 36, 48 }, { 36, 49 }, { 36, 50 }, { 36, 52 }, { 36, 53 }, { 36, 54 }, { 36, 55 }, { 36, 56 }, { 36, 57 }, { 36, 60 }, { 36, 61 }, { 36, 62 }, { 36, 64 }, { 36, 65 }, { 36, 67 }, { 36, 68 }, { 36, 70 }, { 36, 71 }, { 36, 74 }, { 36, 75 }, { 36, 77 }, { 36, 78 }, { 36, 80 }, { 36, 82 }, { 36, 83 }, { 36, 84 }, { 36, 85 }, { 36, 86 }, { 36, 87 }, { 36, 89 }, { 36, 90 }, { 36, 93 }, { 36, 95 }, { 36, 96 }, { 36, 97 }, { 36, 100 }, { 35, 100 }, { 34, 100 }, { 33, 100 }, { 32, 100 }, { 31, 100 }, { 30, 100 }, { 28, 100 }, { 26, 100 }, { 25, 98 }, { 30, 98 }, { 33, 98 }, { 37, 98 }, { 40, 98 }, { 47, 98 }, { 49, 98 }, { 50, 98 }, { 53, 98 }, { 58, 98 }, { 66, 98 }, { 69, 98 }, { 71, 98 }, { 76, 98 }, { 78, 98 }, { 79, 98 }, { 80, 98 }, { 82, 98 }, { 83, 98 }, { 87, 98 }, { 89, 98 }, { 89, 100 }, { 89, 103 }, { 89, 107 }, { 89, 110 }, { 89, 111 }, { 89, 113 }, { 89, 114 }, { 88, 117 }, { 87, 117 }, { 81, 117 }, { 80, 117 }, { 78, 117 }, { 74, 117 }, { 70, 117 }, { 66, 117 }, { 63, 117 }, { 60, 117 }, { 59, 117 }, { 58, 117 }, { 56, 117 }, { 66, 113 }, { 67, 113 }, { 80, 113 }, { 86, 118 }, { 86, 120 }, { 86, 122 }, { 86, 123 }, { 84, 125 }, { 82, 125 }, { 81, 125 }, { 80, 125 }, { 74, 125 }, { 70, 125 }, { 66, 125 }, { 65, 125 }, { 64, 125 }, { 63, 125 }, { 62, 125 }, { 60, 125 }, { 58, 125 }, { 56, 125 }, { 50, 125 }, { 48, 125 }, { 42, 125 }, { 41, 124 }, { 41, 121 }, { 41, 112 }, { 41, 110 }, { 41, 104 }, { 41, 103 }, { 41, 101 }, { 41, 97 }, { 41, 90 }, { 41, 87 }, { 47, 86 }, { 49, 86 }, { 50, 86 }, { 58, 86 }, { 62, 86 }, { 66, 86 }, { 69, 86 }, { 71, 86 }, { 73, 86 }, { 76, 86 }, { 77, 86 }, { 78, 86 }, { 79, 86 }, { 82, 86 }, { 85, 86 }, { 89, 86 }, { 90, 86 }, { 93, 86 }, { 94, 86 }, { 99, 86 }, { 101, 86 }, { 104, 86 }, { 106, 86 }, { 107, 86 }, { 108, 86 }, { 110, 86 }, { 112, 87 }, { 112, 90 }, { 112, 92 }, { 112, 93 }, { 112, 97 }, { 112, 99 }, { 112, 100 }, { 112, 103 }, { 112, 104 }, { 112, 108 }, { 112, 110 }, { 112, 111 }, { 112, 113 }, { 112, 114 }, { 112, 115 }, { 111, 115 }, { 110, 115 }, { 110, 113 }, { 110, 112 }, { 110, 108 }, { 110, 104 }, { 110, 103 }, { 110, 101 }, { 110, 99 }, { 110, 97 }, { 110, 95 }, { 110, 92 }, { 110, 90 }, { 110, 85 }, { 110, 84 }, { 110, 80 }, { 113, 80 }, { 114, 80 }, { 116, 80 }, { 118, 80 }, { 119, 80 }, { 120, 80 }, { 120, 81 }, { 120, 82 }, { 120, 83 }, { 120, 85 }, { 114, 88 }, { 111, 88 }, { 108, 88 }, { 107, 88 }, { 104, 88 }, { 101, 88 }, { 97, 88 }, { 94, 88 }, { 92, 88 }, { 91, 88 }, { 84, 88 }, { 81, 88 }, { 80, 88 }, { 77, 85 }, { 77, 82 }, { 77, 79 }, { 77, 75 }, { 77, 74 }, { 77, 72 }, { 77, 71 }, { 77, 70 }, { 77, 66 }, { 77, 64 }, { 77, 62 }, { 77, 61 }, { 77, 60 }, { 77, 59 }, { 77, 56 }, { 77, 53 }, { 77, 52 }, { 77, 50 }, { 77, 48 }, { 77, 46 }, { 78, 46 }, { 79, 46 }, { 81, 46 }, { 82, 46 }, { 84, 46 }, { 85, 46 }, { 87, 46 }, { 89, 46 }, { 91, 46 }, { 94, 46 }, { 97, 46 }, { 99, 46 }, { 100, 46 }, { 102, 46 }, { 105, 46 }, { 105, 48 }, { 105, 51 }, { 105, 52 }, { 105, 53 }, { 105, 54 }, { 105, 55 }, { 105, 56 }, { 105, 57 }, { 105, 59 }, { 105, 60 }, { 105, 61 }, { 105, 62 }, { 105, 63 }, { 105, 64 }, { 105, 65 }, { 105, 66 }, { 105, 68 }, { 105, 69 }, { 105, 70 }, { 105, 71 }, { 105, 72 }, { 104, 74 }, { 103, 74 }, { 101, 74 }, { 97, 74 }, { 96, 74 }, { 94, 74 }, { 93, 74 }, { 92, 74 }, { 91, 74 }, { 90, 74 }, { 89, 74 }, { 86, 74 }, { 84, 74 }, { 82, 74 }, { 81, 74 }, { 80, 74 }, { 76, 74 }, { 74, 74 }, { 72, 74 }, { 71, 74 }, { 68, 74 }, { 67, 74 }, { 66, 74 }, { 65, 74 }, { 63, 74 }, { 62, 74 }, { 60, 74 }, { 59, 74 }, { 58, 74 }, { 56, 74 }, { 55, 74 }, { 53, 74 }, { 48, 74 }, { 46, 74 }, { 45, 74 }, { 43, 74 }, { 42, 74 }, { 40, 74 }, { 40, 72 }, { 40, 70 }, { 40, 68 }, { 40, 67 }, { 40, 66 }, { 40, 62 }, { 40, 60 }, { 40, 54 }, { 40, 53 }, { 40, 52 }, { 40, 50 }, { 40, 48 }, { 40, 47 }, { 40, 45 }, { 40, 44 }, { 40, 42 }, { 40, 41 }, { 40, 40 }, { 40, 38 }, { 40, 37 }, { 40, 36 }, { 40, 35 }, { 40, 34 }, { 40, 32 }, { 40, 31 }, { 40, 30 }, { 40, 28 }, { 40, 27 }, { 40, 26 }, { 40, 25 }, { 40, 23 }, { 40, 21 }, { 40, 20 }, { 41, 19 }, { 42, 19 }, { 44, 19 }, { 45, 19 }, { 46, 19 }, { 47, 19 }, { 50, 19 }, { 51, 19 }, { 53, 19 }, { 64, 19 }, { 65, 19 }, { 66, 21 }, { 66, 22 }, { 66, 28 }, { 66, 29 }, { 66, 30 }, { 66, 32 }, { 66, 34 }, { 66, 35 }, { 66, 37 }, { 66, 38 }, { 66, 40 }, { 66, 45 }, { 66, 47 }, { 66, 50 }, { 66, 52 }, { 66, 53 }, { 66, 56 }, { 66, 57 }, { 66, 58 }, { 66, 59 }, { 66, 60 }, { 66, 64 }, { 66, 65 }, { 66, 68 }, { 66, 69 }, { 66, 70 }, { 66, 71 }, { 66, 73 }, { 66, 75 }, { 66, 77 }, { 66, 78 }, { 66, 82 }, { 66, 83 }, { 66, 85 }, { 66, 87 }, { 65, 87 }, { 63, 87 }, { 60, 87 }, { 59, 87 }, { 58, 87 }, { 56, 87 }, { 55, 87 }, { 53, 87 }, { 51, 87 }, { 50, 87 }, { 49, 87 }, { 48, 87 }, { 47, 87 }, { 46, 87 }, { 45, 87 }, { 43, 87 }, { 42, 87 }, { 40, 87 }, { 38, 87 }, { 35, 87 }, { 34, 87 }, { 33, 87 }, { 32, 87 }, { 30, 87 }, { 28, 87 }, { 27, 87 }, { 27, 85 }, { 27, 84 }, { 27, 83 }, { 27, 80 }, { 27, 78 }, { 27, 75 }, { 27, 73 }, { 27, 72 }, { 27, 71 }, { 27, 70 }, { 28, 70 }, { 30, 70 }, { 33, 70 }, { 34, 70 }, { 37, 70 }, { 38, 70 }, { 39, 70 }, { 41, 70 }, { 42, 70 }, { 58, 70 }, { 59, 70 }, { 62, 70 }, { 64, 70 }, { 67, 70 }, { 69, 70 }, { 71, 70 }, { 74, 70 }, { 75, 70 }, { 76, 70 }, { 78, 70 }, { 79, 70 }, { 80, 71 }, { 80, 72 }, { 80, 75 }, { 80, 77 }, { 80, 79 }, { 80, 83 }, { 80, 85 }, { 80, 87 }, { 80, 89 }, { 80, 91 }, { 80, 93 }, { 80, 95 }, { 80, 100 }, { 80, 101 }, { 80, 103 }, { 80, 104 }, { 80, 107 }, { 80, 110 }, { 80, 115 }, { 80, 118 }, { 80, 120 }, { 79, 120 }, { 78, 120 }, { 74, 120 }, { 70, 120 }, { 66, 120 }, { 65, 120 }, { 63, 120 }, { 62, 120 }, { 61, 120 }, { 60, 120 }, { 58, 120 }, { 56, 120 }, { 50, 120 }, { 49, 120 }, { 48, 120 }, { 42, 120 }, { 40, 120 }, { 35, 120 }, { 32, 120 }, { 31, 120 }, { 26, 120 }, { 24, 120 }, { 19, 120 }, { 18, 117 }, { 30, 107 }, { 33, 107 }, { 33, 108 }, { 33, 109 }, { 33, 110 }, { 33, 113 }, { 33, 121 }, { 32, 122 }, { 31, 122 }, { 30, 122 }, { 26, 122 }, { 24, 122 }, { 19, 122 }, { 17, 122 }, { 16, 121 }, { 16, 117 }, { 16, 112 }, { 16, 111 }, { 16, 106 }, { 16, 105 }, { 16, 101 }, { 16, 100 }, { 16, 98 }, { 16, 97 }, { 16, 95 }, { 16, 93 }, { 16, 90 }, { 16, 88 }, { 16, 87 }, { 16, 86 }, { 16, 85 }, { 16, 84 }, { 16, 83 }, { 16, 82 }, { 18, 82 }, { 19, 82 }, { 20, 82 }, { 21, 82 }, { 22, 82 }, { 24, 82 }, { 26, 82 }, { 28, 82 }, { 30, 82 }, { 32, 82 }, { 33, 82 }, { 34, 82 }, { 35, 82 }, { 37, 82 }, { 38, 82 }, { 40, 82 }, { 42, 82 }, { 42, 83 }, { 42, 84 }, { 42, 85 }, { 42, 88 }, { 42, 89 }, { 42, 90 }, { 42, 91 }, { 42, 93 }, { 40, 93 }, { 38, 93 }, { 37, 93 }, { 35, 93 }, { 34, 93 }, { 32, 93 }, { 30, 93 }, { 28, 93 }, { 26, 93 }, { 24, 93 }, { 21, 93 }, { 20, 93 }, { 19, 93 }, { 15, 93 }, { 14, 93 }, { 13, 93 }, { 11, 93 }, { 10, 93 }, { 9, 93 }, { 6, 93 }, { 4, 93 }, { 3, 93 }, { 3, 91 }, { 3, 90 }, { 3, 88 }, { 3, 87 }, { 3, 86 }, { 3, 85 }, { 3, 84 }, { 3, 83 }, { 3, 82 }, { 3, 81 }, { 3, 79 }, { 3, 78 }, { 9, 76 }, { 13, 76 }, { 20, 76 }, { 22, 76 }, { 22, 78 }, { 22, 83 }, { 22, 84 }, { 22, 85 }, { 22, 86 }, { 22, 87 }, { 22, 89 }, { 22, 90 }, { 22, 91 }, { 22, 94 }, { 22, 95 }, { 22, 97 }, { 22, 101 }, { 22, 103 }, { 21, 103 }, { 20, 103 }, { 19, 103 }, { 15, 103 }, { 14, 103 }, { 13, 103 }, { 11, 103 }, { 10, 103 }, { 9, 103 }, { 8, 103 }, { 7, 103 }, { 6, 103 }, { 3, 103 }, { 2, 103 }, { 2, 102 }, { 2, 101 }, { 2, 100 }, { 2, 99 }, { 2, 98 }, { 2, 97 }, { 6, 97 }, { 9, 97 }, { 13, 97 }, { 15, 97 }, { 18, 97 }, { 19, 97 }, { 23, 97 }, { 23, 101 }, { 23, 103 }, { 23, 104 }, { 23, 105 }, { 23, 106 }, { 23, 109 }, { 23, 110 }, { 23, 113 }, { 23, 114 }, { 22, 115 }, { 21, 115 }, { 20, 115 }, { 19, 115 }, { 17, 115 }, { 15, 115 }, { 14, 115 }, { 13, 115 }, { 12, 115 }, { 9, 115 }, { 7, 115 }, { 6, 115 }, { 3, 115 }, { 1, 115 }, { 9, 110 }, { 12, 110 }, { 13, 110 }, { 24, 110 }, { 26, 110 }, { 29, 110 }, { 30, 110 }, { 34, 110 }, { 36, 110 }, { 37, 110 }, { 39, 110 }, { 44, 110 }, { 47, 110 }, { 50, 110 }, { 51, 110 }, { 59, 110 }, { 62, 110 }, { 66, 110 }, { 67, 110 }, { 67, 115 }, { 67, 118 }, { 67, 121 }, { 67, 122 }, { 67, 123 }, { 67, 124 }, { 67, 126 }, { 66, 128 }, { 65, 128 }, { 64, 128 }, { 63, 128 }, { 62, 128 }, { 58, 128 }, { 56, 128 }, { 52, 128 }, { 50, 128 }, { 49, 128 }, { 48, 128 }, { 44, 128 }, { 41, 128 }, { 40, 128 }, { 35, 128 }, { 33, 128 }, { 36, 126 }, { 36, 127 }, { 36, 129 } };
+ size_t i{ 0 };
+
+ Grid pathGrid{ lines.size(), lines[0].size() };
+
+ auto directionIndex = getStartDirectionIndex();
+ auto current = start_;
+ visitPosition(current, directionIndex, pathGrid);
+ backtracePath(current, directionIndex, pathGrid);
+ auto next = current + Point2::cardinalDirections[directionIndex];
+ while (isInBounds(next))
{
- setPosition(current, getVisitedChar());
- part1++;
+ if (getPosition(next) == getObstructionChar())
+ {
+ directionIndex = turnDirectionRight(directionIndex);
+ backtracePath(current, directionIndex, pathGrid);
+ }
+ else
+ {
+ if (pathGrid.cell(current).isLoopingInDirection[turnDirectionRight(directionIndex)] &&
+ //!pathGrid.cell(current).isLoopingInDirection[turnDirectionRight(turnDirectionRight(directionIndex))] &&
+ !pathGrid.cell(next).isVisited)
+ {
+ part2++;
+ if (std::find(loopingSolutions.cbegin(), loopingSolutions.cend(), next) == loopingSolutions.cend())
+ {
+ std::cout << "didn't find " << next << " in solutions. Current is " << current << std::endl;
+ }
+ }
+ current = next;
+ visitPosition(current, directionIndex, pathGrid);
+ }
+ next = current + Point2::cardinalDirections[directionIndex];
+ }
+
+ for (int j = 0; j < pathGrid.getNRows(); j++)
+ {
+ for (int i = 0; i < pathGrid.getNColumns(); i++)
+ {
+ if (pathGrid[j][i].isLoopingInDirection[0]) // down
+ if (pathGrid[j][i].isLoopingInDirection[1]) // right
+ if (pathGrid[j][i].isLoopingInDirection[2]) // up
+ if (pathGrid[j][i].isLoopingInDirection[3]) // left
+ std::cout << "+"; // down right up left
+ else
+ std::cout << "F"; // down right up
+ else
+ if (pathGrid[j][i].isLoopingInDirection[3])
+ std::cout << "T"; // down right left
+ else
+ std::cout << "r"; // down right
+ else
+ if (pathGrid[j][i].isLoopingInDirection[2])
+ if (pathGrid[j][i].isLoopingInDirection[3])
+ std::cout << "3"; // down up left
+ else
+ std::cout << "|"; // down up
+ else
+ if (pathGrid[j][i].isLoopingInDirection[3])
+ std::cout << "7"; // down left
+ else
+ std::cout << "v"; // down
+ else
+ if (pathGrid[j][i].isLoopingInDirection[1])
+ if (pathGrid[j][i].isLoopingInDirection[2])
+ if (pathGrid[j][i].isLoopingInDirection[3])
+ std::cout << "W"; // right up left
+ else
+ std::cout << "L"; // right up
+ else
+ if (pathGrid[j][i].isLoopingInDirection[3])
+ std::cout << "-"; // right left
+ else
+ std::cout << ">"; // right
+ else
+ if (pathGrid[j][i].isLoopingInDirection[2])
+ if (pathGrid[j][i].isLoopingInDirection[3])
+ std::cout << "J"; // up left
+ else
+ std::cout << "^"; // up
+ else
+ if (pathGrid[j][i].isLoopingInDirection[3])
+ std::cout << "<"; // left
+ else
+ std::cout << lines[j][i];
+ }
+ std::cout << std::endl;
}
}
-size_t GuardGallivant::turnDirection(const size_t current) const
+void GuardGallivant::visitPosition(const Point2& current, const size_t directionIndex, Grid& pathGrid)
{
- return current == 0 ? 3 : current - 1;
+ if (!pathGrid.cell(current).isVisited)
+ {
+ pathGrid.cell(current).isVisited = true;
+ part1++;
+ }
+ pathGrid.cell(current).isLoopingInDirection[directionIndex] = true;
+ backtraceTurn(current, turnDirectionLeft(directionIndex), pathGrid);
+}
+
+void GuardGallivant::backtracePath(const Point2& current, const size_t directionIndex, Grid& pathGrid)
+{
+ auto oppositeDirectionIndex = revertDirection(directionIndex);
+ auto reverseTurnDirectionIndex = turnDirectionRight(oppositeDirectionIndex);
+ auto next = current + Point2::cardinalDirections[oppositeDirectionIndex];
+ while (isInBounds(next) && getPosition(next) != getObstructionChar() &&
+ !pathGrid.cell(next).isLoopingInDirection[directionIndex])
+ {
+ backtraceTurn(next, reverseTurnDirectionIndex, pathGrid);
+ pathGrid.cell(next).isLoopingInDirection[directionIndex] = true;
+ next = next + Point2::cardinalDirections[oppositeDirectionIndex];
+ }
+}
+
+void GuardGallivant::backtraceTurn(const Point2& current, const size_t reverseTurnDirectionIndex,
+ Grid& pathGrid)
+{
+ auto left = current + Point2::cardinalDirections[reverseTurnDirectionIndex];
+ if (isInBounds(left) && getPosition(left) == getObstructionChar())
+ {
+ backtracePath(current, reverseTurnDirectionIndex, pathGrid);
+ }
+}
+
+size_t GuardGallivant::turnDirectionRight(const size_t currentDirectionIndex) const
+{
+ return currentDirectionIndex == 0 ? 3 : currentDirectionIndex - 1;
+}
+
+size_t GuardGallivant::turnDirectionLeft(const size_t currentDirectionIndex) const
+{
+ return currentDirectionIndex == 3 ? 0 : currentDirectionIndex + 1;
+}
+
+size_t GuardGallivant::revertDirection(const size_t currentDirectionIndex) const
+{
+ auto next = currentDirectionIndex + 2;
+ return next > 3 ? next - 4 : next;
}
diff --git a/src/Point2.cpp b/src/Point2.cpp
index 5340d53..04268e6 100644
--- a/src/Point2.cpp
+++ b/src/Point2.cpp
@@ -81,3 +81,9 @@ Point2& Point2::operator*=(const int rhs)
*this = *this * rhs;
return *this;
}
+
+std::ostream& operator<<(std::ostream& os, const Point2& rhs)
+{
+ os << "(" << rhs.x << ", " << rhs.y << ")";
+ return os;
+}
diff --git a/tests/src/TestCases.cpp b/tests/src/TestCases.cpp
index 85e70a2..ddade61 100644
--- a/tests/src/TestCases.cpp
+++ b/tests/src/TestCases.cpp
@@ -97,11 +97,11 @@ TEST_CASE("[GuardGallivantTests]")
TestContext test;
SECTION("FullData")
{
- test.run(std::make_unique(), 4665, 0, test.getInputPaths());
+ test.run(std::make_unique(), 4665, 1688, test.getInputPaths());
}
SECTION("ExampleData")
{
- test.run(std::make_unique(), 41, 0, test.getExampleInputPaths());
+ test.run(std::make_unique(), 41, 6, test.getExampleInputPaths());
}
}