-
Notifications
You must be signed in to change notification settings - Fork 0
/
day6.cpp
45 lines (39 loc) · 906 Bytes
/
day6.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
#include <iostream>
#include "data.h"
std::map<char, std::string> getReplacements()
{
std::map<char, std::string> ret{};
return ret;
}
void process(Data& data)
{
std::map<char, int> counts;
int total = 0;
int total2 = 0;
int people = 0;
for(int i = 0; i < data.lines.size(); i++)
{
if (data.lines[i].words.size())
{
for(auto c: data.lines[i].words[0])
{
counts[c]++;
}
people++;
}
if(data.lines[i].words.size() == 0 || i == data.lines.size() - 1)
{
for(auto p: counts)
{
total++;
if (p.second == people)
{
total2++;
}
}
counts.clear();
people = 0;
}
}
std::cout << total << " " << total2 << std::endl;
}