Scratchy finished first, but admittedly needed 6 tries to get the right answer to part 2.The day 1 puzzle has opened, but the mice are nonfunctional after the singing and everyone is tired. I'll post solutions as they come in.
Code:
$ ./day01-cAdvent of Code 2025 Day 1 Secret Entrance (c)Part 1 The actual password is 997Part 2 Following method 0x434C49434B gives 5978Total execution time 0.000571019 seconds.Code:
/* Advent of Code 2025 Day 1 Secret Entrance (c) Written December 2025 by Eric Olson */#include <stdio.h>#include <stdlib.h>#include <time.h>static struct timespec tic_start;void tic(){ clock_gettime(CLOCK_MONOTONIC_RAW,&tic_start);}double toc(){ struct timespec tic_stop; clock_gettime(CLOCK_MONOTONIC_RAW,&tic_stop); double sec=tic_stop.tv_sec-tic_start.tv_sec; return sec+(tic_stop.tv_nsec-tic_start.tv_nsec)*1.0e-9;}void dowork(){ FILE *fp=fopen("day01.txt","r"); int p1=0,p2=0; int d=50; while(!feof(fp)){ char c; int x; if(fscanf(fp,"%c%d\n",&c,&x)!=2) break; int r; switch(c){case 'L': if(d>0){ d-=x; r=(100-d)/100; } else { d-=x; r=-d/100; } d=(d%100+100)%100; break;case 'R': d+=x; r=d/100; d%=100; break;default: fprintf(stderr,"Unknown direction %c!\n",c); exit(1); } if(d==0) p1++; p2+=r; } fclose(fp); printf("Part 1 The actual password is %d\n",p1); printf("Part 2 Following method 0x434C49434B gives %d\n",p2);}int main(){ printf("Advent of Code 2025 Day 1 Secret Entrance (c)\n\n"); tic(); dowork(); double t=toc(); printf("\nTotal execution time %g seconds.\n",t); exit(0);} Statistics: Posted by ejolson — Mon Dec 01, 2025 10:10 am