From 648f6d4ebc3d00ce7876038e26a1c531040f01b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20M=C3=BCller?= Date: Tue, 4 Feb 2025 17:50:38 +0100 Subject: [PATCH] Rename LinesSolver::getPosition()/setPosition() to getCharAt()/setCharAt() --- include/aoc/LinesSolver.hpp | 6 +++--- src/CeresSearch.cpp | 12 ++++++------ src/GuardGallivant.cpp | 8 ++++---- src/HoofIt.cpp | 6 +++--- src/LinesSolver.cpp | 6 +++--- src/ResonantCollinearity.cpp | 2 +- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/include/aoc/LinesSolver.hpp b/include/aoc/LinesSolver.hpp index 232c24b..968a055 100644 --- a/include/aoc/LinesSolver.hpp +++ b/include/aoc/LinesSolver.hpp @@ -1,5 +1,5 @@ // Solutions to the Advent Of Code 2024. -// Copyright (C) 2024 Stefan Müller +// Copyright (C) 2024-2025 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 @@ -28,6 +28,6 @@ class LinesSolver protected: std::vector lines{}; bool isInBounds(const Point2& point) const; - char getPosition(const Point2& point) const; - void setPosition(const Point2& point, const char value); + char getCharAt(const Point2& point) const; + void setCharAt(const Point2& point, const char value); }; diff --git a/src/CeresSearch.cpp b/src/CeresSearch.cpp index e30085f..165c2b9 100644 --- a/src/CeresSearch.cpp +++ b/src/CeresSearch.cpp @@ -1,5 +1,5 @@ // Solutions to the Advent Of Code 2024. -// Copyright (C) 2024 Stefan Müller +// Copyright (C) 2024-2025 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 @@ -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] == getCharAt(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]))) + && ((getCharAt(pUL) == xmas_[1] && getCharAt(pDR) == xmas_[3]) + || (getCharAt(pUL) == xmas_[3] && getCharAt(pDR) == xmas_[1])) + && ((getCharAt(pUR) == xmas_[1] && getCharAt(pDL) == xmas_[3]) + || (getCharAt(pUR) == xmas_[3] && getCharAt(pDL) == xmas_[1]))) { part2++; } diff --git a/src/GuardGallivant.cpp b/src/GuardGallivant.cpp index b7cb5ac..351c05a 100644 --- a/src/GuardGallivant.cpp +++ b/src/GuardGallivant.cpp @@ -1,5 +1,5 @@ // Solutions to the Advent Of Code 2024. -// Copyright (C) 2024 Stefan Müller +// Copyright (C) 2024-2025 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 @@ -43,7 +43,7 @@ void GuardGallivant::finish() auto next{ current + Point2::cardinalDirections[dirIndex] }; while (isInBounds(next)) { - if (getPosition(next) == getObstructionChar()) + if (getCharAt(next) == getObstructionChar()) { dirIndex = turnDirection(dirIndex); } @@ -78,9 +78,9 @@ constexpr char GuardGallivant::getObstructionChar() void GuardGallivant::visitPosition(const Point2& current) { - if (getPosition(current) != getVisitedChar()) + if (getCharAt(current) != getVisitedChar()) { - setPosition(current, getVisitedChar()); + setCharAt(current, getVisitedChar()); part1++; } } diff --git a/src/HoofIt.cpp b/src/HoofIt.cpp index 46f0d03..caf6ac7 100644 --- a/src/HoofIt.cpp +++ b/src/HoofIt.cpp @@ -1,5 +1,5 @@ // Solutions to the Advent Of Code 2024. -// Copyright (C) 2024 Stefan Müller +// Copyright (C) 2024-2025 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 @@ -57,12 +57,12 @@ void HoofIt::finish() { auto trail = queue.front(); queue.pop(); - if (getPosition(trail) != getTrailheadChar()) + if (getCharAt(trail) != getTrailheadChar()) { for (auto direction : Point2::cardinalDirections) { Point2 p{ trail + direction }; - if (isInBounds(p) && getPosition(p) + 1 == getPosition(trail)) + if (isInBounds(p) && getCharAt(p) + 1 == getCharAt(trail)) { if (trailEndsMap[p.y][p.x].empty()) { diff --git a/src/LinesSolver.cpp b/src/LinesSolver.cpp index cc7c59c..8ad2139 100644 --- a/src/LinesSolver.cpp +++ b/src/LinesSolver.cpp @@ -1,5 +1,5 @@ // Solutions to the Advent Of Code 2024. -// Copyright (C) 2024 Stefan Müller +// Copyright (C) 2024-2025 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 @@ -26,12 +26,12 @@ bool LinesSolver::isInBounds(const Point2& point) const 0 <= point.x && point.x < lines[point.y].size(); } -char LinesSolver::getPosition(const Point2& point) const +char LinesSolver::getCharAt(const Point2& point) const { return lines[point.y][point.x]; } -void LinesSolver::setPosition(const Point2& point, const char value) +void LinesSolver::setCharAt(const Point2& point, const char value) { lines[point.y][point.x] = value; } diff --git a/src/ResonantCollinearity.cpp b/src/ResonantCollinearity.cpp index 242d0c5..92b4825 100644 --- a/src/ResonantCollinearity.cpp +++ b/src/ResonantCollinearity.cpp @@ -53,7 +53,7 @@ constexpr char ResonantCollinearity::getEmptyChar() void ResonantCollinearity::addNewAntenna(Grid& antinodeGrid1, Grid& antinodeGrid2, Point2&& newPosition) { - const auto [it, success] = antennas_.insert({ getPosition(newPosition), { newPosition } }); + const auto [it, success] = antennas_.insert({ getCharAt(newPosition), { newPosition } }); if (!success) { // Adds the new antenna position itself as an antinode for part 2.