-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdayX-template.cpp
More file actions
39 lines (34 loc) · 778 Bytes
/
dayX-template.cpp
File metadata and controls
39 lines (34 loc) · 778 Bytes
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
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int part1(string filename);
void print_result(string msg, int actual, int expected);
int main()
{
int result;
result = part1("dayX-test-data");
print_result("P1 test: ", result, 0);
result = part1("dayX-data");
print_result("P1 actual: ", result, 2);
}
int part1(string filename)
{
ifstream data(filename);
int result = 0;
string line;
while (getline(data, line))
{
}
return result;
}
void print_result(string msg, int actual, int expected)
{
cout << msg << "Actual " << actual << " Expected " << expected;
int diff = actual - expected;
if (expected < 0 && diff != 0)
{
cout << " Diff " << diff;
}
cout << endl;
}