From 0ef1fc62e87be5ada2a06b7099c82d5e74fe73a2 Mon Sep 17 00:00:00 2001 From: Nick Krichevsky Date: Sun, 27 Dec 2020 04:54:22 -0500 Subject: [PATCH] Minor cleanup of day 23 --- day23/day23.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/day23/day23.cpp b/day23/day23.cpp index dad13ea..e319498 100644 --- a/day23/day23.cpp +++ b/day23/day23.cpp @@ -93,10 +93,10 @@ class CupGraph { private: static constexpr int END = -1; + friend CupGraph; + const CupGraph &graph; int n; int stop; - const CupGraph &graph; - friend CupGraph; }; /** * Construct a new CupGraph from the given range @@ -272,7 +272,6 @@ std::vector makeCupList(const std::string &inputLine) { std::tuple getPickedUpCups(int currentCup, const CupGraph &graph) { auto range = graph.cycleRange(currentCup); auto it = range.first; - auto it2 = range.first; // This may look stupid, but putting *(it++) into make_tuple will not be evaluated in a deterministic order! int value1 = *(it++); int value2 = *(it++); @@ -305,7 +304,6 @@ bool tupleContainsItem(Tuple tuple, ValueType value) { */ int findDestinationCup(int currentCup, const CupGraph &graph, int minCup, int maxCup) { std::tuple pickedUpCups = getPickedUpCups(currentCup, graph); - auto cupRange = graph.cycleRange(currentCup); int destinationCup = currentCup; do { @@ -364,7 +362,7 @@ void runGame(int startingCup, CupGraph &graph, int numIterations) { // Since we move three at a time, we only need to get the first picked up cup int firstPickedUpCup = graph.getNext(currentCup); - graph.move3(graph.getNext(currentCup), destinationCup); + graph.move3(firstPickedUpCup, destinationCup); currentCup = graph.getNext(currentCup); }