Hangman P88165


Statement
 

pdf   zip

thehtml

Write a program that simulates the hangman game.

Remember that the hangman is a game of paper and pencil between two players, for instance Anna and Bernat. Ana thinks a word and writes so many asterisks as letters the word has. Bernat has to attempt to guess which word is, proposing letters successively. If the letter that proposes is in the word, Anna shows the positions where it is. If the letter is not there, Anna “hangs” Bernat. Hanging him does not mean to hurt him, but to create a doll that represents a hangman in a gallows. The game ends with the victory of Bernat if he guesses all letters, or with the victory of Anna if she manages to paint all the parts of the doll (three in our case: head, arms and legs).

Input

Input starts with the word that Anna has chosen. This word only contains six uppercase letters. Then, are coming the letters that Bernat proposes.

Output

The output contains different blocks. The first block contains the drawing of the gallows and shows six asterisks that represent the six letters of the word that Bernat has to guess. Then, for each letter that Bernat proposes, a block with the drawing of the gallows and the hangman and the letter of the word that has guessed so far (printing asterisks for the letters that has not already guessed) must be printed. The program must stop writing blocks when a player wins and must print “ END” (with a space before)

Use the examples to see the format of the gallows, the hangman and blocks described previously.

Observation

Watch the case where the second player repeats one of the letters that he has already proposed.

Public test cases
  • Input

    SCRAWL
    A
    E
    S
    R
    C
    L
    W
    

    Output

     ******
     +----+
     |/
     |
     |
     |
    -+-
    
     ***A**
     +----+
     |/
     |
     |
     |
    -+-
    
     ***A**
     +----+
     |/   |
     |    O
     |
     |
    -+-
    
     S**A**
     +----+
     |/   |
     |    O
     |
     |
    -+-
    
     S*RA**
     +----+
     |/   |
     |    O
     |
     |
    -+-
    
     SCRA**
     +----+
     |/   |
     |    O
     |
     |
    -+-
    
     SCRA*L
     +----+
     |/   |
     |    O
     |
     |
    -+-
    
     SCRAWL
     +----+
     |/   |
     |    O
     |
     |
    -+-
    
     END
    
  • Input

    POTATO
    A
    E
    I
    O
    U
    K
    W
    Z
    

    Output

     ******
     +----+
     |/
     |
     |
     |
    -+-
    
     ***A**
     +----+
     |/
     |
     |
     |
    -+-
    
     ***A**
     +----+
     |/   |
     |    O
     |
     |
    -+-
    
     ***A**
     +----+
     |/   |
     |    O
     |   /|\
     |
    -+-
    
     *O*A*O
     +----+
     |/   |
     |    O
     |   /|\
     |
    -+-
    
     *O*A*O
     +----+
     |/   |
     |    O
     |   /|\
     |   / \
    -+-
    
     END
    
  • Information
    Author
    Jordi Petit
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++