#253 · Python Basics · Beginner · 40 XP · about 8 min
A group finishes dinner and wants to split the bill evenly, tip included. Write split_bill(total_cents, tip_percent, people) that returns a list with the amount each person pays, in cents.
Work it out like this:
tip_percent percent of total_cents, rounded down to a whole cent.people people.The list has one amount per person, and the amounts add up to the total plus the tip.
split_bill(10000, 15, 3) # returns [3834, 3833, 3833] split_bill(2599, 10, 2) # returns [1429, 1429] split_bill(999, 20, 4) # returns [300, 300, 299, 299]
In the first example the tip is 1500 cents, so 11500 cents are shared by 3 people: 3833 each with 1 cent left over, which the first person pays. In the second, 10% of 2599 is 259.9, rounded down to 259.
0 <= total_cents <= 10000000 <= tip_percent <= 100, a whole number1 <= people <= 50First solves only, ranked by stars and then time.