Skip to main content
Skip to content

Conditions · Beginner

Number Guessing Game Logic in Hinglish

Higher / lower hints for a list of guesses, stopping with bhang.

The program

Edit anything and press Run. The output below was produced by running this exact code.

Expected output

Press Run to try it

Guess 1 : 50 -> Bahut bada, thoda kam karoGuess 2 : 25 -> Bahut chhota, thoda badhaoGuess 3 : 40 -> Bahut bada, thoda kam karoGuess 4 : 33 -> Bahut chhota, thoda badhaoGuess 5 : 37 -> Sahi jawab! 🎉

How it works

The guesses come from a fixed list so the run is repeatable — each one is compared with secret and gets a too-big or too-small hint. Notice how the guesses close in on the answer by halving the gap, the same idea as binary search.

When a guess matches, the program records mila = sahi and bhang leaves the loop, so the last guess in the list is never checked. The final agar (!mila) only prints if nothing matched.

To make it interactive, replace the list with pucho() calls — the input lesson shows how.