35
\$\begingroup\$

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.
\$\endgroup\$
  • \$\begingroup\$ @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. \$\endgroup\$ – Adám Mar 5 '18 at 11:38
  • 27
    \$\begingroup\$ 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! :) \$\endgroup\$ – Stewie Griffin Mar 5 '18 at 13:30
  • 5
    \$\begingroup\$ So, we're to apply logic to a Monty Python sketch? ...excellent! \$\endgroup\$ – BruceWayne Mar 5 '18 at 21:47
  • \$\begingroup\$ @BruceWayne that is precisely what we’re doing. \$\endgroup\$ – AJFaraday Mar 5 '18 at 23:29
  • \$\begingroup\$ 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? \$\endgroup\$ – Οurous Mar 6 '18 at 5:59

21 Answers 21

4
\$\begingroup\$

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
`#!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

Run this one

\$\endgroup\$
  • \$\begingroup\$ This answer is OK, but the string literal compressor is buggy, it sometimes produce 5 character long result(if you include the `, 7) for 4-character long strings. \$\endgroup\$ – Weijun Zhou Mar 5 '18 at 23:02
  • \$\begingroup\$ Compression isn't always guaranteed to produce a smaller result. Just usually for english strings. That's not a bug. If you have a case where a double quoted string is smaller, just use that instead. \$\endgroup\$ – recursive Mar 5 '18 at 23:04
  • \$\begingroup\$ I thought it was like Jelly's which always finds the shortest representation (maybe the description should be reworded then?) \$\endgroup\$ – Weijun Zhou Mar 5 '18 at 23:06
  • \$\begingroup\$ Never mind. I think saying can help you is a little confusing but is OK logically. \$\endgroup\$ – Weijun Zhou Mar 5 '18 at 23:09
  • \$\begingroup\$ Hm, yes, the wording is kind of misleading. \$\endgroup\$ – recursive Mar 5 '18 at 23:17
35
\$\begingroup\$

Python 2, 99 73 65 64 63 bytes

lambda s:'PVC'*('ea'in s)or'wtoiondnyy'[s[-2:]in'instperit'::2]

Try it online!

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]
\$\endgroup\$
  • 23
    \$\begingroup\$ Upvoted because of using python to solve a monty python challenge. \$\endgroup\$ – Brain Guider Mar 5 '18 at 12:34
  • 10
    \$\begingroup\$ @AnderBiguri, please cast your vote based on the solution itself rather than the language used. \$\endgroup\$ – Shaggy Mar 5 '18 at 12:51
  • 24
    \$\begingroup\$ @Shaggy AFAIK the choice of language is one of the fun parts of PPCG! I like the solution, because its in python. We already have the bytes to see which one "wins" \$\endgroup\$ – Brain Guider Mar 5 '18 at 14:29
  • 2
    \$\begingroup\$ Yes, votes in codegolf should be merely for the approach considered best or most creative as the winner is determined otherwise. Also it would be boring if everyone just used special codegolf languages instead of getting creative with more common ones \$\endgroup\$ – Gimli Mar 6 '18 at 18:07
  • 5
    \$\begingroup\$ I agree, there can be many reasons to like a particular answer. But even if people are so excited by "Python for Monty Python" pun, it is still sad to see that upvoters don't bother to scroll down a bit, and show some appreciation to another Python answer that is actually more unconventional and even a tad shorter... \$\endgroup\$ – Kirill L. Mar 7 '18 at 7:40
15
\$\begingroup\$

Python 2, 62 bytes

lambda n:'wtPoiVonCdn yy'[hash(n)%97%78%28%15%2+('ea'in n)::3]

Try it online!

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.

\$\endgroup\$
10
\$\begingroup\$

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'

Try it online!

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]

Try it online!

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
\$\endgroup\$
9
\$\begingroup\$

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

Try it online!

I got the .p.|is*t regex from Peter Norvig's regex golfer.

\$\endgroup\$
  • 2
    \$\begingroup\$ Uh oh, circular attributions. \$\endgroup\$ – Adám Mar 5 '18 at 12:24
9
\$\begingroup\$

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.

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.
\$\endgroup\$
  • 2
    \$\begingroup\$ It's really cool to be able to read through this problem-solving kind of thinking :) \$\endgroup\$ – AJFaraday Mar 5 '18 at 13:12
6
\$\begingroup\$

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.

\$\endgroup\$
  • 1
    \$\begingroup\$ Nice! You can save a byte by detecting "leap" with |a=='l'="PVC". \$\endgroup\$ – Lynn Mar 5 '18 at 22:57
5
\$\begingroup\$

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!

\$\endgroup\$
5
\$\begingroup\$

C (gcc), 81 bytes

h;f(char*s){puts(strchr("HzYfPW",h=*s^s[1]<<2&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.

\$\endgroup\$
4
\$\begingroup\$

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;
\$\endgroup\$
4
\$\begingroup\$

Jelly,  27  26 bytes

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

A monadic link accepting and returning lists of characters.

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"
\$\endgroup\$
3
\$\begingroup\$

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"

Try it online!

RIP enklact.

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

Dirty, 73 57 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
\$\endgroup\$
3
\$\begingroup\$

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. :)

\$\endgroup\$
  • 1
    \$\begingroup\$ 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. :) \$\endgroup\$ – AJFaraday Mar 6 '18 at 8:37
  • \$\begingroup\$ 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. \$\endgroup\$ – lee Mar 6 '18 at 10:49
  • 2
    \$\begingroup\$ 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 \$\endgroup\$ – TheLethalCoder Mar 7 '18 at 11:17
3
\$\begingroup\$

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]
\$\endgroup\$
2
\$\begingroup\$

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!

\$\endgroup\$
2
\$\begingroup\$

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.

\$\endgroup\$
2
\$\begingroup\$

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.
\$\endgroup\$
1
\$\begingroup\$

Excel, 81 bytes

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

Using the 'anetisilire' method.

\$\endgroup\$
1
\$\begingroup\$

Japt, 36 34 bytes

Uses a RegEx from Martin's Retina solution.

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

Try it | Check all test cases

\$\endgroup\$
1
\$\begingroup\$

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"));

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.