# Question 1 You are given a deck containing N cards. While holding the deck facedown: 1. Deal all the cards facedown onto a table into Y piles like you would if you were playing with a group of people (i.e. card 1 to P1, card 2 to P2, …, card Y to PY, card Y + 1 to P1, etc). 2. Combine all the piles into a deck by placing P1 onto P2, then P1+P2 onto P3, and so on. This is a round. 3. Pick up the deck from the table and repeat steps 1-2 until the deck is in the original order. 4. For each round, vary the pile count according to a repeating pattern. Start with 3 piles, then 4, then 5, then loop back to 3, then 4 and so on. Write a program to determine how many rounds it will take to put a deck back into the original order. . This program should be written in It should take a number of cards in the deck as a command line argument and write the result to stdout. Please ensure the program compiles and runs correctly (no pseudo-code). This isn’t a trick question; it should be fairly straightforward.

In order to determine the number of rounds it will take to put a deck back into the original order, we need to first understand the process described in the question.

The process starts with a deck of N cards, which are initially facedown. The cards are then dealt onto a table into Y piles, following the pattern of card 1 to pile 1, card 2 to pile 2, and so on until card Y. The process continues by placing card Y + 1 on pile 1, card Y + 2 on pile 2, and so on, until all the cards have been dealt.

After all the cards have been dealt, the piles are combined by placing pile 1 onto pile 2, then pile 1+2 onto pile 3, and so on, until all the piles have been combined into a single deck again. This completes one round of the process.

Now, according to the question, the pile count varies in each round according to a repeating pattern. The pattern starts with 3 piles, then progresses to 4 piles, then 5 piles, and loops back to 3 piles. This pattern continues indefinitely.

To determine the number of rounds it will take to put the deck back into the original order, we can simulate the process and count the number of rounds until we find the original order.

A possible approach to implementing this program in a programming language such as C++ is as follows:

1. Accept the number of cards in the deck as a command-line argument.

2. Initialize a variable to keep track of the number of rounds, set it to 0.

3. Generate a repeating pattern of pile counts (3, 4, 5, 3, 4, 5, …) using a loop.

4. Start a loop that continues until the deck is in the original order.

5. Within the loop, follow the process described in the question: deal the cards into piles, combine the piles, and increment the round count.

6. After each round, check if the deck is in the original order. If it is, exit the loop.

7. Print the number of rounds to stdout.

It is important to note that the implementation details may vary depending on the programming language being used, but the overall logic described above should be applicable.

### Need your ASSIGNMENT done? Use our paper writing service to score better and meet your deadline.

Click Here to Make an Order Click Here to Hire a Writer