From 48966f12832ac97228132e56fb3159099f3e466e Mon Sep 17 00:00:00 2001 From: kartofen Date: Sun, 31 Jul 2022 11:55:45 +0300 Subject: cleanup --- Advent-of-Code-2021/AOC-1/aoc-1 | Bin 16640 -> 0 bytes Advent-of-Code-2021/AOC-1/aoc-1.c | 81 --------------------------------- Advent-of-Code-2021/AOC-1/aoc-1.c~ | 1 - Advent-of-Code-2021/AOC-1/input-1.txt~ | 0 Advent-of-Code-2021/AOC-1/main.c | 81 +++++++++++++++++++++++++++++++++ 5 files changed, 81 insertions(+), 82 deletions(-) delete mode 100755 Advent-of-Code-2021/AOC-1/aoc-1 delete mode 100644 Advent-of-Code-2021/AOC-1/aoc-1.c delete mode 100644 Advent-of-Code-2021/AOC-1/aoc-1.c~ delete mode 100644 Advent-of-Code-2021/AOC-1/input-1.txt~ create mode 100644 Advent-of-Code-2021/AOC-1/main.c (limited to 'Advent-of-Code-2021/AOC-1') diff --git a/Advent-of-Code-2021/AOC-1/aoc-1 b/Advent-of-Code-2021/AOC-1/aoc-1 deleted file mode 100755 index eb5fe13..0000000 Binary files a/Advent-of-Code-2021/AOC-1/aoc-1 and /dev/null differ diff --git a/Advent-of-Code-2021/AOC-1/aoc-1.c b/Advent-of-Code-2021/AOC-1/aoc-1.c deleted file mode 100644 index 5574481..0000000 --- a/Advent-of-Code-2021/AOC-1/aoc-1.c +++ /dev/null @@ -1,81 +0,0 @@ -#include -#include -#include - -#define N 5000 - -int numbers[N]; - -void ParseInput(char *filepath) -{ - char ch; - FILE *fp; - fp = fopen(filepath, "r"); - - if (fp == NULL) - { - perror("Error while opening the file.\n"); - exit(EXIT_FAILURE); - } - - int i = 0; - int n = 0; - char *str = malloc(sizeof(char)*N); - while((ch= fgetc(fp)) != EOF) - { - if(ch != '\n') - { - str[i] = ch; - i += 1; - } - else - { - i = 0; - numbers[n] = atoi(str); - n += 1; - memset(str, ' ', sizeof(char)*N); - } - } - - free(str); - - fclose(fp); -} - -void PrintNumbers() -{ - for(int i=0; i numbers[(i-1)]) - bigger += 1; - } - - printf("Answer: %d", bigger); - */ - - // Part Two - int bigger = 0; - for(int i = 3; i - (numbers[i-3] + numbers[i-2] + numbers[i -1])) - bigger += 1; - } - - printf("Answer: %d", bigger); - - return 0; -} diff --git a/Advent-of-Code-2021/AOC-1/aoc-1.c~ b/Advent-of-Code-2021/AOC-1/aoc-1.c~ deleted file mode 100644 index 4525d8c..0000000 --- a/Advent-of-Code-2021/AOC-1/aoc-1.c~ +++ /dev/null @@ -1 +0,0 @@ -#includ diff --git a/Advent-of-Code-2021/AOC-1/input-1.txt~ b/Advent-of-Code-2021/AOC-1/input-1.txt~ deleted file mode 100644 index e69de29..0000000 diff --git a/Advent-of-Code-2021/AOC-1/main.c b/Advent-of-Code-2021/AOC-1/main.c new file mode 100644 index 0000000..5574481 --- /dev/null +++ b/Advent-of-Code-2021/AOC-1/main.c @@ -0,0 +1,81 @@ +#include +#include +#include + +#define N 5000 + +int numbers[N]; + +void ParseInput(char *filepath) +{ + char ch; + FILE *fp; + fp = fopen(filepath, "r"); + + if (fp == NULL) + { + perror("Error while opening the file.\n"); + exit(EXIT_FAILURE); + } + + int i = 0; + int n = 0; + char *str = malloc(sizeof(char)*N); + while((ch= fgetc(fp)) != EOF) + { + if(ch != '\n') + { + str[i] = ch; + i += 1; + } + else + { + i = 0; + numbers[n] = atoi(str); + n += 1; + memset(str, ' ', sizeof(char)*N); + } + } + + free(str); + + fclose(fp); +} + +void PrintNumbers() +{ + for(int i=0; i numbers[(i-1)]) + bigger += 1; + } + + printf("Answer: %d", bigger); + */ + + // Part Two + int bigger = 0; + for(int i = 3; i + (numbers[i-3] + numbers[i-2] + numbers[i -1])) + bigger += 1; + } + + printf("Answer: %d", bigger); + + return 0; +} -- cgit v1.2.3