Thursday, 12 November 2026
PastThree rungs, one idea. Solving rung 1 counts. Climb as far as you can.
Rounding Off
operators + rounding numbers
Round down to a ten
Write a function called round_down_ten
Return the number rounded down to the ten below it, so 47 gives 40. A number that is already a multiple of ten stays as it is. The number is always 0 or bigger. Handy trick: // throws away the remainder when dividing.
Examples
| Input | Output |
|---|---|
| 47 | 40 |
| 40 | 40 |
| 5 | 0 |
| 0 | 0 |
There are extra hidden tests, so make it work in general, not just for these.
The nearest ten
Write a function called round_to_ten
Now round to the nearest ten, which is the closer one: 44 gives 40 and 47 gives 50. A number exactly halfway, such as 45, rounds up to 50. The number is always 0 or bigger.
Examples
| Input | Output |
|---|---|
| 47 | 50 |
| 44 | 40 |
| 45 | 50 |
| 0 | 0 |
There are extra hidden tests, so make it work in general, not just for these.
Any size you like
Write a function called round_to_nearest
Round n to the nearest multiple of size, so 130 with a size of 100 gives 100. A number exactly halfway rounds up, so 150 with a size of 100 gives 200. The size is always an even number, 2 or bigger, and n is 0 or bigger.
Examples
| Input | Output |
|---|---|
| 47, 10 | 50 |
| 130, 100 | 100 |
| 9, 6 | 12 |
| 0, 2 | 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.