You are to create an program that can play a version of a solitaire card game called "Accordian'' solitaire, the rules for which are as follows:
A standard playing deck is used. Deal cards one by one in a row from left to right, not overlapping. Whenever the card matches its immediate neighbor on the left, or matches the third card to the left, it may be moved onto that card. Cards match if they are of the same suit or same rank. After making a move, look to see if it has made additional moves possible. When a card is moved, all the cards in the pile are moved. Gaps between piles should be closed up as soon as they appear by moving all piles on the right of the gap one position to the left. Deal out the whole pack, combining cards towards the left whenever possible. The game is won if the pack is reduced to a single pile.
Situations can arise where more than one play is possible. Where two
cards may be moved, you should adopt the strategy of always moving the
leftmost card possible. Where a card may be moved either one position
to the left or three positions to the left, move it three positions.
of Accordian Solitaire.
Input data to the program specifies the cards for several games. Each line of input contains the the cards for a single game, in the order in which they are dealt from the pack. Each line may contain 1 to 52 cards separated by a single space. The line ends with "00" (double zeroes). The final line of the input file contains only double zeroes. Cards are represented as a two character code. The first character is the suit and the second character is the rank.
One line of output must be produced for line of input. Each line of output shows the cards remaining after playing a round of the game with the pack of cards as described by the corresponding input line.
C7 D7 H3 H5 00
D2 HK SJ C3 H3 00
H2 H3 H4 H5 HK DK D2 D3 D4 00
C7 C4 D9 ST CT S1 HT S9 C9 CQ D6 H7 S2 H5 S5 D3 DT C2 S4 SK H3 DJ C6 S8 C5 DK C8 SQ C1 H9 S7 D4 CJ S6 D2 D1 S3 D8 D7 DQ HQ HJ HK H4 CK H8 SJ C3 H2 H1 H6 D5 00
HE LL OW OR LD 00
D2 H3 SJ C3
H7 C5 H6
HE LL OR LD
||application produces correct output for all instructor test
||Program design is effectively decomposed into
well-defined, special-purpose functions
|15%||Algorithm design uses structured logic for decisions and loops.|
|15%||Coding standards are followed.|
|5%||Clean compile and link (no warnings using the required compiler flags).|
Remember, your program will be tested on Unix1. Code that does not compile will receive a grade of zero.
You need to submit your source code electronically using the
handin utility: No
late submittals will be accepted!
handin graderjd Project4 accordion.c (optional other files)
Accordion Project Function statement counts (instructor solution) 5 2 5 4 5 21 5 9 13 main - 8 total 77 Benefits? Easier testing. Easier debugging. Opportunities for reuse.