-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay6part1.cpp
More file actions
78 lines (70 loc) · 1.29 KB
/
Copy pathDay6part1.cpp
File metadata and controls
78 lines (70 loc) · 1.29 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
#include <iostream>
#include <fstream>
#include <vector>
#include<string>
using namespace std;
void getcount(string s,vector<int>&v2)
{
vector<char>v;
for (int i = 0; i < s.length(); i++)
{
v.push_back(s[i]);
}
sort(v.begin(), v.end());
int k = 1;
for (int i = 1; i < s.length(); i++)
{
if (v[i] == v[i - 1])
{
continue;
}
else if (v[i] != v[i - 1])
{
k++;
}
}
v2.push_back(k);
}
int main()
{
string p;
string word = "";
vector<string>v;
vector<string>v1;
ifstream indata;
indata.open("Day6data");
if(indata.fail())
{
cout<<"something is wrong"<<endl;
}
while (getline(indata, p))
{
v.push_back(p);
}
int k=0;
for(int i=0;i<2196;i++)
{
if(v[i].empty())
{
v1.push_back(word);//clubbing all charecters in group
word="";
k=0;
}
else{
word=word.append(v[i]);
k++;
}
}
vector<int>v3;
for(int i=0;i<v1.size();i++)
{
getcount(v1[i],v3);
}
int sum=0;
for(int i=0;i<v1.size();i++)
{
sum=sum+v3[i];
}
cout<<"Part1 : "<<sum<<endl;
return 0;
}