cards in no particular order.
The trick repeats while any cards are left in hand:
1. Turn over the top card and put it on the table.
2. If the deck is not empty, take the next top card without looking and slide it under the bottom of the deck.
Arrange the deck so the cards come out in strictly increasing order. Return that deck as a list, with the top card first.cards=[40, 10, 30, 20] → [10, 30, 20, 40]
Deck [10, 30, 20, 40]: show 10, move 30 down → [20, 40, 30]; show 20, move 40 down → [30, 40]; show 30, move 40 down → [40]; show 40. The order is 10, 20, 30, 40.
cards=[9, 4, 7] → [4, 9, 7]
Deck [4, 9, 7]: show 4, move 9 down → [7, 9]; show 7, move 9 down → [9]; show 9.
cards=[5] → [5]
cards are distinctcards=[40, 10, 30, 20]
[10, 30, 20, 40]
Run checks the first 3 tests in your browser. Submit checks all 75 tests on the server, hidden ones included.