Skip to content
Programmingoneonone
Programmingoneonone
  • Engineering Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
    • 100+ C++ Programs
  • Solutions
    • HackerRank
      • Algorithms Solutions
      • C solutions
      • C++ solutions
      • Java solutions
      • Python solutions
    • Leetcode Solutions
    • HackerEarth Solutions
  • Work with US
Programmingoneonone
Programmingoneonone

HackerEarth Little Jhool and psychic powers problem solution

YASH PAL, 31 July 202413 February 2026
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 solutions HackerEarth HackerEarth

Post navigation

Previous post
Next post

Leave a Reply

Your email address will not be published. Required fields are marked *

Programmingoneonone

We at Programmingoneonone, also known as Programming101 is a learning hub of programming and other related stuff. We provide free learning tutorials/articles related to programming and other technical stuff to people who are eager to learn about it.

Pages

  • About US
  • Contact US
  • Privacy Policy

Practice

  • Java
  • C++
  • C

Follow US

  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2026 Programmingoneonone | WordPress Theme by SuperbThemes