Trains the technique from
LeetCode 2591Distribute Money to Maximum ChildrenThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
An arcade attendant has tokens tokens to hand out across players players waiting at the counter. The house rules are:
A player who leaves with exactly eight tokens is also given a free badge.
Return the largest number of badges the attendant can award. If no handout satisfies all three rules, return -1.
Example 1
Handing eight tokens to each player uses all 24, gives everyone at least one and leaves nobody on exactly four, so all three players collect a badge.
Example 2
Handing out eight and two tokens uses all ten, gives both players at least one and leaves neither on exactly four. One player holds eight, so one badge is awarded.
Example 3
Handing out five and seven tokens uses all twelve, gives both players at least one and leaves neither on exactly four. Neither player holds eight, so no badge is awarded.
Example 4
One token cannot give two players at least one each, so no handout satisfies the rules.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def most_badges(tokens: int, players: int) -> int:public int mostBadges(int tokens, int players)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.