Fix some private field identifiers

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

View File

@@ -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++;
}

View File

@@ -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++;