Skip to the content

The cards I get

Problem

The whole deck gets dealt out, one card at a time, going around the table from seat 1. When there aren't enough left for another full lap, the rest go to the first seats, one card each.

Write a function that takes how many cards the deck has, how many players there are and which seat you're in (the first one is seat 1), and returns how many cards you get. If the deck can't give one to everybody, the last seats get 0.

Examples

  • First seat

    10, 4, 1 → 3

  • The last seat with an extra

    10, 4, 2 → 3

  • The first seat without one

    10, 4, 3 → 2

  • The deck comes out even

    12, 4, 4 → 3

Besides these, the challenge has hidden tests that are revealed when you submit your solution.

You start with this

Python

def my_share(deck, people, spot):
    pass

JavaScript

function myShare(deck, people, spot) {
}
Solve this challenge

It opens in your browser, with the editor and the tests. It is free and you do not need an account to start.

More O(1) challenges

See all challenges →