# Woody words, tinny words

Note: There are some rude words in this question.

There's an implicit puzzle posed in this classic Monty Python sketch (you can also ready the script online).

Various phrases are described as being 'woody' or 'tinny', and one is described as being 'PVC'.

Given a phrase, respond with its type according to the following lists:

### woody:

gone
sausage
seemly
prodding
vacuum
bound
vole
caribou
intercourse
pert
thighs
botty
erogenous zone
ocelot
wasp
yowling


### tinny:

litter bin
newspaper
antelope
recidivist
tit
simpkins


### PVC:

leap


## Rules

• If the input belongs to one of the above lists, the output should be woody, tinny or PVC, accordingly.
• All input is lower case.
• Any behaviour is acceptable for phrases which are not listed above.
• The fewest bytes in the answer wins.
• @AJFaraday I'd recommend spending some time on the site and answering some questions before embarking on the difficult task of writing challenges. When you feel ready, use the sandbox, at least for your first few challenges and for any non-trivial challenges too. – Adám Mar 5 '18 at 11:38
• I don't like that recommendation at all! Please continue posting challenges, even if you don't like answering. It's of course nice to look at other challenges to get a feel of the site, and I recommend the Sandbox too, but please keep writing challenges! :) – Stewie Griffin Mar 5 '18 at 13:30
• So, we're to apply logic to a Monty Python sketch? ...excellent! – BruceWayne Mar 5 '18 at 21:47
• @BruceWayne that is precisely what we’re doing. – AJFaraday Mar 5 '18 at 23:29
• You may choose how to deal (or ignore) with casing in input and output. To clarify, does this mean we can expect input to be in uppercase? – Οurous Mar 6 '18 at 5:59

# Stax, 30 25 bytes

ï═H♣║GÇX→ΩM+@╢^j╬♪►╨╝ô╤c\


Run and debug it

The commented ascii representation is this. I didn't invent this algorithm. It's shamelessly ripped off Jonathan Allen's python solution.

9@                  10th character, modularly indexed
PVC
.p.|is?t
tinny
$woody  Try it online! I got the .p.|is*t regex from Peter Norvig's regex golfer. • Uh oh, circular attributions. – Adám Mar 5 '18 at 12:24 # Java 8, 8180 67 bytes s->s.charAt(2)<98?"PVC":s.matches(".*(.p.|is?t).*")?"tinny":"woody"  Regex from @MatrinEnder's Retina answer. Try it online. Original answer: 81 80 bytes s->"anetisilire".contains(s.substring(0,2))?"tinny":s.charAt(2)<98?"PVC":"woody"  Try it online. Explanation: s-> // Method with String as both parameter and return-type "anetisilire".contains(s.substring(0,2))? // If the first two letters of the input are present in "anetisilire" "tinny" // Output "tinny" :s.charAt(2)<98? // Else-if the third character of the input is an 'a' "PVC" // Output "PVC" : // Else: "woody" // Output "woody"  Additional explanation: litter bin: anetisi(li)re newspaper: a(ne)tisilire antelope: (an)etisilire recidivist: anetisili(re) tit: ane(ti)silire simpkins: aneti(si)lire  1. None of the first two letters of the woody words are present in this String above, nor is le from leap. 2. None of the woody words has an a as third letter, so that is used to get leap to PVC if it's not a tinny word. 3. Everything else is a word from the woody list. • It's really cool to be able to read through this problem-solving kind of thinking :) – AJFaraday Mar 5 '18 at 13:12 # Haskell, 61 bytes f(a:b:_)|b=='i'||elem a"ran"="tinny"|a=='l'="PVC"|1>0="woody"  Try it online! Uses this hand-found logic: • Words with second letter i or first letter r, a, or n are tinny • Any other word starting with l (leap) is PVC • Anything else is woody Lynn saved a byte by checking leap by its first letter. • Nice! You can save a byte by detecting "leap" with |a=='l'="PVC". – Lynn Mar 5 '18 at 22:57 # QuadS, 34 32 bytes Shamelessly uses Martin Ender's system, including the regex from Peter Norvig's regex golfer. ⊃⍵ ea .p.|is?t$
PVC
tinny
woody


