Cool puzzle bro
This commit is contained in:
parent
2eda698664
commit
907c70335a
@ -41,6 +41,9 @@ int main() {
|
|||||||
|
|
||||||
char map[((WIDTH + 1) * HEIGHT) + 1];
|
char map[((WIDTH + 1) * HEIGHT) + 1];
|
||||||
|
|
||||||
|
// Isn't it lovely?
|
||||||
|
char *christmas_tree = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; ; i++) {
|
for (i = 0; ; i++) {
|
||||||
strcpy(map, blank_map);
|
strcpy(map, blank_map);
|
||||||
@ -51,8 +54,7 @@ int main() {
|
|||||||
robots[j].py += robots[j].vy;
|
robots[j].py += robots[j].vy;
|
||||||
robots[j].py = (robots[j].py + HEIGHT) % HEIGHT;
|
robots[j].py = (robots[j].py + HEIGHT) % HEIGHT;
|
||||||
}
|
}
|
||||||
if (i == 7502) printf("Cycle %d\n%s\n\n", i, map);
|
if (strstr(map, christmas_tree) != NULL) break;
|
||||||
if (i == 7502) break;
|
|
||||||
|
|
||||||
if (i == CYCLES - 1) {
|
if (i == CYCLES - 1) {
|
||||||
for (int j = 0; j < robots_count; j++) {
|
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 1: %lld\n", q1 * q2 * q3 * q4);
|
||||||
printf("Part 2: %lld\n", i);
|
printf("Part 2: %lld\n", i);
|
||||||
|
Loading…
Reference in New Issue
Block a user