Starting from:

$29

Exercise 9– Crazy Eights 

Exercise 9– Crazy Eights 
          (2 marks) 
For this exercise, you are to solve the crazy eights puzzle using Dynamic Programming as presented 
in the week 10B lecture. 
As usual, your program will prompt for the name of an input file and the read and process the data 
contained in this file. 
The file contains the following data.  
52 lines each containing the identity of a playing card in the form RS, where R is the Rank of the card 
(A, 2, 3, 4, 5, 6, 7, …, 10, J, Q, K) and S is the Suit (C, D, H, S).  
E.g.  
2C  
XD 
QS 
… 
AS 
JD 
5H 
The order of cards in the list is the shuffled order of the deck you are to solve. 
NOTE: the notation X is used to represent the ten of a suit. Thus, spades contains: 
2S, 3S, 4S, 5S, 6S, 7S, 8S, 9S, XS, JS, QS, KS and AS. 
You are to solve the deck (find the longest allowable sequence of cards) and output: 
  The length of the longest sequence; 
  The first card in the sequence; 
  The last card in the sequence. 
Remember: The sequence is allowed to skip cards, it is not allowed to re‐order cards. 
   
As usual, do not use classes or STL. 
Submit ex9.ext via moodle as usual where ext is one of c, cpp, java or py. 

More products