Try it online!

⊃⍵ pick the first occurrence of

ea "ea"
.p.|is?t "p" surrounded by letters OR "i" and "t" with an optional "s" between them
$ end of input … but substituting the matches with the corresponding one of the following: PVC tinny woody The equivalent 43-byte Dyalog APL function is: ⊃'ea' '.p.|is?t' '$'⎕S'PVC' 'tinny' 'woody'


Try all the cases online!

# C (gcc), 8180 79 bytes

-1 byte thanks to @ceilingcat.

h;f(char*s){puts(index("HzYfPW",h=*s^s[1]*4&127)?"Tinny":h<120?"Woody":"PVC");}


Try it online!

The first order of business was to find some hash function that would separate the words into their categories. After some fiddling about I stumbled upon (s[0] ^ (s[1] << 2)) & 0x7f, where the 0x7f is of course there to bring it down to printable ASCII levels. This produced the following information (the tables are sorted, but not the resulting strings):

Woody:
----
erogenous zone  - 45
prodding        8 56
yowling         E 69
vole            J 74
intercourse     Q 81
thighs          T 84
gone            [ 91
botty           ^ 94
bound           ^ 94
ocelot          c 99
pert            d 100
caribou         g 103
seemly          g 103
vacuum          r 114
wasp            s 115
sausage         w 119

[wg8r^JgQdT^-csE

Tinny:
----
litter bin      H 72
tit             P 80
simpkins        W 87
antelope        Y 89
recidivist      f 102
newspaper       z 122

HzYfPW

PVC:
----
leap            x 120

x


The hash collisions don't matter, since they are confided to the same category. We only have to check if the resulting hash is in the Tinny hashes string ("HzYfPW"), since the Woody hashes are all below the PVC hash (120). If 120 or higher, and not a Tinny word, it must be PVC. If not a Tinny word, and the hash is below 120, then it must be a good, woody sort of word.

• @ceilingcat Oof, keep forgetting those POSIX extras. Cheers! – gastropner Jan 6 at 18:24

# x86 32-bit machine code, 39 bytes

Hexdump:

69 01 47 6f 61 2c c7 02 50 56 43 00 3a c4 74 16
c7 02 77 6f 6f 64 85 c0 78 06 c7 02 74 69 6e 6e
66 c7 42 04 79 00 c3


The hash function is multiplication by a "magic" number 0x2c616f47. There are only 6 numbers that can be used with this code.

First of all, it writes PVC to the output. This will be overwritten, if needed.

After hashing, it checks for the PVC word; the check is al = ah - I chose it because it's a small 2-byte instruction. Then, it writes either wood or tinn, depending on the sign of the hashed result. Then, it writes y.

Assembly code:

    imul eax, [ecx], 0x2c616f47;
mov dword ptr [edx], 'CVP';
cmp al, ah;
je done;
mov dword ptr [edx], 'doow';
test eax, eax;
js skip;
mov dword ptr [edx], 'nnit';
skip:
mov word ptr [edx + 4], 'y';
done:
ret;


# Jelly,  27  26 bytes

⁵ịe“Ṗµ»_⁼“ḣG»$ị“©LẈḊ¶$Ḍ»Ḳ¤


Try it online!

### How?

⁵ịe“Ṗµ»_⁼“ḣG»$ị“©LẈḊ¶$Ḍ»Ḳ¤ - Link: list of characters, W   e.g. "gone"  "leap"  "newspaper"
⁵                          - literal ten                  10
ị                         - index into (1-based & modular)     'o'     'e'     'n'
“Ṗµ»                    - compression of characters    "int"
e                        - exists in?                          0       0       1
$- last two links as a monad “ḣG» - compression of characters "leap" ⁼ - equal? 0 1 0 _ - subtract 0 -1 1 ¤ - nilad followed by link(s) as a nilad: “©LẈḊ¶$Ḍ»  -   compression of characters  "tinny PVC woody"
Ḳ -   split at spaces            ["tinny","PVC","woody"]
ị           - index into (1-based & modular)     "woody" "PVC"   "tinny"


-2 bytes thanks to Laikoni.

f"leap"="PVC"
f s|take 2selemwords"li ne ti si an re"="tinny"|1>0="woody"


Try it online!

RIP enklact.

• f"leap"="PVC";f s| is shorter than f s|s=="leap"="PVC"|. – Laikoni Mar 5 '18 at 12:50

# Dirty, 7357 54 bytes

⇖'le'⇗≐∀⭦)Ẃ'nar'⇗{=]}⭨'i'=]'woody'‼␛['tinny'‼␛('PVC'‼␛


Try it online!

Explained:

For a similar older version (I'll update it when I stop golfing it)

␛‼'CVP'⇨⇖'leap'⇗≡⊭◌⬅Ẃ'nar'⇗{=]}1ẁ'i'=]'woody'‼␛['tinny'‼␛


The body of this is made up of:

⇖            put the input into the left stack
'leap'      push the string "leap"
⇗     put that string into the right stack
≡    are the left and right stacks equal
⊭   logically negate
◌  skip next instruction if true
⬅ change direction to leftwards


If we end up going left, then we have:

       ⇨⇖'leap'⇗≡⊭◌ does stuff to the stacks, but isn't relevant
'CVP'              push the string "PVC" (reversed, because we're going left)
‼                   print the string on the main stack
␛                    exit the program (this should wrap into the other exit, but that isn't working yet)


Otherwise, this checks if the string starts with any of "nar":

Ẃ           wipe the right stack
'nar'      push the string "nar"
⇗    move string to right stack
{
=  compare the top of the left and right stacks
] goto matching bracket if true
}   consuming loop while the right stack is true


We then check if the second letter is "i":

1        push the number 1
ẁ       drop ^ number of elements off of the left stack
'i'    push "i"
=   are the top of the left and middle stacks equal
] goto matching bracket if true


If they all fall through, we run into

'woody'   push the string "woody"
‼  print the string on the main stack
␛ exit the program


If we ended up jumping, we wrap around to

[          matching bracket for the goto
'tinny'   push the string "tinny"
‼  print the string on the main stack
␛ exit the program


## C# 97 Bytes

string t(string w)=>w[0]!='p'&new[]{10,9,8,3}.Contains(w.Length)?"tinny":w[0]=='l'?"pvc":"woody";


I went looking for a pattern in the length of the strings and found they are unique except for lengths 4 and 8. So I special case those by looking at the first characters. Oh well, it's still shorter than some answers. :)

• You know, when Martin Ender found a simple rule for these lists, just about every answer implemented that same solution, one way or another. It's cool to see an original approach. :) – AJFaraday Mar 6 '18 at 8:37
• Thanks for the feedback. :) I didn't read other solutions before attempting mine.. perhaps there is still a more elegant solution yet to be discovered.. I so wish they all had unique lengths then this would be The Solution. – lee Mar 6 '18 at 10:49
• string t(string w)=> can be just w=>. You can convert 'p' and other characters to their int representations I think. You can remove the trailing semi colon – TheLethalCoder Mar 7 '18 at 11:17

# Python, 59 bytes

lambda w:"wtPoiVonCdn yy"[(w*4)[9]in"tin"or(w[2]<"b")*2::3]


Try it online!

Uses the indexing from ovs's Python answer but a simpler and shorter choice function:

If the tenth letter of the word, w, with wrapping ((w*4)[9] - where w*4 repeats w four times) is a letter in the word tin (in"tin") then the word is tinny, otherwise if the third letter (w[2]) is an a (<'b') then the word is PVC otherwise the word is woody.

...this 59 does the same job:

lambda w:"wtPoiVonCdn yy"[[(w*4)[9]in"tin",2][w[2]<"b"]::3]


# C, 107 bytes

k;f(char*s){for(k=0;*s;)k+=*s++;k%=100;puts(k-18?(k-5)*(k-81)*(k-56)*(k-78)*(k-37)?"woody":"tinny":"PVC");}


Try it online!

## Batch, 145 bytes

@set/ps=
@if %s%==leap echo PVC&exit/b
@for %%s in (a n r)do @if %s:~,1%==%%s echo tinny&exit/b
@if %s:~1,1%==i echo tinny&exit/b
@echo woody


Takes input on STDIN. Explanation: After checking for leap, tinny words either begin with one of the letters a, n or r or their second letter is i.

## CJam, 35 bytes

1b_856%338<\418=-"woodytinnyPVC"5/=


Try it online!

I completely forgot that I had started a brute force search for short expressions to hash the woody and tinny strings into two classes. I just found the console window where the search ran and it turns out it actually found something...

### Explanation

1b     e# Sum the code points of the input string.
e# The result is unique for each input, except "pert" and "wasp" which
e# both sum to 443. But they're both woody, so that's fine.
_      e# Duplicate.
856%   e# Take the sum modulo 856.
338<   e# Check whether the result is less than 338. That's true for all
e# tinny words.
\      e# Swap with the other copy of the sum.
418=   e# Check whether the sum is equal to 418, which identifies "leap".
-      e# Subtract. Gives -1 for "leap", 1 for tinny words and 0 for woody words.
"woodytinnyPVC"5/
e# Create the list ["woody" "tinny" "PVC"].
e# Select the correct string.


# Excel, 81 bytes

=IF(ISNUMBER(FIND(LEFT(A1,2),"anetisilire")),"tinny",IF(A1="leap","PVC","woody"))


Using the 'anetisilire' method.

# Japt, 36 34 bytes

Uses a RegEx from Martin's Retina solution.

g2 ¶'a?"PVC":wÅnyyë2Uè?t|.pe


# JavaScript, 60, 50

EDIT I saw all the other regex answers. I guess I'm just blind. Anyway, here's one using the same regex

i=="leap"?"PVC":/.p.|is*t/.test(i)?"tinny":"woody"


Also, now, it beats the other JS answer

Snippet:

let test = i => i=="leap"?"PVC":/.p.|is*t/.test(i)?"tinny":"woody"

let woody = gone
sausage
seemly
prodding
vacuum
bound
vole
caribou
intercourse
pert
thighs
botty
erogenous zone
ocelot
wasp
yowling;
console.log("THESE SHOULD BE woody");
woody.split("\n").forEach(el => console.log(test(el)));
let tinny = litter bin
newspaper
antelope
recidivist
tit
simpkins;
console.log("THESE SHOULD BE tinny");
tinny.split("\n").forEach(el => console.log(test(el)));
console.log("THIS SHOULD BE PVC");
console.log(test("leap"));

I didn't see any with regex yet, so I thought I'd give it a try

i=="leap"?"PVC":/[gyuz]|[or][tl]|as/.test(i)?"woody":"tinny"


Not sure if this counts as 60 or more because I didn't include a return statement. Will add a snippet when I get on my computer

Edit: Snippet

let test = i => i=="leap"?"PVC":/[gyuz]|[or][tl]|as/.test(i)?"woody":"tinny"

let woody = gone
sausage
seemly
prodding
vacuum
bound
vole
caribou
intercourse
pert
thighs
botty
erogenous zone
ocelot
wasp
yowling;
console.log("THESE SHOULD BE woody");
woody.split("\n").forEach(el => console.log(test(el)));
let tinny = litter bin
newspaper
antelope
recidivist
tit
simpkins;
console.log("THESE SHOULD BE tinny");
tinny.split("\n").forEach(el => console.log(test(el)));
console.log("THIS SHOULD BE PVC");
console.log(test("leap"));`