Create a puzzle in which the user is presented with an array of length n containing the values 1..n in random order. The user repeatedly chooses one of three available moves with the goal of putting the array in order. The moves are described below.
Moves:
Part a. Draw a design diagram similar to the PrintCalendar case study from the text's slides. You can find the version we used in class at:http://cs.gettysburg.edu/~cpresser/cs111/files/Ch6_CalendarDesign.pdf. Break the problem down into simple sub-problems. Consider decomposing into operations such as printing the array, checking if the puzzle is solved, reversing a portion of the array, among others. You should break it down into at least 4 sub-problems. Submit the diagram as a pdf.
Part b. Write a program to play the game using techniques we have learned in class.
What size array (integer >= 3)? 4
3 1 2 4
-------------------------
(Q) quit (A) reverse left end (D) reverse right end (S) reverse center.
> a
2 1 3 4
-------------------------
(Q) quit (A) reverse left end (D) reverse right end (S) reverse center.
> s
2 3 1 4
-------------------------
(Q) quit (A) reverse left end (D) reverse right end (S) reverse center.
> a
1 3 2 4
-------------------------
(Q) quit (A) reverse left end (D) reverse right end (S) reverse center.
> s
1 2 3 4
-------------------------
You solved it in 4 moves.
What size array (integer >= 3)? 5
4 1 2 5 3
------------------------------
(Q) quit (A) reverse left end (D) reverse right end (S) reverse center.
> s
4 5 2 1 3
------------------------------
(Q) quit (A) reverse left end (D) reverse right end (S) reverse center.
> a
1 2 5 4 3
------------------------------
(Q) quit (A) reverse left end (D) reverse right end (S) reverse center.
> s
1 4 5 2 3
------------------------------
(Q) quit (A) reverse left end (D) reverse right end (S) reverse center.
> d
1 3 2 5 4
------------------------------
(Q) quit (A) reverse left end (D) reverse right end (S) reverse center.
> s
1 5 2 3 4
------------------------------
(Q) quit (A) reverse left end (D) reverse right end (S) reverse center.
> d
1 4 3 2 5
------------------------------
(Q) quit (A) reverse left end (D) reverse right end (S) reverse center.
> s
1 2 3 4 5
------------------------------
You solved it in 7 moves.