Skip to the content

The tiles that fit

Problem

You're covering a wall tall by wide centimeters with square tiles of side centimeters. They go up in even rows and you can't cut them: the strip left over at the edge stays bare.

Write a function that returns how many whole tiles fit.

On a wall 10 by 9 with tiles of 4, four tiles fit: two rows of two.

If the tile is bigger than the wall, none fits and you return 0.

Examples

  • An exact wall

    10, 8, 2 → 20

  • Leftovers on both edges

    10, 9, 4 → 4

  • The tile doesn't fit

    5, 3, 6 → 0

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

You start with this

Python

def tiles(tall, wide, side):
    pass

JavaScript

function tiles(tall, wide, side) {
}
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 →