| Bytes | Lang | Time | Link |
|---|---|---|---|
| 032 | Japt | 180305T125248Z | Shaggy |
| 079 | C gcc | 180306T200127Z | gastropn |
| 054 | JavaScript ES6 | 180306T164553Z | Arnauld |
| 025 | Stax | 180305T182718Z | recursiv |
| 062 | Python 2 | 180305T154207Z | ovs |
| 035 | CJam | 180312T103247Z | Martin E |
| 026 | Jelly | 180311T011219Z | Jonathan |
| 059 | Python | 180311T010936Z | Jonathan |
| 050 | JavaScript | 180308T132045Z | vityavv |
| 039 | x86 32bit machine code | 180307T190935Z | anatolyg |
| 097 | C# 97 Bytes | 180306T060603Z | lee |
| 054 | Dirty | 180306T035636Z | Οurous |
| 061 | Haskell | 180305T174323Z | xnor |
| 081 | Excel | 180305T141350Z | Wernisch |
| 032 | QuadS | 180305T115613Z | Adá |
| 145 | Batch | 180305T133941Z | Neil |
| 063 | Python 2 | 180305T114319Z | TFeld |
| 067 | Java 8 | 180305T121657Z | Kevin Cr |
| 075 | Haskell | 180305T114203Z | totallyh |
| 036 | Retina | 180305T114244Z | Martin E |
| 107 | C | 180305T123510Z | Steadybo |
Japt, 36 34 32 bytes
Uses the RegEx from Martin's Retina solution.
ba Í?`wÅnyy`ë2Uè`?t|.p.`:"PVC
ba Í?`...`ë2Uè`...`:"PVC :Implicit input of string U
ba :First 0-based index of "a" in U
Í :Subtract from 2
? :If truthy (not 0)
`...` : Compressed string "wtoiondnyy"
ë2 : Get every 2nd character, starting at index
Uè : Count the occurrences in U of
`...` : Compressed string "is?t|.p." (= RegEX /is?t|.p./g)
:"PVC :else "PVC"
C (gcc), 81 80 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");}
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.
JavaScript (ES6), Chrome/Edge, 54 bytes
Because the behavior of parseInt() on large inputs with a radix of 36 is implementation-dependent, this one doesn't work with SpiderMonkey (Firefox).
s=>[,'PVC',,'Tinny'][parseInt(s+383,36)%69%7]||'Woody'
How?
The hash function returns 3 for Tinny words, 1 for PVC and either 0, 4, 5 or 6 for Woody words. The words marked with an asterisk are implicitly truncated because space is considered as an invalid character by parseInt().
word | +383 | base 36 -> decimal | mod 69 | mod 7
---------------+----------------+-----------------------+--------+------
gone | gone383 | 36318994131 | 54 | 5
sausage | sausage383 | 2874302392811475 | 42 | 0
seemly | seemly383 | 80120017777107 | 6 | 6
prodding | prodding383 | 94214834629477200 | 12 | 5
vacuum | vacuum383 | 88266035564499 | 60 | 4
bound | bound383 | 916101808275 | 6 | 6
vole | vole383 | 68967369939 | 39 | 4
caribou | caribou383 | 1249086300450771 | 63 | 0
intercourse | intercourse383 | 3.183324871563264e+21 | 11 | 4
pert | pert383 | 55312791699 | 21 | 0
thighs | thighs383 | 83184557510739 | 6 | 6
botty | botty383 | 916052399571 | 63 | 0
erogenous zone | erogenous (*) | 41664605989780 | 7 | 0
ocelot | ocelot383 | 68678794158483 | 39 | 4
wasp | wasp383 | 70309896339 | 63 | 0
yowling | yowling383 | 3523299657958227 | 39 | 4
---------------+----------------+-----------------------+--------+------
litter bin | litter (*) | 1301413923 | 24 | 3
newspaper | newspaper383 | 3081816298632183000 | 3 | 3
antelope | antelope383 | 38980419895881940 | 24 | 3
recidivist | recidivist383 | 129824740122576960000 | 3 | 3
tit | tit383 | 1785109395 | 45 | 3
simpkins | simpkins383 | 104264583727840850 | 24 | 3
---------------+----------------+-----------------------+--------+------
leap | leap383 | 46576922259 | 57 | 1
Previous version, 59 57 bytes
s=>['Woody','Tinny','PVC'][82178>>parseInt(s,35)%50%26&3]
How?
Below are the different steps of the function for each input. The result of the first modulo is an approximation within the precision of JS numbers and is mathematically invalid for intercourse.
input | base-35 -> dec. | %50 | %26 | 00000000010100000100000010
---------------+-------------------+-----+-----+---------------------------
gone | 716219 | 19 | 19 | 00------------------>
sausage | 52042888324 | 24 | 24 | 00----------------------->
seemly | 1492249219 | 19 | 19 | 00------------------>
prodding | 1659396207121 | 21 | 21 | 00-------------------->
vacuum | 1643736697 | 47 | 21 | 00-------------------->
bound | 17573443 | 43 | 17 | 00---------------->
vole | 1359274 | 24 | 24 | 00----------------------->
caribou | 22625709220 | 20 | 20 | 00------------------->
intercourse | 51532867489988450 | 48 | 22 | 00--------------------->
pert | 1089999 | 49 | 23 | 00---------------------->
thighs | 1549436973 | 23 | 23 | 00---------------------->
botty | 17572449 | 49 | 23 | 00---------------------->
erogenous zone | 33308397234728 | 28 | 2 | 00->
ocelot | 1279159344 | 44 | 18 | 00----------------->
wasp | 1385255 | 5 | 5 | 00---->
yowling | 63810499496 | 46 | 20 | 00------------------->
litter bin | 1131250042 | 42 | 16 | 01--------------->
newspaper | 52754217228642 | 42 | 16 | 01--------------->
antelope | 687218151914 | 14 | 14 | 01------------->
recidivist | 2160354371100934 | 34 | 8 | 01------->
tit | 36184 | 34 | 8 | 01------->
simpkins | 1835782971008 | 8 | 8 | 01------->
leap | 917900 | 0 | 0 | 10
Stax, 30 25 bytes
ï═H♣║GÇX→ΩM+@╢^j╬♪►╨╝ô╤c\
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
`#!z"pi0$L+%v9`X store "tinny pvc woody" in the x register
3( keep only the first 3 characters ("tin")
# how many times the 10th char occurs in tin? (a)
y.eaI index of "ea" in the input or -1 (b)
+ a + b (one of -1, 0, or 1)
xj@ modularly indexed word in x
Python 2, 62 bytes
lambda n:'wtPoiVonCdn yy'[hash(n)%97%78%28%15%2+('ea'in n)::3]
How?
This submission uses the fact that the hash function is stable for strings in Python 2. Each valid input has a valid output. The brute-forced repeated modulo %97%78%28%15%2 returns 1 for all tinny and PVC words and 0 for woody words. By adding the value of ('ea' in n) to it, we get 2 instead of 1 for the input 'leap'. Here is a table of all values:
+----------------+----------------------+----------------+-------------+-------+
| word | hash | %97%78%28%15%2 | +('ea'in n) | type |
+----------------+----------------------+----------------+-------------+-------+
| leap | 5971033325577305778 | 1 | 2 | PVC |
+----------------+----------------------+----------------+-------------+-------+
| litter bin | 2393495108601941061 | 1 | 1 | tinny |
| newspaper | 1961680444266253688 | 1 | 1 | tinny |
| antelope | -2930683648135325182 | 1 | 1 | tinny |
| recidivist | -1480015990384891890 | 1 | 1 | tinny |
| tit | -1495230934635649112 | 1 | 1 | tinny |
| simpkins | 672871834662484926 | 1 | 1 | tinny |
+----------------+----------------------+----------------+-------------+-------+
| gone | 3644900746337488769 | 0 | 0 | woody |
| sausage | 4880706293475915938 | 0 | 0 | woody |
| seemly | -8112698809316686755 | 0 | 0 | woody |
| prodding | 7325980211772477495 | 0 | 0 | woody |
| vacuum | -5283515051184812457 | 0 | 0 | woody |
| bound | -6522768127315073267 | 0 | 0 | woody |
| vole | -7823607590901614336 | 0 | 0 | woody |
| caribou | -3644594841083815940 | 0 | 0 | woody |
| intercourse | 2499732157679168166 | 0 | 0 | woody |
| pert | 4142553773863848247 | 0 | 0 | woody |
| thighs | -3490317966011085195 | 0 | 0 | woody |
| botty | -6522767127163072681 | 0 | 0 | woody |
| erogenous zone | 7046120593231489339 | 0 | 0 | woody |
| ocelot | -6961879712146820842 | 0 | 0 | woody |
| wasp | -3668927459619339511 | 0 | 0 | woody |
| yowling | 6823632481520320220 | 0 | 0 | woody |
+----------------+----------------------+----------------+-------------+-------+
The type to return is now extracted from the string 'wtPoiVonCdn yy' by taking every third character, starting at the calculated index.
CJam, 35 bytes
1b_856%338<\418=-"woodytinnyPVC"5/=
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.
Jelly, 27 26 bytes
⁵ịe“Ṗµ»_⁼“ḣG»$ị“©LẈḊ¶$Ḍ»Ḳ¤
A monadic link accepting and returning lists of characters.
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"
Python, 59 bytes
lambda w:"wtPoiVonCdn yy"[(w*4)[9]in"tin"or(w[2]<"b")*2::3]
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]
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"));
Old answer
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"));
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;
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. :)
Dirty, 73 57 54 bytes
⇖'le'⇗≐∀⭦)Ẃ'nar'⇗{=]}⭨'i'=]'woody'‼␛['tinny'‼␛('PVC'‼␛
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
Haskell, 61 bytes
f(a:b:_)|b=='i'||elem a"ran"="tinny"|a=='l'="PVC"|1>0="woody"
Uses this hand-found logic:
- Words with second letter
ior first letterr,a, ornaretinny - Any other word starting with
l(leap) isPVC - Anything else is
woody
Lynn saved a byte by checking leap by its first letter.
Excel, 81 bytes
=IF(ISNUMBER(FIND(LEFT(A1,2),"anetisilire")),"tinny",IF(A1="leap","PVC","woody"))
Using the 'anetisilire' method.
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
⊃⍵ 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!
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.
Python 2, 99 73 65 64 63 bytes
lambda s:'PVC'*('ea'in s)or'wtoiondnyy'[s[-2:]in'instperit'::2]
Alternatives also with 63 bytes:
lambda s:'PVC'*('ea'in s)or'wtoiondnyy'[s[-6::5]in'dtenmsr'::2]
lambda s:'PVC'*('ea'in s)or'wtoiondnyy'[s[::5]in'lrinaosit'::2]
Java 8, 81 80 67 bytes
s->s.charAt(2)<98?"PVC":s.matches(".*(.p.|is?t).*")?"tinny":"woody"
Regex from @MatrinEnder's Retina answer.
Original answer: 81 80 bytes
s->"anetisilire".contains(s.substring(0,2))?"tinny":s.charAt(2)<98?"PVC":"woody"
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
- None of the first two letters of the
woodywords are present in this String above, nor islefromleap. - None of the
woodywords has anaas third letter, so that is used to getleaptoPVCif it's not atinnyword. - Everything else is a word from the
woodylist.
Haskell, 75 bytes
-2 bytes thanks to Laikoni.
f"leap"="PVC"
f s|take 2s`elem`words"li ne ti si an re"="tinny"|1>0="woody"
RIP enklact.
Retina, 39 38 36 bytes
Saved 1 byte by using three substitution pairs as in Adám's answer.
L#-3$0`ea
PVC
.p.|is?t
tinny
$
woody
I got the .p.|is*t regex from Peter Norvig's regex golfer.
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");}