From 529af585fd2be41a8da68e30eddde356bf1f7501 Mon Sep 17 00:00:00 2001 From: Nick Krichevsky Date: Thu, 24 Dec 2020 19:08:26 -0500 Subject: [PATCH] Remove unneeded midle copy from rotation code in day 20 --- day20/day20.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/day20/day20.cpp b/day20/day20.cpp index e04e8cd..f17d3ed 100644 --- a/day20/day20.cpp +++ b/day20/day20.cpp @@ -125,7 +125,7 @@ class CameraFrame { std::vector rotatedFrame(this->frame.size(), std::string(this->frame.at(0).size(), ' ')); int ringStartIndex = 0; int ringEndIndex = this->frame.size() - 1; - while (ringStartIndex < ringEndIndex) { + while (ringStartIndex <= ringEndIndex) { // Top Edge -> Right Edge for (int i = ringStartIndex; i <= ringEndIndex; i++) { rotatedFrame.at(i).at(ringEndIndex) = frame.at(ringStartIndex).at(i); @@ -150,14 +150,6 @@ class CameraFrame { ringEndIndex--; } - // Copy over the middle - // Without this if, this overwrites legit rotated tiles when filling in the middle, if we have a board of an - // even number size - if (this->frame.size() % 2 != 0) { - auto middle = this->frame.size() / 2; - rotatedFrame.at(middle).at(middle) = frame.at(middle).at(middle); - } - this->frame = std::move(rotatedFrame); }