[Question]
  [
There are 21 items in [Minecraft](http://minecraft.gamepedia.com/Minecraft_Wiki) that you can [craft](http://minecraft.gamepedia.com/Crafting) using only [wood](http://minecraft.gamepedia.com/Wood) and items crafted from wood:
> 
> [axe](http://minecraft.gamepedia.com/Axe)  
> 
> [boat](http://minecraft.gamepedia.com/Boat)  
> 
> [bowl](http://minecraft.gamepedia.com/Bowl)  
> 
> [button](http://minecraft.gamepedia.com/Button)  
> 
> [chest](http://minecraft.gamepedia.com/Chest)  
> 
> [crafting table](http://minecraft.gamepedia.com/Crafting_table)  
> 
> [door](http://minecraft.gamepedia.com/Door)  
> 
> [fence](http://minecraft.gamepedia.com/Fence)  
> 
> [gate](http://minecraft.gamepedia.com/Gate)  
> 
> [hoe](http://minecraft.gamepedia.com/Hoe)  
> 
> [ladder](http://minecraft.gamepedia.com/Ladder)  
> 
> [pickaxe](http://minecraft.gamepedia.com/Pickaxe)  
> 
> [planks](http://minecraft.gamepedia.com/Planks)  
> 
> [pressure plate](http://minecraft.gamepedia.com/Pressure_plate)  
> 
> [shovel](http://minecraft.gamepedia.com/Shovel)  
> 
> [sign](http://minecraft.gamepedia.com/Sign)  
> 
> [slab](http://minecraft.gamepedia.com/Slab)  
> 
> [stairs](http://minecraft.gamepedia.com/Stairs)  
> 
> [stick](http://minecraft.gamepedia.com/Stick)  
> 
> [sword](http://minecraft.gamepedia.com/Sword)  
> 
> [trapdoor](http://minecraft.gamepedia.com/Trapdoor) 
> 
> 
> 
This list assumes that the [6 different types](http://minecraft.gamepedia.com/Tree#Species) 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](http://minecraft.gamepedia.com/Crafting#Complete_recipe_list). We'll represent each of these recipes as a 2×2 or 3×3 grid of the characters `.WPS`. The `.` is an empty crafting slot, `W` is for [wood](http://minecraft.gamepedia.com/Wood), `P` is for [wood planks](http://minecraft.gamepedia.com/Wood_Planks), and `S` is for [sticks](http://minecraft.gamepedia.com/Stick). No other characters are needed for these particular items.
For example, this is the recipe for a [chest](http://minecraft.gamepedia.com/Chest):
```
PPP
P.P
PPP
```
**Challenge**
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`](http://minecraft.gamepedia.com/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. [`stick`](http://minecraft.gamepedia.com/Stick):
```
.P
.P
```
```
...
.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. [`hoe`](http://minecraft.gamepedia.com/Hoe):
```
.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.)
**Details**
* 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](https://mothereff.in/byte-counter) wins.
**Example**
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
...
```
  
[Answer]
# CJam, ~~100~~ ~~96~~ ~~94~~ 91 bytes
```
"+WcbKF AQH;_{GM8Lyf=_tmTn"141bDb3/l72b970%={Z"O>HVa=4a"98bZb+"P.SW"f=3/=}%N*
```
StackExchange mangles unprintables, so rather than copying and pasting [here is the permalink](http://cjam.aditsu.net/#code=%22%01%1E%2B%1AW%08c%1Fb%05KF%20AQ%08%16H%18%3B_%15%11%7B%1DGM8Lyf%3D_tmT%0Cn%22141bDb3%2Fl72b970%25%3D%7BZ%22O%1B%3EHVa%3D4a%2298bZb%2B%22P.SW%22f%3D3%2F%3D%7D%25N*&input=chest). Additionally, here's the [test program](http://cjam.aditsu.net/#code=%7Bl%3ALN%20%22%01%1E%2B%1AW%08c%1Fb%05KF%20AQ%08%16H%18%3B_%15%11%7B%1DGM8Lyf%3D_tmT%0Cn%22141bDb3%2FL72b970%25%3D%7BZ%22O%1B%3EHVa%3D4a%2298bZb%2B%22P.SW%22f%3D3%2F%3D%7D%25N*%20NN%7D21*&input=axe%0Aboat%0Abowl%0Abutton%0Achest%0Acrafting%20table%0Adoor%0Afence%0Agate%0Ahoe%0Aladder%0Apickaxe%0Aplanks%0Apressure%20plate%0Ashovel%0Asign%0Aslab%0Astairs%0Astick%0Asword%0Atrapdoor).
*(Thanks to @Optimizer for telling me about `f` and @MartinBüttner for telling me about CJam's modulo indexing.)*
Cygwin's `hexdump`:
```
0000000 0122 2b1e 571a 6308 621f 4b05 2046 5141
0000010 1608 1848 5f3b 1115 1d7b 4d47 4c38 6679
0000020 5f3d 6d74 0c54 226e 3431 6231 6244 2f33
0000030 376c 6232 3739 2530 7b3d 225a 1b4f 483e
0000040 6156 343d 2261 3839 5a62 2b62 5022 532e
0000050 2257 3d66 2f33 7d3d 4e25 002a          
000005b
```
## Explanation
To construct the recipes, we use 13 different rows (also listed are explanations why this is minimal):
```
0    W..    (required by planks)
1    ...    (required by many)
2    .PP    (required by many)
3    PPP    (required by chest)
4    .P.    (required by bowl)
5    ..P    (required by stairs)
6    S.S    (required by ladder)
7    SSS    (required by ladder)
8    .S.    (required by sign)
9    .SP    (required by axe)
10   P.P    (required by bowl)
11   PSP    (required by fence)
12   SPS    (required by gate)
```
We encode the rows via `Z"O>HVa=4a"98bZb+"P.SW"f=3/`, [which gives](http://cjam.aditsu.net/#code=Z%22O%1B%3EHVa%3D4a%2298bZb%2B%22P.SW%22f%3D3%2Fp)
```
["W.." "..." ".PP" "PPP" ".P." "..P" "S.S" "SSS" ".S." ".SP" "P.P" "PSP" "SPS"]
```
The first bit `"+WcbKF AQH;_{GM8Lyf=_tmTn"141bDb3/` encodes the recipes, [giving](http://cjam.aditsu.net/#code=%22%01%1E%2B%1AW%08c%1Fb%05KF%20AQ%08%16H%18%3B_%15%11%7B%1DGM8Lyf%3D_tmT%0Cn%22141bDb3%2Fp) 
```
[[3 3 8] [1 0 0] [1 0 0] [3 8 8] [1 3 3] [2 8 8] [6 7 6] [1 0 0] [1 10 3] [1 1 2] [2 2 2] [1 11 11] [1 1 4] [1 0 1] [1 10 4] [2 9 8] [3 10 3] [1 2 2] [4 8 8] [1 4 4] [1 1 3] [1 12 12] [4 4 8] [5 2 3]]
```
Note how the first entry is `[3 3 8]`, which is the recipe for `sign`.
`l72b970%=` reads in the input, then applies some magic to work out which recipe to take from the list. Even though we only have 21 recipes there are 24 in the list — the extra few spots correspond to the `[1 0 0]`s.
After reading the input, picking the recipe and converting the recipe to rows, we put in some newlines `N*` and auto-print.
---
# CJam, ~~89~~ ~~86~~ 83 bytes
```
'W"9=!%)S@*m:@DQzk?V$%qyR55AmVEpPNW}"132b3b"P.S"f=+3/3/l57b5342%24%(=N*
```
... it turns out that hardcoding all the outputs does a bit better in CJam. I'm pretty disappointed.
Once again we have some unprintables so here's the [permalink](http://cjam.aditsu.net/#code='W%22%029%3D!%10%25%29%1ES%40*%0Bm%3A%40D%18Qzk%3FV%24%25qyR%0655Am%04V%1AEpP%15N%16W%10%01%7D%22132b3b%22P.S%22f%3D%2B3%2F3%2Fl57b5342%2524%25%28%3DN*&input=chest) and [test program](http://cjam.aditsu.net/#code=%7Bl%3ALN%20'W%22%029%3D!%10%25%29%1ES%40*%0Bm%3A%40D%18Qzk%3FV%24%25qyR%0655Am%04V%1AEpP%15N%16W%10%01%7D%22132b3b%22P.S%22f%3D%2B3%2F3%2FL57b5342%2524%25%28%3DN*%20NN%7D21*&input=axe%0Aboat%0Abowl%0Abutton%0Achest%0Acrafting%20table%0Adoor%0Afence%0Agate%0Ahoe%0Aladder%0Apickaxe%0Aplanks%0Apressure%20plate%0Ashovel%0Asign%0Aslab%0Astairs%0Astick%0Asword%0Atrapdoor).
Cygwin's `hexdump`:
```
0000000 5727 0222 3d39 1021 2925 531e 2a40 6d0b
0000010 403a 1844 7a51 3f6b 2456 7125 5279 3506
0000020 4135 046d 1a56 7045 1550 164e 1057 7d01
0000030 3122 3233 3362 2262 2e50 2253 3d66 332b
0000040 332f 6c2f 3735 3562 3433 2532 3432 2825
0000050 4e3d 002a                              
0000053
```
## Explanation
The outputs are encoded using base 3, with the lone `W` being tacked onto the front before the string is split into 3s to give rows, and the rows are split into groups of 3s to give recipes.
Like above, base converting and modulo magic is used to select the recipe. There are 22 recipes (one unused) but we need to take modulo 24, so we actually need to explicitly specify `24%` this time rather than relying on modulo indexing.
[Answer]
# JavaScript (ES6), 235 ~~241 262~~
**Edit** Abusing even more of the rule that input is always valid: there is just 1 item that requires W, and that can be special cased. So the output grid is encoded as 9 digit base 3 numbers.
235 bytes with I/O via popup.
```
w=prompt();
"926a722boa182bo2b19520ch224c6056d644f448g764h7651l2294pi8pr758sh2915si26sl19172sta56st785s728t"
.replace(/(\d+)(\D+)/g,(c,p,m)=>w.search(m+z)||[for(c of'11\n11\n111')z+='.SP'[~~p%3]+(p/=3,-c?'':c)],z='');
alert(&&z||'W.\n..')
```
221 bytes as a testable function.
```
F=w=>"926a722boa182bo2b19520ch224c6056d644f448g764h7651l2294pi8pr758sh2915si26sl19172sta56st785s728t"
.replace(/(\d+)(\D+)/g,(c,p,m)=>w.search(m+z)||[for(c of'11\n11\n111')z+='.SP'[~~p%3]+(p/=3,-c?'':c)],z='')&&z||'W.\n..'
```
Output always as 3x3 grid. With 4 available output symobols, the grid is encoded as a 3x3x2 (18) bit number. And as the input have to be always valid, the string are stored truncated to the bare minimum.
**Test** In Firefox/FireBug console
```
;["axe", "boat", "bowl", "button", "chest", "crafting table", "door", 
 "fence", "gate", "hoe", "ladder", "pickaxe", "planks", "pressure plate", 
 "shovel", "sign", "slab", "stairs", "stick", "sword", "trapdoor"]
.forEach(v=>console.log(v+'\n'+F(v)))
```
*Output*
```
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
...
```
[Answer]
# Python, 305 bytes
```
n=2**(23-hash(raw_input())/535366%24);print "W..\n...\n..." if n==1024 else "\n".join(["".join(['P' if [16706041,9740732,7635081,7399784,5267501,7372808,57344,57344,49152][j+i*3]&n==n else 'S' if [6,2097152,6,131078,10748162,6,131138,9699584,2][j+i*3]&n==n else '.' for j in range(3)]) for i in range(3)])
```
## Explanation
```
# Compute a unique number for each item.
# 535366 and 24 are precalculated values that were bruteforced.
n = 23 - hash(raw_input()) / 535366 % 24
# Use precalculated tables that represent which ingredient in this recipe of
# an item. The nth bit of p[0] will be set if the first ingredient of the item
# associated with the unique number n is some planks. It works the same for s.
p = [16706041,9740732,7635081,7399784,5267501,7372808,57344,57344,49152]
s = [6,2097152,6,131078,10748162,6,131138,9699584,2]
# Handle planks differently, as it is the only one using wood.
if n == 10:
    print "W..\n...\n..."
else:
    for i in xrange(3):
        line = ""
        for j in xrange(3):
            # Now we can check if the ingredient is some planks...
            if p[j + i * 3] & 1 << n == 1 << n:
                line += 'P'
            # ...or if it is some sticks...
            elif s[j + i * 3] & 1 << n == 1 << n:
                line += 'S'
            # ...or if it is simply empty.
            else:
                line += '.'
        print line
```
## Comment
This code surely isn't the tiniest but it works just fine. I'm satisfied. :)
# Python, 282 bytes
```
n=hash(raw_input())/808789215%21;print "\n".join(["P.PPPP...P..S..S..PP.......PP.PP....P........SPSSPS...PPPPPP.S.PP.PS..S.W........PPPPPP...PP..S..S.P..PP.PPPS.SSSSS.SPPP.S..S.PPP......P..P..S..PPPP.PPPPPSPPSP...PP.PP.PP.P..P.....P.P.P...."[9*n+i*3:9*n+(i+1)*3] for i in range(3)])
```
Using the same technique to generate an unique identifier but directly looking up the recipe in an array. It is a lot simpler and a little more compact than my first code.
]