All challenges

Thursday, 15 October 2026

Past

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

Merging Two Lists

lists + walking two at once

Rung 1Daily goal5 points

One from each, turn about

Write a function called merge_alternately

Take the first item of a, then the first of b, then the second of a, and so on. When one list runs out, add everything left in the other. So [1, 2, 3] and [9, 8] give [1, 9, 2, 8, 3]. Two empty lists give an empty list.

Examples

InputOutput
[1, 2, 3], [9, 8][1, 9, 2, 8, 3]
[], [][]
[1], [][1]
[], [5, 6][5, 6]

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

Rung 2Bonus7 points

Two by two

Write a function called make_pairs

Now pair them up instead: return a list of small lists, each holding one item from a and the item at the same position in b. Stop as soon as either list runs out, so anything left over is ignored. [1, 2, 3] and [9, 8] give [[1, 9], [2, 8]].

Examples

InputOutput
[1, 2, 3], [9, 8][[1, 9], [2, 8]]
[], [1][]
[1], [2][[1, 2]]
[1, 2], [3, 4][[1, 3], [2, 4]]

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

Rung 3Bonus10 points

Keep them in order

Write a function called merge_sorted

Both lists are already sorted smallest to largest. Build one sorted list out of them by always taking whichever front item is smaller, and when the two are equal take the one from a first. Handy trick: a[i:] gives you the part of a from position i to the end, which is exactly what is left over once the other list runs out.

Examples

InputOutput
[1, 3, 5], [2, 4][1, 2, 3, 4, 5]
[], [][]
[1, 2], [][1, 2]
[1, 1], [1][1, 1, 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.