Faro shuffle
Statement
Goal
You just have got into cardistry and discovered a shuffle named Faro shuffle(See
Faro shuffle is done as follow:
1. Split the deck of cards into two decks of the same size.
(If the original deck has an odd number of cards the first deck will have one more card than the second deck)
2. Merge the two decks picking alternatively one card from each, starting with the first deck.
You grab a fresh deck of cards and start practicing this shuffle.
After a while, you wonder if you can create a trick based on this shuffle, a pattern might emerged if you do it a certain number of times.
Given a deck of cards, print out the resulting deck after N shuffles.
Input
Line 1: An integer N for the number of Faro shuffle to perform.
Line 2: Space separated cards.
Line 2: Space separated cards.
Output
A single line representing the deck of cards gone through N Faro shuffles.
Constraints
1 ≤ N ≤ 100
Example
Input
1 AS AH AD AC
Output
AS AD AH AC
Tags
Loops
Difficulty
Easy
Test cases
Aces Test
Input
1
AS AH AD AC
Output
AS AD AH AC
Validator 1 Validator
Input
1
AH AS AC AD
Output
AH AC AS AD
Odd number of cards Test
Input
1
2S 5D QH 3S 4S JH JD 5S KH
Output
2S JH 5D JD QH 5S 3S KH 4S
Validator 2 Validator
Input
1
2D 3D 4D 5D 6D
Output
2D 5D 3D 6D 4D
Multiple shuffles Test
Input
10
KS KC 4S 5D 7H KH AH 9D QH 8S 5C JH QS 3S AS KD 6D 5H 5S JS
Output
KS 8S 5S QH 5H 9D 6D AH KD KH AS 7H 3S 5D QS 4S JH KC 5C JS
Validator 3 Validator
Input
10
KS KC 4S 5D 7H KH AH 9D QH 8S 5C JH QS 3S AS KD 6D 5H 5S
Output
KS 8S 5S QH 5H 9D 6D AH KD KH AS 7H 3S 5D QS 4S JH KC 5C
Fresh deck Test
Input
52
AS 2S 3S 4S 5S 6S 7S 8S 9S 10S JS QS KS AH 2H 3H 4H 5H 6H 7H 8H 9H 10H JH QH KH KC QC JC 10C 9C 8C 7C 6C 5C 4C 3C 2C AC KD QD JD 10D 9D 8D 7D 6D 5D 4D 3D 2D AD
Output
AS 4H 7C 4D AH 10C 7D JS KC 10D 8S JH KD 5S 8H 3C 2S 5H 6C 3D 2H 9C 6D QS QC 9D 9S QH QD 6S 9H 2C 3S 6H 5C 2D 3H 8C 5D KS JC 8D 10S KH JD 7S 10H AC 4S 7H 4C AD
Validator 4 Validator
Input
100
10S 8C 10D 2C 9C AC AS 6C QD QH 8S 5H 7D KC 3S JC 3H 10H 4S QC JS 6H 5D 9D QS 7C 9H 5S 10C 5C 4C 2H 8D 2D JH 9S 7H 6S KD 2S AH JD 6D 3D 8H AD 4H 7S 3C KS 4D KH
Output
10S 3H 8D 3C KC 5C AD 8S 9H 6D 6C 9D 2S 9C JS 7H 8C 10H 2D KS 3S 4C 4H 5H 5S 3D QD QS AH AC 6H 6S 10D 4S JH 4D JC 2H 7S 7D 10C 8H QH 7C JD AS 5D KD 2C QC 9S KH
Solution language
Solution
Stub generator input