Thursday, 5 November 2026
PastThree rungs, one idea. Solving rung 1 counts. Climb as far as you can.
Rectangles And Tiles
functions + rectangle maths
How much floor
Write a function called rect_area
You get the width and the height of a rectangle, both whole numbers 0 or bigger. Return its area, which is the width times the height. A width of 3 and a height of 4 gives 12.
Examples
| Input | Output |
|---|---|
| 3, 4 | 12 |
| 1, 1 | 1 |
| 0, 5 | 0 |
| 10, 10 | 100 |
There are extra hidden tests, so make it work in general, not just for these.
Fence posts
Write a function called fence_posts
A fence goes right round the edge of the rectangle, with a post in every corner and another post every gap steps along each side. gap always divides both the width and the height exactly. A 6 by 4 rectangle with a gap of 2 needs 10 posts.
Examples
| Input | Output |
|---|---|
| 6, 4, 2 | 10 |
| 3, 3, 1 | 12 |
| 5, 2, 1 | 14 |
| 10, 5, 5 | 6 |
There are extra hidden tests, so make it work in general, not just for these.
Tiles that fit
Write a function called tiles_fit
Cover a width by height floor with square tiles that are side by side. Only whole tiles are used, laid in neat rows and columns, and none are cut. Return a list [tiles, uncovered]: how many tiles fit, and how much floor area is still bare. A 7 by 5 floor with 2 by 2 tiles fits 6 tiles and leaves 11 bare, so it gives [6, 11]. side is always 1 or more.
Examples
| Input | Output |
|---|---|
| 7, 5, 2 | [6, 11] |
| 4, 4, 2 | [4, 0] |
| 3, 3, 5 | [0, 9] |
| 6, 3, 1 | [18, 0] |
There are extra hidden tests, so make it work in general, not just for these.
Finish Rung 1 and today counts. Rungs 2 and 3 are there if you want to push further.