advent2021

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

main.c (630B)


      1 #include <stdio.h>
      2 #include <time.h>
      3 
      4 void puzzle(const char *filename, size_t *res1, size_t *res2);
      5 
      6 int main(int argc, char *argv[]) {
      7 	printf("Advent of Code: day 06\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 	size_t counter1 = -1;
     21 	size_t counter2 = -1;
     22 
     23 	puzzle(filename, &counter1, &counter2);
     24 
     25 	printf("Puzzle #1: %zu\n", counter1);
     26 	printf("Puzzle #2: %zu\n", counter2);
     27 
     28 	double elapsed = clock() - time_start;
     29 	printf("Elapsed: %f\n", elapsed / CLOCKS_PER_SEC);
     30 
     31 	return 0;
     32 }