AOC_2022/4/tuer4.c

62 lines
1.3 KiB
C
Raw Normal View History

#include <stdio.h>
#include <string.h>
int numarr_to_int(char numarr[2]) {
return (( (numarr[1] - '0') * 10 ) + (numarr[0] - '0'));
}
int main() {
2022-12-04 21:33:10 +01:00
FILE *input_file = fopen("./input.txt", "r");;
fseek(input_file, 0, SEEK_END);
int if_size = ftell(input_file);
fseek(input_file, 0, SEEK_SET);
char input[if_size];
2022-12-04 21:33:10 +01:00
char c[1];
int val_arr[4];
int pos = 0;
char tmp_num[2];
int tmp_pos = 0;
int fully = 0;
do {
c[0] = fgetc(input_file);
if((c[0] == (char)-1)) break;
2022-12-04 21:33:10 +01:00
if(c[0] = '-') {
tmp_pos = 0;
val_arr[pos] = numarr_to_int(tmp_num);
//printf("%i; %i; %i; %i\r\n", val_arr[0],val_arr[1],val_arr[2],val_arr[3]);
2022-12-04 21:33:10 +01:00
pos++;
continue;
2022-12-04 21:33:10 +01:00
}
if(c[0] = ',') {
tmp_pos = 0;
val_arr[pos] = numarr_to_int(tmp_num);
2022-12-04 21:33:10 +01:00
pos++;
continue;
2022-12-04 21:33:10 +01:00
}
if(c[0] = '\n') {
tmp_pos = 0;
pos = 0;
printf("%i; %i; %i; %i\r\n", val_arr[0],val_arr[1],val_arr[2],val_arr[3]);
if(val_arr[0]<val_arr[1] && val_arr[2]>val_arr[3]) fully++;
continue;
2022-12-04 21:33:10 +01:00
}
tmp_num[tmp_pos] = c[0];
tmp_pos++;
}
while(c[0] != (char)-1);
2022-12-04 21:33:10 +01:00
printf("~UwU Twying c todayw, awwen't we master? *^w^* Hewe is youww wesult: UmU~ : %i\r\n", fully);
return 0;
}