From 4291faa39d4aad4a9cfed55600d32403422a2d4b Mon Sep 17 00:00:00 2001 From: Adam Spragg Date: Fri, 9 Dec 2022 16:56:52 +0000 Subject: 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) --- 9.c | 1 + 1 file changed, 1 insertion(+) 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); -- cgit v1.2.1