1
0

En realitat és la primera part del puzzle

This commit is contained in:
2025-12-02 23:55:10 +01:00
parent a75bc0f7ca
commit 3cb5ff77cc
6 changed files with 2 additions and 2 deletions

43
aoc_25_1_1/src/aoc25.c Normal file
View File

@@ -0,0 +1,43 @@
#include <stdio.h>
#include <string.h>
extern int left(int a, int b);
extern int right(int a, int b);
extern int count(int a, int b);
int main(void) {
int dial = 50;
int rotation;
char direction[2];
int password = 0;
FILE *fptr = fopen("aoc25_1_1.txt", "r");
if (fptr == NULL) {
printf("Error, puzzle input aoc25_1_1.txt not found\n");
return (1);
}
printf("DIAL starts at %d\n", dial);
while (fscanf(fptr, "%s %d", direction, &rotation) == 2) {
printf("DIRECTION %s ROTATION %d\n", direction, rotation);
if (strcmp(direction, "L") == 0) {
dial = left(dial, rotation);
printf("DIAL is now %d\n", dial);
}
if (strcmp(direction, "R") == 0) {
dial = right(dial, rotation);
printf("DIAL is now %d\n", dial);
}
password = count(password, dial);
printf("PASSWORD is now %d\n", password);
}
fclose(fptr);
return (0);
}