Skip to content

Instantly share code, notes, and snippets.

@maksverver
Created December 10, 2022 22:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maksverver/3c507c55d195ae5394f7a19b855b671b to your computer and use it in GitHub Desktop.
Save maksverver/3c507c55d195ae5394f7a19b855b671b to your computer and use it in GitHub Desktop.
--- 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