summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Spragg <adam@spra.gg>2022-12-09 16:56:52 +0000
committerAdam Spragg <adam@spra.gg>2022-12-09 16:56:52 +0000
commit4291faa39d4aad4a9cfed55600d32403422a2d4b (patch)
treed111ddd6fdb640dedb4c0de8fea2135c9271dbf3
parent0939249b408dce6ceab9c4637c2815b3b6f5f353 (diff)
Solve puzzle 9 part 1
I wasn't creating a new tail element after inserting the first tail, so when we revisited the origin the second time it didn't spot it as a dupe, giving an off-by-one error (The test input didn't have the tail pass the origin twice, so this wasn't an issue there)
-rw-r--r--9.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/9.c b/9.c
index d0c6a9f..bd19cae 100644
--- a/9.c
+++ b/9.c
@@ -50,6 +50,7 @@ main()
int ntails = 0;
tsearch(tail, &tails, point_tcmp);
+ tail = point_copy(tail);
++ntails;
fprintf(stderr, "Tail visiting %d,%d\n", tail->x, tail->y);