
Sort a in place by insertion and hand the whole array to report after every insertion, so the caller can watch the sorted prefix grow one slot at a time.
insertion_steps(a, 4, report) with a = {4, 3, 2, 1}Expected result
step: 3 4 2 1
step: 2 3 4 1
step: 1 2 3 4
calls: 3For your own tracking. Tests grade your code.
insertion_steps(a, 4, report) with a = {1, 2, 3, 4}Expected result
step: 1 2 3 4
step: 1 2 3 4
step: 1 2 3 4
calls: 3insertion_steps(a, 1, report) with a = {42}, then the bufferExpected result
calls: 0
arr: 42insertion_steps(a, 3, report) with a = {3, 1, 2, 99}, then the bufferExpected result
step: 1 3 2
step: 1 2 3
calls: 2
arr: 1 2 3 99Expected files
insertion_steps.cAllowed functions
None. Write every helper yourself.
Allowed headers

v0.40: Create exercises. Challenge the community.
Meet Studio →Sort a in place by insertion and hand the whole array to report after every insertion, so the caller can watch the sorted prefix grow one slot at a time.
insertion_steps(a, 4, report) with a = {4, 3, 2, 1}Expected result
step: 3 4 2 1
step: 2 3 4 1
step: 1 2 3 4
calls: 3For your own tracking. Tests grade your code.
insertion_steps(a, 4, report) with a = {1, 2, 3, 4}Expected result
step: 1 2 3 4
step: 1 2 3 4
step: 1 2 3 4
calls: 3insertion_steps(a, 1, report) with a = {42}, then the bufferExpected result
calls: 0
arr: 42insertion_steps(a, 3, report) with a = {3, 1, 2, 99}, then the bufferExpected result
step: 1 3 2
step: 1 2 3
calls: 2
arr: 1 2 3 99Expected files
insertion_steps.cAllowed functions
None. Write every helper yourself.
Allowed headers

Run the tests to grade your code
Build your code, then check each test here. Open a result to inspect its output.