All challenges

Thursday, 12 November 2026

Past

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

Rounding Off

operators + rounding numbers

Rung 1Daily goal5 points

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

InputOutput
4740
4040
50
00

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

Rung 2Bonus7 points

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

InputOutput
4750
4440
4550
00

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

Rung 3Bonus10 points

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

InputOutput
47, 1050
130, 100100
9, 612
0, 20

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.