← All problemsSign in

The Cunning Space Traveller

An old space traveller is trying to trick the children of planet Naboo with an old trick. He has a hat full of a fixed number of black(B) and white(W) balls. He then asks one of the younglings to pick up a pair of balls from the hat at random. If they are of the same color, he asks the youngling to place a new white ball back into the hat, otherwise a new black ball is placed into the hat. This c

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start