Back
Close

Composable Words

Statement

 Goal

You are playing a word game.

You must check if each of n words, word, are valid or not.

To check if they are valid, you must see if each word is made only from characters in l.

Each character in l may be used once, more than once, or not used at all to form the words.
Each word is always UPPERCASE.
Input
Line 1: An integer, n, representing the amount of words, word to check.
Line 2: A string, l containing space-separated characters that each word must be composed of to be valid. If a word has a single-character that's not in l, that word is invalid.
Line 3: n word separated by spaces
Output
n Lines: A validation: "word" is valid. or "word" is invalid.
Constraints
1 <= n <= 10
2 <= length of word <= 50
Example
Input
2
A B D
DAB BAD
Output
"DAB" is valid.
"BAD" is valid.

Game modes
Fastest, Shortest, Reverse

Test cases
Simple Words. Test
Input
2 A B D DAB BAD
Output
"DAB" is valid. "BAD" is valid.

Validator 1 Validator
Input
2 C A T CAT TAC
Output
"CAT" is valid. "TAC" is valid.

Similar Letters. Test
Input
5 G A R E D GREED DARED DREAD FEARED RAGE
Output
"GREED" is valid. "DARED" is valid. "DREAD" is valid. "FEARED" is invalid. "RAGE" is valid.

Validator 2 Validator
Input
5 T R E O D TREE FJORD RED REED TROD
Output
"TREE" is valid. "FJORD" is invalid. "RED" is valid. "REED" is valid. "TROD" is valid.

Sorry Paris! Test
Input
7 A E I O U T R S C D N M L W B MOSCOW BRUSSELS ROME PARIS LONDON BERLIN TURIN
Output
"MOSCOW" is valid. "BRUSSELS" is valid. "ROME" is valid. "PARIS" is invalid. "LONDON" is valid. "BERLIN" is valid. "TURIN" is valid.

Validator 3 Validator
Input
3 M A D E MALAYSIA SCANDANAVIA ARGENTINA
Output
"MALAYSIA" is invalid. "SCANDANAVIA" is invalid. "ARGENTINA" is invalid.

Completely Invalid. Test
Input
10 F A E U Q N R D BACK FACE HAND FEET CHEST LEGS ARMS HEAD SHOULDERS HIPS
Output
"BACK" is invalid. "FACE" is invalid. "HAND" is invalid. "FEET" is invalid. "CHEST" is invalid. "LEGS" is invalid. "ARMS" is invalid. "HEAD" is invalid. "SHOULDERS" is invalid. "HIPS" is invalid.

Validator 4 Validator
Input
10 A E I O U T R C TRACK RACK TACK STACK STEAK KNACK KNOCK SOCK TALK CHALK
Output
"TRACK" is invalid. "RACK" is invalid. "TACK" is invalid. "STACK" is invalid. "STEAK" is invalid. "KNACK" is invalid. "KNOCK" is invalid. "SOCK" is invalid. "TALK" is invalid. "CHALK" is invalid.

Check the Usernames: Test
Input
6 @ A N L 1 5 T E O R S F G D I @5DN1L @CODE_PARSER @CG_CHATBOT @NINTENDO @USERNAME123 @CHECK_THIS_NAME
Output
"@5DN1L" is valid. "@CODE_PARSER" is invalid. "@CG_CHATBOT" is invalid. "@NINTENDO" is valid. "@USERNAME123" is invalid. "@CHECK_THIS_NAME" is invalid.

Validator 5 Validator
Input
7 @ % # L I O N E @LIONEL%# @LIONEL$ @L$I#EL @IONEL89 @LIONEL @LIONEL9675 @LIONEL%LIONEL
Output
"@LIONEL%#" is valid. "@LIONEL$" is invalid. "@L$I#EL" is invalid. "@IONEL89" is invalid. "@LIONEL" is valid. "@LIONEL9675" is invalid. "@LIONEL%LIONEL" is valid.

Solution language

Solution

Stub generator input