Day 6
This commit is contained in:
parent
b92b49fe98
commit
666fdea266
|
@ -0,0 +1,22 @@
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
string signal;
|
||||||
|
cin >> signal;
|
||||||
|
|
||||||
|
for (int i = 0; i < signal.size()-4; i++)
|
||||||
|
{
|
||||||
|
string segment = signal.substr(i,4);
|
||||||
|
sort(segment.begin(), segment.end());
|
||||||
|
if (segment.end() == std::unique(segment.begin(), segment.end()))
|
||||||
|
{
|
||||||
|
cout << i+4 << endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
string signal;
|
||||||
|
cin >> signal;
|
||||||
|
|
||||||
|
for (int i = 0; i < signal.size()-14; i++)
|
||||||
|
{
|
||||||
|
string segment = signal.substr(i,14);
|
||||||
|
sort(segment.begin(), segment.end());
|
||||||
|
if (segment.end() == std::unique(segment.begin(), segment.end()))
|
||||||
|
{
|
||||||
|
cout << i+14 << endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue