What the host pays
- O(1) · Trivial
- Free
- Python
- JavaScript
- operations
- division
Problem
You split the restaurant bill evenly, but in whole dollars: whatever is left over goes to whoever invited, on top of their own share.
Take total, the bill, and n, how many of you there are, and return what the host pays. A bill of 100 split three ways means everyone puts in 33 and the host pays 34. If it splits evenly, the host pays a share like everybody else.
Examples
100, 3 → 34
Splits evenly
120, 4 → 30
85, 2 → 43
Besides these, the challenge has hidden tests that are revealed when you submit your solution.
You start with this
Python
def host(total, n):
passJavaScript
function host(total, n) {
}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.