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 void puzzle(const char *filename, int *res1, int *res2);
      5 
      6 int main(int argc, char *argv[]) {
      7 	printf("Advent of Code: day 05\n");
      8 	double time_start = clock();
      9 
     10 	if (argc <= 0) {
     11 		return -1;
     12 	}
     13 	if (argc <= 1) {
     14 		printf("Usage: %s inputfile.txt\n", argv[0]);
     15 		return -1;
     16 	}
     17 
     18 	const char *filename = argv[1];
     19 
     20 	int counter1 = -1;
     21 	int counter2 = -1;
     22 
     23 	puzzle(filename, &counter1, &counter2);
     24 
     25 	printf("Puzzle #1: %d\n", counter1);
     26 	printf("Puzzle #2: %d\n", counter2);
     27 
     28 	double elapsed = clock() - time_start;
     29 	printf("Elapsed: %f\n", elapsed / CLOCKS_PER_SEC);
     30 
     31 	return 0;
     32 }