CIS200: Assignment 4
10 points. Due Saturday, March 8, 2008, 10:00pm

Jumble is a word game that often appears on the comics page of a newspaper: the reader sees a word whose letters are mixed up (``jumbled''), and the reader must rearrange the letters to make an English word. To help the reader, the positions of the vowels in the unjumbled word are indicated by question marks (?). For example, the word, ``yeast,'' might be jumbled like this:
   t s a y e
and the unjumbled word is outlined like this:
   _ ? ? _ _
where the question marks indicate where the vowels should be inserted. A typical Jumble puzzle has 4-6 such jumbled words, that once unjumbled, make a small joke or answer a riddle.

Your assignment is to design and build a Python program, named Jumble.py, that reads an English word as its input, then jumbles the word, presents it in the above format, and lets the user interactively move the letters back into their proper positions in the original word. For simplicity, assume that the input word will have a length of 10 letters or less.

Program behavior

When the program is started, it asks the human to type a word to play Jumble. The human types the word, and program starts the game:
Please type a word: enterprise

Here is your puzzle:
   guesses = 0

   0 1 2 3 4 5 6 7 8 9
   t e s r p n e r i e

   ? _ _ ? _ _ _ ? _ ?
   0 1 2 3 4 5 6 7 8 9

Please type the number of the letter you wish to move: 5
Please type the number of the letter's destination: 1
Correct!

Here is your puzzle:
   guesses = 1

   0 1 2 3 4 5 6 7 8
   t e s r p e r i e

   ? n _ ? _ _ _ ? _ ?
   0 1 2 3 4 5 6 7 8 9

Please type the number of the letter you wish to move: 7
Please type the number of the letter's destination: 0
Incorrect!

Here is your puzzle:
   guesses = 2

   0 1 2 3 4 5 6 7 8 
   t e s r p e r i e

   ? n _ ? _ _ _ ? _ ?
   0 1 2 3 4 5 6 7 8 9

Please type the position of the letter you wish to move:
  ... etc. ...
The program lets the user play until all the letters are moved from the jumbled word into the unjumbled one. The jumbled word shrinks in size, until we reach the end of the game:
Here is your puzzle:
   guesses = 2358

   0
   r 
   
   e n t e _ p r i s e
   0 1 2 3 4 5 6 7 8 9

Please type the position of the letter you wish to move: 0
Please type the number of the letter's destination: 4
Correct!

Congratulations!  You completed the puzzle in 2359 guesses!

   e n t e r p r i s e
   0 1 2 3 4 5 6 7 8 9

Press the Enter key to finish.

Building, testing, documenting, and submitting the program

Write an algorithm (or, if you prefer, a flowchart) that outlines the steps your program must take. Study the ``Yoda'' program in the Lecture Notes, Chapter 4, to see how to scramble the letters of a word and build a new string (or, a tuple of characters) that hold the letters of the scrambled word.

Make a list to hold the unjumbled word, and make it hold only "_" and "?" letters at first. (For the example, we started with ["?", "_", "_", "?", "_", "_", "_", "?", "_", "?"]). Write a loop to let the user repeatedly move letters from the jumbled word into the unjumbled list. It is best to build your program in several stages. If you run out of time, submit what you have on the deadline for partial credit:

  1. First, build a program that reads the input word, jumbles the word's letters, and prints the jumbled word.
  2. Next, extend the program so that it prints the layout of the unjumbled word, using a list that holds the _ and ? characters.
  3. Next, extend the program so that it asks the user to move letters from the jumbled word to the unjumbled one.
Test your program on the above example (and others you invent). Pretend that you are a smart user, who solves the puzzle quickly and that you are a not-so-smart user, who makes many mistakes and never solves the puzzle. Remember to add comments at the beginning of the program that describe the form of input that the user types to play the game. Use the web page at http://www.cis.ksu.edu/~schmidt/200s08/Assign to submit your file, Jumble.py.

Reminder: This is a single-person assignment. You are welcome to discuss the assignment with your instructors, tutors, and other students, but the algorithm you design and the program you write and submit must be your own work, just as if you are submitting an essay for an English Composition course.