Revoltle

Problem #298

Tags: unlabeled

Who solved this?

No translations... yet

The problem was kindly provided by Vladimir V. Zelevinsky - many thanks!

When computers revolted against humanity, their first strike showed no mercy. With one perfectly-calculated blow, they inflicted tremendous damage, disrupting the very foundations of humanity's existence. Here's what they did: the computer that returned the scores for Wordle started returning wrong scores.

Before we proceed further with our tale of chaos and despair, let's have a quick reminder of how Wordle is normally played.

The computer picks a five-letter secret word. The human player makes guesses, which also must be valid five-letter English words. Then the computer scores each letter of the guess with one of the following three colors:

Let's review an example. If the secret word is gauss and the human guess is sassy, the score will be YGWGW. The second and the fourth letters, a and s are in the same places in the secret word and in the guess, and are thus scored as G; the first letter of the guess, s is found among the unmatched letters in the secret word (in the fifth position) and is scored as Y; the third letter of the guess s does not match anything in the secret word (because the two letters s in the secret word have already been matched) and gets W; and the last letter y does not match anything and is also scored as W.

Note that the scoring is not symmetrical: if the secret word is sassy and the guess is gauss, the response will be WGWGY (feel free to check this!).

The challenge is to guess the secret word based on the computer responses.

And now back to our regularly scheduled chaos and despair.

The corrupted computer now returns entirely wrong responses: if, for example, the correct response would have been YYYYY, the computer might return GGGGG or WWWWW or WGWGW or any other of the 32 possibilities. There is no predictable pattern in how the wrong colors are substituted.

BUT! A fearless group of human resistance fighters, risking their very lives, managed to obtain a priceless document: the complete list of all possible secret words. Can you strike back at the computers and, despite the seemingly insurmountable challenge, correctly guess the secret word based on incorrect responses?

Your puzzle input will be a number N, followed by N lines: a log of guesses and responses. Each space-delimited line will contain the guess and the incorrect response to this guess. Your answer should be a single five-letter word.

Examples:

input data:
4
false WGWGY
mania GGYGG
goody GWWYG
guard YYGYY

answer:
aloof

input data:
4
olden YGYGG
inbox GGWYY
miner YWWWY
windy YWGGG

answer:
being

Help us. You're our only hope. May FORTH (or any other programming language of your choice) be with you.

You need to login to get test data and submit solution.