deck holds 2 · half cards. Split it into two halves: the first half cards and the last half cards.
Riffle them together: the first card of the first half, then the first card of the second half, then the second card of the first half, the second card of the second half, and so on. Return the resulting order of cards.deck=[1, 2, 3, 10, 20, 30], half=3 → [1, 10, 2, 20, 3, 30]
The first half is 1, 2, 3 and the second is 10, 20, 30. Taking one from each in turn gives 1, 10, 2, 20, 3, 30.
deck=[7, 7], half=1 → [7, 7]
Each half holds a single card, so the order stays the same.
half ≤ 500len(deck) = 2 · halfdeck[i] ≤ 10⁴deck=[1, 2, 3, 10, 20, 30], half=3
[1, 10, 2, 20, 3, 30]
Run checks the first 3 tests in your browser. Submit checks all 52 tests on the server, hidden ones included.