← All problemsSign in

Game of Cards

Problem description: Sonu got bored of playing Solitaire all day, and has invented a new game of cards that he can play by himself. He takes a shuffled deck of cards with R red cards and B black cards. In each turn, Sonu draws a card. A red card awards him with -r points, while a black card awards him with +b points. He can stop drawing cards at any point he wishes. Sonu believes there must be a

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