Back
Close
  • 122

Learning Opportunities

This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.

Statement

 Goal

You just have got into cardistry and discovered a shuffle named Faro shuffle
(See https://www.youtube.com/watch?v=YNim5GjQ610 for more details)


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.
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

A higher resolution is required to access the IDE