-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday5a.cpp
More file actions
94 lines (85 loc) · 1.59 KB
/
Copy pathday5a.cpp
File metadata and controls
94 lines (85 loc) · 1.59 KB
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
#include <string>
#include <vector>
#include <sstream>
#include <fstream>
#include <cassert>
namespace day5a
{
int main()
{
std::string input0;
//std::ifstream ifile("day5_sample.txt");
std::ifstream ifile("day5.txt");
if (ifile.is_open())
{
while (!ifile.eof())
{
std::string line;
std::getline(ifile, line);
input0 += line + '\n';
}
assert(input0.back() == '\n');
input0.pop_back(); // no trailing newline character please
//__debugbreak();
}
else
{
assert(0);
}
std::vector<std::string> values;
std::string temp;
for (char c : input0)
{
if (c == '\n')
{
values.push_back(temp);
temp = "";
continue;
}
temp += c;
}
values.push_back(temp);
std::vector<std::pair<uint64_t, uint64_t>> data1;
std::vector<uint64_t> data2;
bool phase_two = false;
for (int i = 0; i < values.size(); i++)
{
if (values[i] == "")
phase_two = true;
if (!phase_two)
{
std::istringstream ss{ values[i] };
uint64_t v1;
char c1;
uint64_t v2;
ss >> v1;
ss >> c1;
ss >> v2;
data1.emplace_back(v1, v2);
}
else
{
std::istringstream ss{ values[i] };
uint64_t v1;
ss >> v1;
data2.emplace_back(v1);
}
}
int fresh = 0;
for (int i = 0; i < data2.size(); i++)
{
uint64_t id = data2[i];
for (int j = 0; j < data1.size(); j++)
{
auto& r = data1[j];
if (r.first <= id && r.second >= id)
{
fresh++;
break;
}
}
}
__debugbreak();
return 0;
}
}