All challenges

Thursday, 5 November 2026

Past

Three rungs, one idea. Solving rung 1 counts. Climb as far as you can.

Rectangles And Tiles

functions + rectangle maths

Rung 1Daily goal5 points

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

InputOutput
3, 412
1, 11
0, 50
10, 10100

There are extra hidden tests, so make it work in general, not just for these.

Rung 2Bonus7 points

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

InputOutput
6, 4, 210
3, 3, 112
5, 2, 114
10, 5, 56

There are extra hidden tests, so make it work in general, not just for these.

Rung 3Bonus10 points

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

InputOutput
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.