Tanu and Head-bob Codechef Solution

Hello Programmers In this post, you will know how to solve the Tanu and Head-bob Codechef Solution. The Problem Code: HEADBOB

Tanu and Head-bob Codechef Solution
Tanu and Head-bob Codechef Solution

One more thing to add, don’t directly look for the solutions, first try to solve the problems of Codechef by yourself. If you find any difficulty after trying several times, then you can look for solutions.


Tanu has got interested in signs and gestures that we use for communication. One such gesture is the head-bob.
When we want to signal “Yes” to someone, we move the head up-and-down. For “No”, the head is moved left-and-right, rotating about the vertical axis.
There is a peculiar way of gesturing “Yes”, commonly seen in India, by moving head sideways (rotating about the forward-back axis). This is called the Indian head-bob.

Tanu observed many people on the railways station, and made a list of gestures that they made. Usual “Yes” gesture is recorded as “Y“, no as “N” and Indian “Yes” gesture as “I“. (Assume no foreigner uses the Indian “Yes” gesture and vice-versa). Identify which of them were Indians, which were not Indian, and which one you cannot be sure about.


First line contains T, number of people observed by Tanu.
Each person is described in two lines. First line of the description contains a single integer N, the number of gestures recorded for this person. Next line contains a string of N characters, each character can be “Y”, “N” or “I”.


For each person, print “INDIAN” if he/she is from India, “NOT INDIAN” if not from India, and “NOT SURE” if the information is insufficient to make a decision.


  • For 30 points: 1 ≤ T,N ≤ 100
  • For 70 points: 1 ≤ T,N ≤ 1000






Tanu and Head-bob CodeChef Solution in CPP

using namespace std;
string solve_test()
    int NO,YES, I, n=4;
    NO = YES = I = 0;
    cin >> n;
    string signs;
    cin >> signs;
    for(int i =0; i < n; i++)
        if(signs[i] == 'I')
            return "INDIAN";
        else if(signs[i] == 'Y')
            return "NOT INDIAN";
    return "NOT SURE";
int main()
    int t;
    cin >> t;
        cout << solve_test()<<endl;
    return 0;

Disclaimer: The above Problem (Tanu and Head-bob) generated by CodeChef but the solution is provided by BrokenProgrammers. This tutorial is only for Educational and Learning purpose.

Note:- I compile all programs, if there is any case program is not working and showing an error please let me know in the comment section. If you are using adblocker, please disable adblocker because some functions of the site may not work correctly.

Next: Processing a string Codechef Solution

Leave a Reply

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