advent2021

Advent of Code 2021 Solutions
git clone git://bsandro.tech/advent2021
Log | Files | Refs | README | LICENSE

main.c (616B)


      1 #include <stdio.h>
      2 #include <time.h>
      3 
      4 int puzzle1(const char *filename);
      5 int puzzle2(const char *filename);
      6 
      7 int main(int argc, char *argv[]) {
      8 	printf("Advent of Code: day 01\n");
      9 	double time_start = clock();
     10 
     11 	if (argc <= 0) {
     12 		return -1;
     13 	}
     14 	if (argc <= 1) {
     15 		printf("Usage: %s inputfile.txt\n", argv[0]);
     16 		return -1;
     17 	}
     18 
     19 	const char *filename = argv[1];
     20 
     21 	int counter1 = puzzle1(filename);
     22 	printf("Puzzle #1: %d\n", counter1);
     23 	int counter2 = puzzle2(filename);
     24 	printf("Puzzle #2: %d\n", counter2);
     25 
     26 	double elapsed = clock() - time_start;
     27 	printf("Elapsed: %f\n", elapsed / CLOCKS_PER_SEC);
     28 
     29 	return 0;
     30 }