There are 21 items in Minecraft that you can craft using only wood and items crafted from wood:
This list assumes that the 6 different types of wooden planks/slabs/doors/etc. all count as the same item. Another way to think of it is to assume you only have access to one type of wood.
Each of these 21 items has a different crafting recipe. We'll represent each of these recipes as a 2×2 or 3×3 grid of the characters
. is an empty crafting slot,
W is for wood,
P is for wood planks, and
S is for sticks. No other characters are needed for these particular items.
For example, this is the recipe for a chest:
PPP P.P PPP
Write a program that takes in the name of one of our 21 items, exactly as it appears above, and prints a valid crafting recipe for that item.
Crafting recipes are translation invariant, so if the input is
fence, both of these are valid:
PSP PSP ...
... PSP PSP
If a recipe fits in a 2×2 grid, you can output it in a 2×2 or 3×3 grid. e.g.
... .P. .P.
Recipes can also be mirrored horizontally (around a vertical line of symmetry), though this only makes a difference for the axe, hoe, and stairs. e.g.
.PP .S. .S.
PP. .S. .S.
So outputting any recipe that fits in the grid and has the correct shape (ignoring translation and mirroring) is what your program needs to do. These are all the recipes that the official game will recognize. (Note that recipes cannot be rotated or mirrored vertically.)
- Take input from stdin or the command line. You can assume the input is always valid. Requiring quotes around input (e.g.
"chest") is fine.
- Output to stdout (or closest alternative) with an optional trailing newline.
- The shortest submission in bytes wins.
Here's a list of all inputs and sample outputs:
axe PP. SP. S.. boat P.P PPP ... bowl P.P .P. ... button P. .. chest PPP P.P PPP crafting table PP PP door PP. PP. PP. fence PSP PSP ... gate SPS SPS ... hoe PP. S.. S.. ladder S.S SSS S.S pickaxe PPP .S. .S. planks W. .. pressure plate PP .. shovel P.. S.. S.. sign PPP PPP .S. slab PPP ... ... stairs P.. PP. PPP stick P. P. sword P.. P.. S.. trapdoor PPP PPP ...