🎉」 init(2025): day 1

This commit is contained in:
2025-12-01 11:25:06 +01:00
commit 6306ab23d1
52 changed files with 2012 additions and 0 deletions

2
2025/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
*/input
*/a.out

31
2025/01/part1.c Normal file
View File

@@ -0,0 +1,31 @@
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
int main(void)
{
char *s = "L68\nL30\nR48\nL5\nR60\nL55\nL1\nL99\nR14\nL82\n";
/*char b[17100];
bzero(b, 17100);
FILE *f = fopen("input", "r");
fread(b, 1, 17100, f);
char *s = b;*/
int i = 0;
int c = 0;
int p = 50;
while(*s)
{
if (s[0] == 'R')
p = (p + atoi(&s[1])) % 100;
else if (s[0] == 'L')
p = (p - atoi(&s[1])) % 100;
if (p == 0) c++;
while (s[0] != '\n')
s++;
s++;
}
printf("result : %d\n", c);
}

47
2025/01/part2.c Normal file
View File

@@ -0,0 +1,47 @@
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
int main(void)
{
char *s = "L68\nL30\nR48\nL5\nR60\nL55\nL1\nL99\nR14\nL82\n";
/*char b[17100];
bzero(b, 17100);
FILE *f = fopen("input", "r");
fread(b, 1, 17100, f);
char *s = b;*/
int i = 0;
int c = 0;
int p = 50;
while(*s)
{
int m = atoi(&s[1]);
if (s[0] == 'R')
{
while (m)
{
p = (p + 1) % 100;
if (p == 0)
c++;
m--;
}
}
else if (s[0] == 'L')
{
while (m)
{
p = (p - 1) % 100;
if (p == 0)
c++;
m--;
}
}
while (s[0] != '\n')
s++;
s++;
}
printf("result : %d\n", c);
}