Fix some private field identifiers

This commit is contained in:
Stefan Müller 2024-12-24 15:30:14 +01:00
parent 262a84fa68
commit e0a9a807da
6 changed files with 20 additions and 20 deletions

View File

@ -27,7 +27,7 @@ class CeresSearch
std::string getInputFileName() const override; std::string getInputFileName() const override;
void finish() override; void finish() override;
private: private:
char xmas[4] = { 'X', 'M', 'A', 'S' }; char xmas_[4] = { 'X', 'M', 'A', 'S' };
void computeXmasCount(const Point2& start); void computeXmasCount(const Point2& start);
void computeX_MasCount(const Point2& start); void computeX_MasCount(const Point2& start);
}; };

View File

@ -21,11 +21,12 @@ class GuardGallivant
: public LinesSolver : public LinesSolver
{ {
public: public:
Point2 start_{};
std::string getPuzzleName() const override; std::string getPuzzleName() const override;
std::string getInputFileName() const override; std::string getInputFileName() const override;
void processDataLine(const std::string& line) override; void processDataLine(const std::string& line) override;
void finish() override; void finish() override;
private:
Point2 start_{};
void visitPosition(const Point2& current); void visitPosition(const Point2& current);
size_t turnDirection(const size_t current) const; size_t turnDirection(const size_t current) const;
size_t getStartDirectionIndex() const; size_t getStartDirectionIndex() const;

View File

@ -28,6 +28,6 @@ class HistorianHysteria
virtual void processDataLine(const std::string& line) override; virtual void processDataLine(const std::string& line) override;
virtual void finish() override; virtual void finish() override;
private: private:
std::multiset<int> left; std::multiset<int> left_;
std::multiset<int> right; std::multiset<int> right_;
}; };

View File

@ -27,7 +27,6 @@ class SolverEngine
public: public:
SolverEngine(const std::vector<std::string>& inputPaths); SolverEngine(const std::vector<std::string>& inputPaths);
void run(Solver& solver); void run(Solver& solver);
private: private:
std::vector<std::string> inputPaths_; std::vector<std::string> inputPaths_;
std::filesystem::path tryGetValidFullInputFilePath(const std::string& inputFileName); std::filesystem::path tryGetValidFullInputFilePath(const std::string& inputFileName);

View File

@ -31,12 +31,12 @@ void CeresSearch::finish()
{ {
for (int i = 0; i < lines[j].size(); i++) 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 }; Point2 start{ i, j };
computeXmasCount(start); computeXmasCount(start);
} }
else if (lines[j][i] == xmas[2]) else if (lines[j][i] == xmas_[2])
{ {
Point2 start{ i, j }; Point2 start{ i, j };
computeX_MasCount(start); computeX_MasCount(start);
@ -51,7 +51,7 @@ void CeresSearch::computeXmasCount(const Point2& start)
{ {
auto p{ start + d }; auto p{ start + d };
auto i{ 1 }; auto i{ 1 };
while (i < 4 && isInBounds(p) && xmas[i] == getPosition(p)) while (i < 4 && isInBounds(p) && xmas_[i] == getPosition(p))
{ {
p += d; p += d;
i++; i++;
@ -70,10 +70,10 @@ void CeresSearch::computeX_MasCount(const Point2& start)
auto pUR{ start + Point2::upRight }; auto pUR{ start + Point2::upRight };
auto pDL{ start + Point2::downLeft }; auto pDL{ start + Point2::downLeft };
if (isInBounds(pUL) && isInBounds(pDR) if (isInBounds(pUL) && isInBounds(pDR)
&& ((getPosition(pUL) == xmas[1] && getPosition(pDR) == xmas[3]) && ((getPosition(pUL) == xmas_[1] && getPosition(pDR) == xmas_[3])
|| (getPosition(pUL) == xmas[3] && getPosition(pDR) == xmas[1])) || (getPosition(pUL) == xmas_[3] && getPosition(pDR) == xmas_[1]))
&& ((getPosition(pUR) == xmas[1] && getPosition(pDL) == xmas[3]) && ((getPosition(pUR) == xmas_[1] && getPosition(pDL) == xmas_[3])
|| (getPosition(pUR) == xmas[3] && getPosition(pDL) == xmas[1]))) || (getPosition(pUR) == xmas_[3] && getPosition(pDL) == xmas_[1])))
{ {
part2++; part2++;
} }

View File

@ -30,19 +30,19 @@ std::string HistorianHysteria::getInputFileName() const
void HistorianHysteria::processDataLine(const std::string& line) void HistorianHysteria::processDataLine(const std::string& line)
{ {
auto pos{ line.find(" ") }; auto pos{ line.find(" ") };
left.insert(std::stoi(line.substr(0, pos))); left_.insert(std::stoi(line.substr(0, pos)));
right.insert(std::stoi(line.substr(pos + 3))); right_.insert(std::stoi(line.substr(pos + 3)));
} }
void HistorianHysteria::finish() void HistorianHysteria::finish()
{ {
int prev{ 0 }; int prev{ 0 };
auto nSame{ 0 }; auto nSame{ 0 };
auto leftIterator{ left.begin() }; auto leftIterator{ left_.begin() };
auto rightIterator{ right.begin() }; auto rightIterator{ right_.begin() };
auto rightSameIterator{ right.begin() }; auto rightSameIterator{ right_.begin() };
while (leftIterator != left.end()) while (leftIterator != left_.end())
{ {
part1 += abs(*leftIterator - *rightIterator); part1 += abs(*leftIterator - *rightIterator);
@ -50,12 +50,12 @@ void HistorianHysteria::finish()
{ {
nSame = 0; nSame = 0;
// Skips over numbers in the right list that are smaller than the current left number. // 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++; rightSameIterator++;
} }
// Counts the occurrences of the current left number in the right list. // 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++; rightSameIterator++;
nSame++; nSame++;