-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
141 lines (131 loc) · 3.21 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#include <fstream>
#include <iostream>
#include <sstream>
#include <vector>
#include "day_1/Day1.h"
#include "day_10/Day10.h"
#include "day_11/Day11.h"
#include "day_12/Day12.h"
#include "day_13/Day13.h"
#include "day_14/Day14.h"
#include "day_15/Day15.h"
#include "day_16/Day16.h"
#include "day_17/Day17.h"
#include "day_18/Day18.h"
#include "day_19/Day19.h"
#include "day_2/Day2.h"
#include "day_20/Day20.h"
#include "day_21/Day21.h"
#include "day_22/Day22.h"
#include "day_23/Day23.h"
#include "day_24/Day24.h"
#include "day_25/Day25.h"
#include "day_3/Day3.h"
#include "day_4/Day4.h"
#include "day_5/Day5.h"
#include "day_6/Day6.h"
#include "day_7/Day7.h"
#include "day_8/Day8.h"
#include "day_9/Day9.h"
using namespace std;
int main() {
int day_input;
cout << "Input the day please: ";
cin >> day_input;
fstream file; // define the file
file.open("../day_" + to_string(day_input) + "/input.txt", ios::in); // open the file
vector<string> lines;
string line;
// throw an error if it does not open
if (!file.is_open()) {
cerr << "Error opening file" << endl;
return 1;
}
while (getline(file, line)) {
lines.push_back(line);
}
// close the file, not needed from this point on
file.close();
// this is far from pretty but is a nice and easy way to execute the different days
switch (day_input) {
case 1:
Day1::execute(lines);
break;
case 2:
Day2::execute(lines);
break;
case 3:
Day3::execute(lines);
break;
case 4:
Day4::execute(lines);
break;
case 5:
Day5::execute(lines);
break;
case 6:
Day6::execute(lines);
break;
case 7:
Day7::execute(lines);
break;
case 8:
Day8::execute(lines);
break;
case 9:
Day9::execute(lines);
break;
case 10:
Day10::execute(lines);
break;
case 11:
Day11::execute(lines);
break;
case 12:
Day12::execute(lines);
break;
case 13:
Day13::execute(lines);
break;
case 14:
Day14::execute(lines);
break;
case 15:
Day15::execute(lines);
break;
case 16:
Day16::execute(lines);
break;
case 17:
Day17::execute(lines);
break;
case 18:
Day18::execute(lines);
break;
case 19:
Day19::execute(lines);
break;
case 20:
Day20::execute(lines);
break;
case 21:
Day21::execute(lines);
break;
case 22:
Day22::execute(lines);
break;
case 23:
Day23::execute(lines);
break;
case 24:
Day24::execute(lines);
break;
case 25:
Day25::execute(lines);
break;
default:
cerr << "Error opening class corresponding to day" << endl;
return 1;
}
return 0;
}