From 861a51bad786a326f984ced90047f3970d487e97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20M=C3=BCller?= Date: Thu, 5 Dec 2024 19:31:30 +0100 Subject: [PATCH] Fix some code style issues --- AdventOfCode2024/HistorianHysteria.cpp | 8 ++++---- AdventOfCode2024/Point2.cpp | 22 +++++++++++----------- AdventOfCode2024/Point2.h | 6 +++--- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/AdventOfCode2024/HistorianHysteria.cpp b/AdventOfCode2024/HistorianHysteria.cpp index babad2f..774e334 100644 --- a/AdventOfCode2024/HistorianHysteria.cpp +++ b/AdventOfCode2024/HistorianHysteria.cpp @@ -29,7 +29,7 @@ std::string HistorianHysteria::getInputFileName() const void HistorianHysteria::processDataLine(const std::string& line) { - auto pos = line.find(" "); + auto pos{ line.find(" ") }; left.insert(std::stoi(line.substr(0, pos))); right.insert(std::stoi(line.substr(pos + 3))); } @@ -38,9 +38,9 @@ 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()) { diff --git a/AdventOfCode2024/Point2.cpp b/AdventOfCode2024/Point2.cpp index c8843ed..7252aee 100644 --- a/AdventOfCode2024/Point2.cpp +++ b/AdventOfCode2024/Point2.cpp @@ -15,6 +15,17 @@ #include "Point2.h" +const Point2 Point2::left{ -1, 0 }; +const Point2 Point2::right{ 1, 0 }; +const Point2 Point2::up{ 0, -1 }; +const Point2 Point2::down{ 0, 1 }; +const Point2 Point2::upLeft{ -1, -1 }; +const Point2 Point2::upRight{ 1, -1 }; +const Point2 Point2::downLeft{ -1, 1 }; +const Point2 Point2::downRight{ 1, 1 }; +const Point2 Point2::directions[] = { Point2::left, Point2::right, Point2::up, Point2::down, + Point2::upLeft, Point2::upRight, Point2::downLeft, Point2::downRight }; + Point2::Point2() : Point2{ 0, 0 } {} @@ -68,14 +79,3 @@ Point2& Point2::operator*=(const int rhs) *this = *this * rhs; return *this; } - -const Point2 Point2::left{ -1, 0 }; -const Point2 Point2::right{ 1, 0 }; -const Point2 Point2::up{ 0, -1 }; -const Point2 Point2::down{ 0, 1 }; -const Point2 Point2::upLeft{ -1, -1 }; -const Point2 Point2::upRight{ 1, -1 }; -const Point2 Point2::downLeft{ -1, 1 }; -const Point2 Point2::downRight{ 1, 1 }; -const Point2 Point2::directions[] = { Point2::left, Point2::right, Point2::up, Point2::down, - Point2::upLeft, Point2::upRight, Point2::downLeft, Point2::downRight }; diff --git a/AdventOfCode2024/Point2.h b/AdventOfCode2024/Point2.h index ef32241..29dc176 100644 --- a/AdventOfCode2024/Point2.h +++ b/AdventOfCode2024/Point2.h @@ -18,6 +18,9 @@ class Point2 { public: + static const Point2 left, right, up, down; + static const Point2 upLeft, upRight, downLeft, downRight; + static const Point2 directions[8]; int x, y; Point2(); Point2(const int x, const int y); @@ -30,7 +33,4 @@ class Point2 Point2& operator+=(const Point2& rhs); Point2& operator-=(const Point2& rhs); Point2& operator*=(const int rhs); - static const Point2 left, right, up, down; - static const Point2 upLeft, upRight, downLeft, downRight; - static const Point2 directions[8]; };