All challenges

Tuesday, 24 November 2026

Past

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

Counting Pence

functions + whole pence

Rung 1Daily goal5 points

What it costs

Write a function called cost_of

One sweet costs price pence. Return how many pence count sweets cost. 4 sweets at 25 pence each cost 100 pence, and buying none costs 0.

Examples

InputOutput
25, 4100
60, 00
99, 199
5, 315

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

Rung 2Bonus7 points

Change from a note

Write a function called change_for

You hand over paid pence for count sweets that cost price pence each. Return your change in pence. Paying exactly the right amount gives 0, and if you did not pay enough, return None.

Examples

InputOutput
500, 120, 3140
200, 50, 40
100, 60, 2None
1000, 0, 51000

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

Rung 3Bonus10 points

Splitting the bill

Write a function called split_bill

A bill of total pence is shared between people people, and everyone pays whole pence. Return a list of what each person pays. Shares are as equal as possible, and any left-over pence are paid one each by the first people in the list. 100 pence between 3 people gives [34, 33, 33]. people is always 1 or more.

Examples

InputOutput
100, 3[34, 33, 33]
90, 3[30, 30, 30]
5, 1[5]
7, 4[2, 2, 2, 1]

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.