#C6613. Taco Word Formation Challenge
Taco Word Formation Challenge
Taco Word Formation Challenge
You are given a list of words and a string of characters. Your task is to determine whether the string (after cleaning) can be rearranged to form any one of the words in the list.
The program should follow these rules:
- If the list of words is empty, output
empty list
. - If the characters string is empty, output
empty string
. - Ignore any non-alphabetic characters in the characters string.
- The comparison is case-insensitive.
- For each word, if its sorted lowercase letters exactly match the sorted cleaned characters, output that word and terminate.
- If no word can be formed, output
no match
.
Note: If multiple words can be formed, return the one that appears first in the list.
Input/Output is performed via standard input (stdin) and standard output (stdout).
inputFormat
The input is read from standard input (stdin) and has the following format:
n word1 word2 ... wordn characters_string
- The first line contains an integer
n
, the number of words. - The following
n
lines each contain a word. - The last line contains a string of characters.
outputFormat
Output a single line to standard output (stdout):
- If
n
is 0, outputempty list
. - If the characters string is empty, output
empty string
. - If one of the words can be formed by rearranging the non-special characters (ignoring case) of the characters string, output that word.
- If no matching word is found, output
no match
.
3
world
hello
Python
dlorw
world
</p>