What can I spell?
My mother-in-law has a set of wooden blocks that together spell out
fRoSty The Snowman. Specifically,
y are all painted on separate blocks (note that
S are capitalized). And then there's one longer block that says
However, each block also has a different letter on the reverse side. For example, if you flip the
f block around, it shows a
B. So you could instead spell out
BRoSty The Snowman. (Sidenote: Googling
Brosty the Snowman reveals several Twitter users with that alias. Those people are not me, and their opinions are their own. I do not endorse their comments.)
Similarly, the reverse side of the
R is an
e, and on the back of the
t is a
Or actually, I'm not really sure if that's a
u or an
n on the other side of the
t. So I guess it could really be either one!
So the full set of blocks is
f <--> B
R <--> e
o <--> M <--> W
S <--> i
t <--> u <--> n
y <--> E
The Snowman <--> xo xo xo <--> ox ox ox
The Snowman has a space, and
xo xo xo includes two spaces, as does
ox ox ox.
Of course, when writing out a phrase you can re-order the blocks, you don't have to use every block, and you can't use a block twice. (If you like: from each block, either zero or one of the two or three options may be used.)
Finally, you can insert at most
1 space in between any two blocks. So both
fRoSty The Snowman and
fRoStyThe Snowman are possible, but
fRoStyTheSnowman is not possible because the block with
The Snowman includes a space.
So the question is, Given a phrase, can I spell it out using these blocks?
A string of printable-ASCII characters, of length
1 or more. If you like, you may assume the input has only letters (
a-z) and spaces
You may also assume that the input won't begin or end in a space, and will never have multiple spaces in a row.
You may take the input as a string or array of characters or whatever is convenient and conventional in your language.
You should output a Truthy value if the message can be spelled using the blocks, and a Falsey value otherwise.
fRoSty The Snowman
SMuRfy The Snowman
fRy SuM ox ox ox
xo xo xo MRS BEn
xo xo xo MR BEn (don't need to use every block)
E appear in the set of blocks)
R u The Snowman
y i M The Snowman Rn
Box ox oxy
xo xo xo
t o yS
The Snowman BRoW (the
W can't occur simultaneously)
TheSnowman (again, the block in question clearly reads
The snowman (input is case-sensitive)
The SMuRfy Snowman
xo xo xo The Snowman
yo yo yo
Ho Ho Ho
xo xo xo MR bEn
More egg nog please
Invalid inputs (you are allowed to assume such inputs will not occur):
The Snowman (adjacent multiple spaces)
(has space at the beginning/end of the string)
fRo5ty (only letters and spaces allowed)
Is there any more egg nog left?
Should we make some more egg nog?
Is there any alcohol at all in the house?
I'll be back in a bit
`` (The empty string)
My mother-in-law's Internet access is not the best, so the shorter your code, the better. Hence, this is code-golf. Shortest code wins! You may use any of the default input and output methods, and standard loopholes are forbidden.
If you have a built-in that will do this for you, then I guess this is your chance to use it! Please feel free!
Room for improvement
Obviously, let me know if this is too close to another question, or if it's unclear.
Please let me know if you'd rather see different rules. Please feel free to propose any suggestions that would improve the challenge.
Other test cases that I need to include?
Would different formatting be more convenient?