Created
December 10, 2022 22:20
-
-
Save maksverver/3c507c55d195ae5394f7a19b855b671b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- a/Problem9/Problem9.cpp | |
+++ b/Problem9/Problem9.cpp | |
@@ -218,20 +218,19 @@ bool Run(const std::filesystem::path &file) | |
{ | |
int d = dir; | |
Move lastMove; | |
- for (int k = 0; k < NumKnots /*&& d != None*/; k++) | |
+ for (int k = 0; k < NumKnots; k++) | |
{ | |
auto& state = knotStates[k]; | |
lastMove = States[state][d]; | |
state = lastMove.nextState; | |
d = lastMove.moveDir; | |
+ if (d == None) goto done; | |
} | |
- if (d != None) | |
- { | |
- x += lastMove.dx; | |
- y += lastMove.dy; | |
- numCells += grid.Set(x, y); | |
- } | |
+ x += lastMove.dx; | |
+ y += lastMove.dy; | |
+ numCells += grid.Set(x, y); | |
+ done:; | |
//minx = std::min(minx, x); | |
//miny = std::min(miny, y); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment