initial commit

This commit is contained in:
laura 2025-12-08 21:41:49 +01:00
commit 0bc074c0b3
11 changed files with 525 additions and 0 deletions

73
1/main.c Normal file
View file

@ -0,0 +1,73 @@
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <time.h>
char input[] =
{
#embed "input.txt"
,'\0' // null terminator
};
//char input[] = "L68\nL30\nR48\nL5\nR60\nL55\nL1\nL99\nR14\nL82\n";
int width = 0;
int height = 0;
int result = 0;
int parseNum(char* str){
int i = 0;
int out = 0;
while(str[i] != '\n'){
out += str[i]-0x30;
out *= 10;
i++;
}
out /=10;
return out;
}
int main(int argc, char *argv[]){
clock_t start, end;
start = clock();
int i = 0;
int num;
int position = 50;
while(input[i] != 0){
//printf("\n\n%.10s\n\n", &input[i+1]);
//sscanf(&input[i+1], "%d\n*", &num);
num = parseNum(&input[i+1]);
if(input[i] == 'L'){
position = (position + 10000 - num)%100;
}
else{
position = (position + num)%100;
}
if(position == 0){
result++;
}
//printf("%d, %d\n", num, position);
//fflush(stdout);
if(num<10){
i += 3;
} else if(num<100){
i += 4;
} else if(num<1000){
i += 5;
}
}
end = clock();
printf("count: %d\n", result);
clock_t ticks_taken = end - start;
double time_taken = ((double)ticks_taken)/CLOCKS_PER_SEC;
printf("time take: %f ticks\n", time_taken);
printf("CLOCKS_PER_SEC: %ld\n", CLOCKS_PER_SEC);
exit(1);
}