setup 2021, remove loop from main
This commit is contained in:
10
src/2021/01.c
Normal file
10
src/2021/01.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "input.h"
|
||||
|
||||
void advent2021day01(void) {
|
||||
char *input = get_input("input/2021/01");
|
||||
printf("Solution for Day 01 of 2021 is not completed yet\n");
|
||||
free(input);
|
||||
}
|
10
src/2021/02.c
Normal file
10
src/2021/02.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "input.h"
|
||||
|
||||
void advent2021day02(void) {
|
||||
char *input = get_input("input/2021/02");
|
||||
printf("Solution for Day 02 of 2021 is not completed yet\n");
|
||||
free(input);
|
||||
}
|
10
src/2021/03.c
Normal file
10
src/2021/03.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "input.h"
|
||||
|
||||
void advent2021day03(void) {
|
||||
char *input = get_input("input/2021/03");
|
||||
printf("Solution for Day 03 of 2021 is not completed yet\n");
|
||||
free(input);
|
||||
}
|
10
src/2021/04.c
Normal file
10
src/2021/04.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "input.h"
|
||||
|
||||
void advent2021day04(void) {
|
||||
char *input = get_input("input/2021/04");
|
||||
printf("Solution for Day 04 of 2021 is not completed yet\n");
|
||||
free(input);
|
||||
}
|
10
src/2021/05.c
Normal file
10
src/2021/05.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "input.h"
|
||||
|
||||
void advent2021day05(void) {
|
||||
char *input = get_input("input/2021/05");
|
||||
printf("Solution for Day 05 of 2021 is not completed yet\n");
|
||||
free(input);
|
||||
}
|
10
src/2021/06.c
Normal file
10
src/2021/06.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "input.h"
|
||||
|
||||
void advent2021day06(void) {
|
||||
char *input = get_input("input/2021/06");
|
||||
printf("Solution for Day 06 of 2021 is not completed yet\n");
|
||||
free(input);
|
||||
}
|
10
src/2021/07.c
Normal file
10
src/2021/07.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "input.h"
|
||||
|
||||
void advent2021day07(void) {
|
||||
char *input = get_input("input/2021/07");
|
||||
printf("Solution for Day 07 of 2021 is not completed yet\n");
|
||||
free(input);
|
||||
}
|
10
src/2021/08.c
Normal file
10
src/2021/08.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "input.h"
|
||||
|
||||
void advent2021day08(void) {
|
||||
char *input = get_input("input/2021/08");
|
||||
printf("Solution for Day 08 of 2021 is not completed yet\n");
|
||||
free(input);
|
||||
}
|
10
src/2021/09.c
Normal file
10
src/2021/09.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "input.h"
|
||||
|
||||
void advent2021day09(void) {
|
||||
char *input = get_input("input/2021/09");
|
||||
printf("Solution for Day 09 of 2021 is not completed yet\n");
|
||||
free(input);
|
||||
}
|
10
src/2021/10.c
Normal file
10
src/2021/10.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "input.h"
|
||||
|
||||
void advent2021day10(void) {
|
||||
char *input = get_input("input/2021/10");
|
||||
printf("Solution for Day 10 of 2021 is not completed yet\n");
|
||||
free(input);
|
||||
}
|
10
src/2021/11.c
Normal file
10
src/2021/11.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "input.h"
|
||||
|
||||
void advent2021day11(void) {
|
||||
char *input = get_input("input/2021/11");
|
||||
printf("Solution for Day 11 of 2021 is not completed yet\n");
|
||||
free(input);
|
||||
}
|
10
src/2021/12.c
Normal file
10
src/2021/12.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "input.h"
|
||||
|
||||
void advent2021day12(void) {
|
||||
char *input = get_input("input/2021/12");
|
||||
printf("Solution for Day 12 of 2021 is not completed yet\n");
|
||||
free(input);
|
||||
}
|
10
src/2021/13.c
Normal file
10
src/2021/13.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "input.h"
|
||||
|
||||
void advent2021day13(void) {
|
||||
char *input = get_input("input/2021/13");
|
||||
printf("Solution for Day 13 of 2021 is not completed yet\n");
|
||||
free(input);
|
||||
}
|
10
src/2021/14.c
Normal file
10
src/2021/14.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "input.h"
|
||||
|
||||
void advent2021day14(void) {
|
||||
char *input = get_input("input/2021/14");
|
||||
printf("Solution for Day 14 of 2021 is not completed yet\n");
|
||||
free(input);
|
||||
}
|
10
src/2021/15.c
Normal file
10
src/2021/15.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "input.h"
|
||||
|
||||
void advent2021day15(void) {
|
||||
char *input = get_input("input/2021/15");
|
||||
printf("Solution for Day 15 of 2021 is not completed yet\n");
|
||||
free(input);
|
||||
}
|
10
src/2021/16.c
Normal file
10
src/2021/16.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "input.h"
|
||||
|
||||
void advent2021day16(void) {
|
||||
char *input = get_input("input/2021/16");
|
||||
printf("Solution for Day 16 of 2021 is not completed yet\n");
|
||||
free(input);
|
||||
}
|
10
src/2021/17.c
Normal file
10
src/2021/17.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "input.h"
|
||||
|
||||
void advent2021day17(void) {
|
||||
char *input = get_input("input/2021/17");
|
||||
printf("Solution for Day 17 of 2021 is not completed yet\n");
|
||||
free(input);
|
||||
}
|
10
src/2021/18.c
Normal file
10
src/2021/18.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "input.h"
|
||||
|
||||
void advent2021day18(void) {
|
||||
char *input = get_input("input/2021/18");
|
||||
printf("Solution for Day 18 of 2021 is not completed yet\n");
|
||||
free(input);
|
||||
}
|
10
src/2021/19.c
Normal file
10
src/2021/19.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "input.h"
|
||||
|
||||
void advent2021day19(void) {
|
||||
char *input = get_input("input/2021/19");
|
||||
printf("Solution for Day 19 of 2021 is not completed yet\n");
|
||||
free(input);
|
||||
}
|
10
src/2021/20.c
Normal file
10
src/2021/20.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "input.h"
|
||||
|
||||
void advent2021day20(void) {
|
||||
char *input = get_input("input/2021/20");
|
||||
printf("Solution for Day 20 of 2021 is not completed yet\n");
|
||||
free(input);
|
||||
}
|
10
src/2021/21.c
Normal file
10
src/2021/21.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "input.h"
|
||||
|
||||
void advent2021day21(void) {
|
||||
char *input = get_input("input/2021/21");
|
||||
printf("Solution for Day 21 of 2021 is not completed yet\n");
|
||||
free(input);
|
||||
}
|
10
src/2021/22.c
Normal file
10
src/2021/22.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "input.h"
|
||||
|
||||
void advent2021day22(void) {
|
||||
char *input = get_input("input/2021/22");
|
||||
printf("Solution for Day 22 of 2021 is not completed yet\n");
|
||||
free(input);
|
||||
}
|
10
src/2021/23.c
Normal file
10
src/2021/23.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "input.h"
|
||||
|
||||
void advent2021day23(void) {
|
||||
char *input = get_input("input/2021/23");
|
||||
printf("Solution for Day 23 of 2021 is not completed yet\n");
|
||||
free(input);
|
||||
}
|
10
src/2021/24.c
Normal file
10
src/2021/24.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "input.h"
|
||||
|
||||
void advent2021day24(void) {
|
||||
char *input = get_input("input/2021/24");
|
||||
printf("Solution for Day 24 of 2021 is not completed yet\n");
|
||||
free(input);
|
||||
}
|
10
src/2021/25.c
Normal file
10
src/2021/25.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "input.h"
|
||||
|
||||
void advent2021day25(void) {
|
||||
char *input = get_input("input/2021/25");
|
||||
printf("Solution for Day 25 of 2021 is not completed yet\n");
|
||||
free(input);
|
||||
}
|
68
src/main.c
68
src/main.c
@ -12,52 +12,38 @@
|
||||
#include "advent2018.h"
|
||||
#include "advent2019.h"
|
||||
#include "advent2020.h"
|
||||
#include "advent2021.h"
|
||||
|
||||
int main(void) {
|
||||
int day, year;
|
||||
int main(int argc, char** argv) {
|
||||
if (argc != 3) {
|
||||
printf("Usage: advent $YEAR $DAY\nExample: advent 15 1 will run Solution Day 01 of 2015\n\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int day = 0, year = 0;
|
||||
char buf[32];
|
||||
const char *errstr;
|
||||
const char *errstr = NULL;
|
||||
|
||||
printf("--- Advent of Code ---\n");
|
||||
year = strtonum(argv[1], 15, 21, &errstr);
|
||||
if (NULL != errstr) {
|
||||
printf("Input error: %s\n\n", errstr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
day = 0;
|
||||
year = 0;
|
||||
errstr = NULL;
|
||||
day = strtonum(argv[2], 1, 25, &errstr);
|
||||
if (NULL != errstr) {
|
||||
printf("Input error: %s\n\n", errstr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Enter a year (15-20). Enter 'q' to quit: ");
|
||||
scanf("%s", buf);
|
||||
|
||||
if (0 == strcmp(buf, "Q") || 0 == strcmp(buf, "q")) {
|
||||
break;
|
||||
}
|
||||
|
||||
year = strtonum(buf, 15, 20, &errstr);
|
||||
if (NULL != errstr) {
|
||||
printf("Input error: %s\n\n", errstr);
|
||||
continue;
|
||||
}
|
||||
|
||||
printf("Enter a day (1-25): ");
|
||||
scanf("%s", buf);
|
||||
day = strtonum(buf, 1, 25, &errstr);
|
||||
if (NULL != errstr) {
|
||||
printf("Input error: %s\n\n", errstr);
|
||||
continue;
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
|
||||
switch(year) {
|
||||
case 15: solutions2015[day-1](); break;
|
||||
case 16: solutions2016[day-1](); break;
|
||||
case 17: solutions2017[day-1](); break;
|
||||
case 18: solutions2018[day-1](); break;
|
||||
case 19: solutions2019[day-1](); break;
|
||||
case 20: solutions2020[day-1](); break;
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
switch(year) {
|
||||
case 15: solutions2015[day-1](); break;
|
||||
case 16: solutions2016[day-1](); break;
|
||||
case 17: solutions2017[day-1](); break;
|
||||
case 18: solutions2018[day-1](); break;
|
||||
case 19: solutions2019[day-1](); break;
|
||||
case 20: solutions2020[day-1](); break;
|
||||
case 21: solutions2021[day-1](); break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user