From 4e9132b983c771d3e70d5a6b8bcdfdb1fead81fa Mon Sep 17 00:00:00 2001 From: kartofen Date: Mon, 1 Aug 2022 23:44:04 +0300 Subject: some more --- Advent-of-Code-2021/AOC-3-old/main.c | 86 ++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 Advent-of-Code-2021/AOC-3-old/main.c (limited to 'Advent-of-Code-2021/AOC-3-old/main.c') diff --git a/Advent-of-Code-2021/AOC-3-old/main.c b/Advent-of-Code-2021/AOC-3-old/main.c new file mode 100644 index 0000000..51cab24 --- /dev/null +++ b/Advent-of-Code-2021/AOC-3-old/main.c @@ -0,0 +1,86 @@ +#include +#include +#include +#include +#include + +#define N 5 +#define INP_COUNT 12 + +int table[N]; + +void ParseInput(char *filepath) +{ + char ch; + FILE *fp; + fp = fopen(filepath, "r"); + + if(fp == NULL) + { + fprintf(stderr, "ERROR: something with file idk what fuck you"); + exit(EXIT_FAILURE); + } + + int i = 0; + while((ch = fgetc(fp)) != EOF) + { + if(ch == '\n') { i = 0; continue; } + + if(ch == '1') + table[i] += 1; + + i += 1; + } + + fclose(fp); +} + +void PrintTable() +{ + for(int i=0; i (INP_COUNT/2)) + { + gamma_val = gamma_val | (1 << (N-1-i)); + } + } + + int epsilon_val = gamma_val; + for(int i=0; i