Test a Sorted List Merge
Write the tests · Advanced · about 15 min
merge(a, b) takes two lists of numbers, each sorted from smallest to largest, and returns a new sorted list holding every item from both, duplicates included. It must not change a or b.
Write test_ functions with assert that pass on a correct version and fail on broken ones.
Examples
merge([1, 4], [2, 3]) # [1, 2, 3, 4] merge([5], []) # [5]
def test_interleaved():
assert merge([1, 4], [2, 3]) == [1, 2, 3, 4]
The solution opens after your first Check.