summaryrefslogtreecommitdiff
path: root/011.c
diff options
context:
space:
mode:
authorVincent Douillet <vincent@vdouillet.fr>2021-12-03 17:01:37 +0100
committerVincent Douillet <vincent@vdouillet.fr>2021-12-03 17:01:37 +0100
commit736823f313bd2e00e49a1b52aaf0ea68a79db438 (patch)
tree5cf54f57e5c2afd8ea22baacb3ffa05a76a59fcc /011.c
parent04e79fa276ae1c3620868d85941b2c7b7c11222a (diff)
improve input handling & merge part 1 and 2 for the first days
Diffstat (limited to '011.c')
-rw-r--r--011.c32
1 files changed, 0 insertions, 32 deletions
diff --git a/011.c b/011.c
deleted file mode 100644
index 4af029f..0000000
--- a/011.c
+++ /dev/null
@@ -1,32 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include "input.h"
-
-#define INPUT "input/01.txt"
-
-int main() {
- // lecture du fichier d'entree
- FILE* file=fopen(INPUT,"r");
- if(file == NULL) {
- printf("Le fichier %s n'existe pas\n", INPUT);
- return -1;
- }
- size_t lineCount = count_lines(file);
- int* input = malloc(lineCount * sizeof(int));
- if(read_lines_as_int(file, input, lineCount) != 0) {
- printf("Erreur de parsing du fichier\n");
- return -1;
- }
- // fermeture du fichier
- fclose(file);
-
- // calcul des variations de profondeur
- int result = 0;
- for(size_t i = 1; i < lineCount; i++) {
- if(input[i] > input[i-1])
- result++;
- }
- printf("%d\n", result);
-
- return 0;
-}