(inspired by a question over on Code Review)
Suppose two people are playing Hangman, but you've only overheard the game and want to draw the current status.
Given two words as input, where the words each match
[a-z]+ (your choice), output the current state of the hangman game as ASCII art, following the below rules.
- The first word is the word to be guessed, and the second word is the already-guessed letters. These can be taken as input in any order.
- The word to be guessed is guaranteed non-empty, but the already-guessed letters may be empty (i.e., as if it's the start of the game).
- The game will always be a valid hangman game (i.e., guessed letters won't be duplicated, letters won't be guessed past the end of the game, you'll only receive letters as input, etc.).
- Below the hangman drawing must be the word to be guessed, with
_in place of letters yet unknown, separated by spaces. For example, if the word to be guessed was
BOAT, then below the hangman drawing must be
_ _ _ _. If the word was
Aguessed, then below the drawing must be
_ _ A _.
- Below the word to be guessed must be letters already guessed that are not in the word. These can be in any order, and can be separated by any non-alphabetical separator, if so desired.
Here are the states of the hangman game, from initial start to game end. Each wrongly guessed letter advances the state by one. So the first wrongly guessed letter makes the head
O appear, the next makes the body
| appear, etc.
+---+ | | | | | | ========= +---+ | | O | | | | ========= +---+ | | O | | | | | ========= +---+ | | O | /| | | | ========= +---+ | | O | /|\ | | | ========= +---+ | | O | /|\ | / | | ========= +---+ | | O | /|\ | / \ | | =========
- Two strings in any convenient format, with the first guaranteed non-empty.
- You can take the input in either order (e.g., word to guess and then guessed letters, or vice versa). Please state in your submission the input order.
The resulting ASCII art representation of the hangman game in progress, as described above, again in any convenient format.
- Leading or trailing newlines or whitespace are all optional, so long as the characters themselves line up correctly.
- Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
- If possible, please include a link to an online testing environment so other people can try out your code!
- Standard loopholes are forbidden.
- This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.
+---+ | | O | | | | ========= _ _ A T G
+---+ | | | | | | ========= _ _ _ _ _ _ _ _
+---+ | | O | /|\ | / \ | | ========= _ E _ _ E L I N A T O S H R
+---+ | | O | /|\ | / | | ========= _ _ _ _ _ _ EDCBA
+---+ | | | | | | ========= B O A T
+---+ | | O | | | | | ========= A I _ _ _ A _ E KJ