The cards I get
- O(1) · Trivial
- Free
- Python
- JavaScript
- operations
- division
- conditionals
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):
passJavaScript
function myShare(deck, people, spot) {
}It opens in your browser, with the editor and the tests. It is free and you do not need an account to start.