Skip to content
Programming101
Programming101

Learn everything about programming

  • Home
  • CS Subjects
    • IoT – Internet of Things
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programming101
Programming101

Learn everything about programming

HackerEarth Little Jhool and psychic powers problem solution

YASH PAL, 31 July 2024
In this HackerEarth Little Jhool and psychic powers problem solution Little Jhool always wanted to have some psychic powers so that he could show off his skills, and magic to people and impress them. (Especially, his girlfriend Big Jhool!) But, in spite of all his efforts, hard work, 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 follows:
If the binary number written by the person has six consecutive 0s or 1s, his future is bad.
Otherwise, he says that their future is good.
HackerEarth Little Jhool and psychic powers problem solution

HackerEarth Little Jhool and psychic powers problem solution.

#include <bits/stdc++.h>

using namespace std;

int main()
{
string s;

cin >> s;

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

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;
}

Second solution

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

Post navigation

Previous post
Next post
  • HackerRank Separate the Numbers solution
  • How AI Is Revolutionizing Personalized Learning in Schools
  • GTA 5 is the Game of the Year for 2024 and 2025
  • Hackerrank Day 5 loops 30 days of code solution
  • Hackerrank Day 6 Lets Review 30 days of code solution
©2025 Programming101 | WordPress Theme by SuperbThemes