Editor

Cans of Paint

#534 · Python Basics · Beginner · 30 XP · about 4 min

You are painting a wall that is width meters wide and height meters high, and one can of paint covers coverage square meters. Write paint_cans(width, height, coverage) that returns how many cans to buy.

The store sells whole cans only, so if the wall needs part of a can, that part counts as a whole can. A wall that needs exactly 2 cans of paint needs 2 cans, not 3.

Examples

paint_cans(4, 2.5, 5)  # returns 2
paint_cans(4, 3, 5)    # returns 3
paint_cans(3, 2, 10)   # returns 1

In the second example the wall is 4 * 3 = 12 square meters, which is 2.4 cans of paint, so you buy 3.

Note

coverage is always more than 0. A wall with no area needs 0 cans.

Fastest solvers

Leaderboard

First solves only, ranked by stars and then time.