Exercise8 – Crazy Eights


Category: You will Instantly receive a download link for .zip solution file upon Payment


5/5 - (3 votes)

This exercise is to be done before or during your week 12 laboratory class. When you complete the
exercise show your work to your lab tutor to have your work marked. The marking is based mainly
on correct implementation and code readability. You should implement your code in one file (e.g.
ex8.cpp, ex8.c, ex8.java). Make sure your program has a header comment block containing the name
of the exercise, your name and your student login (e.g. jfk01). You may implement your solution in C,
C++, Java or Python.
For this exercise, you are to solve the crazy 8s 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).

The order of cards in the list is the shuffled order of the deck you are to solve,
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.
When you are finished, test your program using the provided text file named “Ex8.txt” and show
your code and the output to your lab tutor to receive your mark.