From 907c70335ae320cbd111bed3c458bc780ddbdba0 Mon Sep 17 00:00:00 2001 From: Bill Rossi Date: Sat, 14 Dec 2024 01:19:51 -0500 Subject: [PATCH] Cool puzzle bro --- c/2024/14/restroom_redoubt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/c/2024/14/restroom_redoubt.c b/c/2024/14/restroom_redoubt.c index e2d546e..37b1380 100644 --- a/c/2024/14/restroom_redoubt.c +++ b/c/2024/14/restroom_redoubt.c @@ -41,6 +41,9 @@ int main() { char map[((WIDTH + 1) * HEIGHT) + 1]; + // Isn't it lovely? + char *christmas_tree = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; + int i; for (i = 0; ; i++) { strcpy(map, blank_map); @@ -51,8 +54,7 @@ int main() { robots[j].py += robots[j].vy; robots[j].py = (robots[j].py + HEIGHT) % HEIGHT; } - if (i == 7502) printf("Cycle %d\n%s\n\n", i, map); - if (i == 7502) break; + if (strstr(map, christmas_tree) != NULL) break; if (i == CYCLES - 1) { for (int j = 0; j < robots_count; j++) { @@ -65,6 +67,8 @@ int main() { } } + // Uncomment this to print the pretty christmas tree + // printf("%s\n", map); printf("Part 1: %lld\n", q1 * q2 * q3 * q4); printf("Part 2: %lld\n", i);