# Little Jhool and psychic powers Hackerearth coderinme

##### Little Jhool and psychic powers

Little Jhool always wanted to have some psychic powers so that he could showoff his skills, and magic to people and impress them. (Specially, his girlfriend Big Jhool!) But, in spite all his efforts, hardwork, dedication, Googling, watching youtube videos he couldn’t garner any psychic abilities!

He knew everyone was making fun of him, so to stop all of that – he came up with a smart plan. Anyone who came to him to know about their future, he asked them to write a binary number for him – and then, he smartly told them if the future for that person had good in store, or bad.

The algorithm which Little Jhool follows is, as following:

If the binary number written by the person has six consecutive
0
s
0s, or
1
s
Otherwise, he says that their future is good.
Input format:

Single line contains a binary number.

Output format:

You need to print “Good luck!” (Without quotes, and WITH exclamation mark!) if the Jhool is going to tell them that they’re going to have a good time. Else, print “Sorry, sorry!” if the person is going to be told that he’ll have a hard time!

Constraints:

The binary number will be in string format, with the maximum length being
100
100 characters.

I Method

```#include <iostream>
#include <string>
using namespace std;

int main()
{
string str;
int c=0;
cin>>str;
if(str.size()==1) {
cout<<"Good luck!";
return 0;
}
for (int i = 0; i < str.size()-2; i++){

if(str[i]==str[i+1])
c++;
else
c=0;
if(c==5) break;
}
if(c==5)
cout<<"Sorry, sorry!";
else
cout<<"Good luck!";
return 0;
}```

II Method

``````a = raw_input()
print 'Sorry, sorry!' if '0'*6 in a or '1'*6 in a else 'Good luck!'``````

III Method

```#include <bits/stdc++.h>

using namespace std;

int main()
{
string s;

cin >> s;

for(int i = 0; i + 6 <= s.size(); i++){

// check for 6 consecutive similar numbers

if(s[i] == s[i + 1] && s[i] == s[i + 2] && s[i] == s[i + 3] && s[i] == s[i + 4] && s[i] == s[i + 5]){

cout << "Sorry, sorry!";
return 0;
}
}

cout << "Good luck!";

return 0;
}```

### hasectic

A web developer(Front end and Back end), and DBA at csdamu.com. Currently working as Salesforce Developer @ Tech Matrix IT Consulting Private Limited. Check me @about.me/s.saifi