Fix some private field identifiers
This commit is contained in:
parent
262a84fa68
commit
e0a9a807da
|
@ -27,7 +27,7 @@ class CeresSearch
|
|||
std::string getInputFileName() const override;
|
||||
void finish() override;
|
||||
private:
|
||||
char xmas[4] = { 'X', 'M', 'A', 'S' };
|
||||
char xmas_[4] = { 'X', 'M', 'A', 'S' };
|
||||
void computeXmasCount(const Point2& start);
|
||||
void computeX_MasCount(const Point2& start);
|
||||
};
|
||||
|
|
|
@ -21,11 +21,12 @@ class GuardGallivant
|
|||
: public LinesSolver
|
||||
{
|
||||
public:
|
||||
Point2 start_{};
|
||||
std::string getPuzzleName() const override;
|
||||
std::string getInputFileName() const override;
|
||||
void processDataLine(const std::string& line) override;
|
||||
void finish() override;
|
||||
private:
|
||||
Point2 start_{};
|
||||
void visitPosition(const Point2& current);
|
||||
size_t turnDirection(const size_t current) const;
|
||||
size_t getStartDirectionIndex() const;
|
||||
|
|
|
@ -28,6 +28,6 @@ class HistorianHysteria
|
|||
virtual void processDataLine(const std::string& line) override;
|
||||
virtual void finish() override;
|
||||
private:
|
||||
std::multiset<int> left;
|
||||
std::multiset<int> right;
|
||||
std::multiset<int> left_;
|
||||
std::multiset<int> right_;
|
||||
};
|
||||
|
|
|
@ -27,7 +27,6 @@ class SolverEngine
|
|||
public:
|
||||
SolverEngine(const std::vector<std::string>& inputPaths);
|
||||
void run(Solver& solver);
|
||||
|
||||
private:
|
||||
std::vector<std::string> inputPaths_;
|
||||
std::filesystem::path tryGetValidFullInputFilePath(const std::string& inputFileName);
|
||||
|
|
|
@ -31,12 +31,12 @@ void CeresSearch::finish()
|
|||
{
|
||||
for (int i = 0; i < lines[j].size(); i++)
|
||||
{
|
||||
if (lines[j][i] == xmas[0])
|
||||
if (lines[j][i] == xmas_[0])
|
||||
{
|
||||
Point2 start{ i, j };
|
||||
computeXmasCount(start);
|
||||
}
|
||||
else if (lines[j][i] == xmas[2])
|
||||
else if (lines[j][i] == xmas_[2])
|
||||
{
|
||||
Point2 start{ i, j };
|
||||
computeX_MasCount(start);
|
||||
|
@ -51,7 +51,7 @@ void CeresSearch::computeXmasCount(const Point2& start)
|
|||
{
|
||||
auto p{ start + d };
|
||||
auto i{ 1 };
|
||||
while (i < 4 && isInBounds(p) && xmas[i] == getPosition(p))
|
||||
while (i < 4 && isInBounds(p) && xmas_[i] == getPosition(p))
|
||||
{
|
||||
p += d;
|
||||
i++;
|
||||
|
@ -70,10 +70,10 @@ void CeresSearch::computeX_MasCount(const Point2& start)
|
|||
auto pUR{ start + Point2::upRight };
|
||||
auto pDL{ start + Point2::downLeft };
|
||||
if (isInBounds(pUL) && isInBounds(pDR)
|
||||
&& ((getPosition(pUL) == xmas[1] && getPosition(pDR) == xmas[3])
|
||||
|| (getPosition(pUL) == xmas[3] && getPosition(pDR) == xmas[1]))
|
||||
&& ((getPosition(pUR) == xmas[1] && getPosition(pDL) == xmas[3])
|
||||
|| (getPosition(pUR) == xmas[3] && getPosition(pDL) == xmas[1])))
|
||||
&& ((getPosition(pUL) == xmas_[1] && getPosition(pDR) == xmas_[3])
|
||||
|| (getPosition(pUL) == xmas_[3] && getPosition(pDR) == xmas_[1]))
|
||||
&& ((getPosition(pUR) == xmas_[1] && getPosition(pDL) == xmas_[3])
|
||||
|| (getPosition(pUR) == xmas_[3] && getPosition(pDL) == xmas_[1])))
|
||||
{
|
||||
part2++;
|
||||
}
|
||||
|
|
|
@ -30,19 +30,19 @@ std::string HistorianHysteria::getInputFileName() const
|
|||
void HistorianHysteria::processDataLine(const std::string& line)
|
||||
{
|
||||
auto pos{ line.find(" ") };
|
||||
left.insert(std::stoi(line.substr(0, pos)));
|
||||
right.insert(std::stoi(line.substr(pos + 3)));
|
||||
left_.insert(std::stoi(line.substr(0, pos)));
|
||||
right_.insert(std::stoi(line.substr(pos + 3)));
|
||||
}
|
||||
|
||||
void HistorianHysteria::finish()
|
||||
{
|
||||
int prev{ 0 };
|
||||
auto nSame{ 0 };
|
||||
auto leftIterator{ left.begin() };
|
||||
auto rightIterator{ right.begin() };
|
||||
auto rightSameIterator{ right.begin() };
|
||||
auto leftIterator{ left_.begin() };
|
||||
auto rightIterator{ right_.begin() };
|
||||
auto rightSameIterator{ right_.begin() };
|
||||
|
||||
while (leftIterator != left.end())
|
||||
while (leftIterator != left_.end())
|
||||
{
|
||||
part1 += abs(*leftIterator - *rightIterator);
|
||||
|
||||
|
@ -50,12 +50,12 @@ void HistorianHysteria::finish()
|
|||
{
|
||||
nSame = 0;
|
||||
// Skips over numbers in the right list that are smaller than the current left number.
|
||||
while (rightSameIterator != right.end() && *rightSameIterator < *leftIterator)
|
||||
while (rightSameIterator != right_.end() && *rightSameIterator < *leftIterator)
|
||||
{
|
||||
rightSameIterator++;
|
||||
}
|
||||
// Counts the occurrences of the current left number in the right list.
|
||||
while (rightSameIterator != right.end() && *rightSameIterator == *leftIterator)
|
||||
while (rightSameIterator != right_.end() && *rightSameIterator == *leftIterator)
|
||||
{
|
||||
rightSameIterator++;
|
||||
nSame++;
|
||||
|
|
Loading…
Reference in New Issue