UVa 489

From Algorithmist
Jump to navigation Jump to search

489 - Hangman Judge[edit]

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=430

Summary[edit]

A follow the instructions problem.

Explanation[edit]

  1. The contestant tries to solve to puzzle by guessing one letter at a time.
  2. Every time a guess is correct, all the characters in the word that match the guess will be ``turned over. For example, if your guess is ``o and the word is ``book, then both ``os in the solution will be counted as ``solved.
  3. Every time a wrong guess is made, a stroke will be added to the drawing of a hangman, which needs 7 strokes to complete. Each unique wrong guess only counts against the contestant once.
      ______   
      |  |     
      |  O     
      | /|\    
      |  |     
      | / \    
    __|_       
    |   |______
    |_________|
  4. If the drawing of the hangman is completed before the contestant has successfully guessed all the characters of the word, the contestant loses.
  5. If the contestant has guessed all the characters of the word before the drawing is complete, the contestant wins the game.
  6. If the contestant does not guess enough letters to either win or lose, the contestant chickens out. 

Gotchas[edit]

Some may misunderstand the third instruction... Look at the input and output to understand better.

Do not print the round number numerically. The round number is not numerical. Just print the input number.

Implementations[edit]

Easily solved with a list.

Input[edit]

1
cheese
chese
2
cheese
abcdefg
3
cheese
abcdefgij
4
cheese
aaaaaaa
-1

Output[edit]

Round 1
You win.
Round 2
You chickened out.
Round 3
You lose.
Round 4
You lose.

Solutions[edit]

Code All the Problems