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

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

So, we're to apply logic to a Monty Python sketch? ...excellent!

@BruceWayne that is precisely what we’re doing.

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?

@Ourous let’s keep it simple. All input is lower case.

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

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.

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.

I thought it was like Jelly's which always finds the shortest representation (maybe the description should be reworded then?)

Never mind. I think saying can help you is a little confusing but is OK logically.

Hm, yes, the wording is kind of misleading.

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]

Upvoted because of using python to solve a monty python challenge.

@AnderBiguri, please cast your vote based on the solution itself rather than the language used.

@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"

@AnderBiguri We already have the “bites” to see which one wins!! ;)

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

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

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.

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

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.

Uh oh, circular attributions.

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

None of the first two letters of the woody words are present in this String above, nor is le from leap.
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.
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 :)

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".

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

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!

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ẈḊ¶$Ḍ»Ḳ¤

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"

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.

f"leap"="PVC";f s| is shorter than f s|s=="leap"="PVC"|.

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

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

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.

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

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.

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

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

Using the 'anetisilire' method.

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


text:
Create this "String Mix-Up" function in as few bytes as possible
This is my first time here at Code Golf SE so feel free to add your input/advice/suggestions to improve my post if necessary. The week after my computer science exam, the solutions were publicly published. One problem had a 45 line example solution but my solution was only 18 lines, (which I was very proud of), but I bet you guys here at code golf SE can do better.
Here are the requirements:

Takes two inputs, string1 and string2.
Delete the first occurrence of string2 found in the string1.
Add string2 in reverse order to the beginning of string1, and
Add string2 in reverse order to the end of the string1.
If string2 does not occur in string1, do not modify string1.
Output the modified string1

Example:
Input:
batman
bat

thebatman
bat

batman
cat

Output:
tabmantab

tabthemantab

batman

Note:
The problem was intended to handle basic inputs. Assume all expected inputs are restricted to characters A-Z, numbers, or other special characters visible on your keyboard. It does not need to handle tabs or newlines.
Submissions with shortest byte counts in each language win.

Can you give an example test case where string 2 doesn't occur in string 1? Also - which characters can appear in the string? Printable ASCII? Tab? Newlines?

@user202729 Input "batman, robin" has output "batman"

Out of curiosity, which language did you use in the exam?

@user202729 I used C++

We also need an example where string1 contains string2 twice or more.

And an example where string2 contains characters that are special in a regex and make naive s/string2// fail

Also a test case with string 2 being a palindome might be a good idea.

Perhaps a test case containing the second input multiple times, since we only should replace the first? Something like: "batman_and_his_bat", "bat" → "tabman_and_his_battab"

As newlines are insignificant in C++ (unless after a preprocessor directive), you can just solve it in 2 lines. Also that's why we don't measure line count here.

I can't believe nobody has said this: Welcome to PPCG! This is a good first challenge, and in case you didn't know, we also have a Sandbox for feedback before you post a challenge, to ensure you aren't missing anything from yours. I'm looking forward to more of your posts here, and hope you enjoy the time you spend here :)

Stax, 16 11 bytes
ÄE┘¢8·╦Ωb•∩

Run and debug it online
The corresponding ascii representation of the same program is this.
Y#xyz|eyr|Sx?

This fixes the bugs in original version.  It uses conditionals and stuff.
Y                   Save 2nd input in y.  Now the two inputs are x and y.
 #                  Occurrences of y in x. (a)
  xyz               x, y, ""
     |e             replace first occurrence
       yr|S         surround with y reversed. (b)
           x        first input. (c)
            ?       a ? b : c

The result is printed implicitly.

C#,  148 bytes
using System.Linq;using System.Text.RegularExpressions;(a,b)=>a==(a=new Regex(Regex.Escape(b)).Replace(a,"",1))?a:(b=string.Concat(b.Reverse()))+a+b

Perhaps include a tio link? (I edited your post to capitalize C# and add syntax highlighting.)

Welcome to PPCG, and nice first answer! With lambdas you are allowed to leave out the types and the trailing semi-colon, but all required imports are mandatory for the byte-count I'm afraid, so it would becomes this instead: using System.Linq;(a,b)=>a==(a=new System.Text.RegularExpressions.Regex(b).Replace(a,"",1))?a:(b=string.Concat(b.Reverse()))+a+b (128 bytes). Also, as @Ourous suggested, perhaps add a TIO link to your answer. Here is an example of how it might look like. It's unfortunate the Regex import is so long in .NET... :(

Hmm, it seems to fail for "this.is.a.test", ".". Expected output: ".thisis.a.test.", actual output: ".his.is.a.test.". Can be fixed like this: using System.Linq;using System.Text.RegularExpressions;(a,b)=>a==(a=new Regex(Regex.Escape(b)).Replace(a,"",1))?a:(b=string.Concat(b.Reverse()))+a+b (148 bytes). Try it online.

Thanks Kevin.. wow, c# is impressively unsuitable for golfing.. :) I tested my code in linqpad which I guess adds some commonly used namespaces by default. And yep, missed the need to escape it as someone pointed out in your java port of my code :) I think I am gonna use JavaScript next time. Thank you very much for taking the time.

APL (Dyalog Unicode), 36 bytesSBCS
Look ma, no regex!
Anonymous infix lambda, taking string2 as left argument and string1 as right argument. Assumes ⎕IO (Index Origin) to be 0, which is default on many systems.
{r,⍵[(⍳≢⍵)~(f⍳1)+⍳≢⍺],r←⌽⍺/⍨∨/f←⍺⍷⍵}

Try it online!
{…} "dfn"; ⍺ is left argument, ⍵ is right argument; e.g. "bat" and "manbatmanbat":
 ⍺⍷⍵ find where string2 begins in string1; [0,0,0,1,0,0,0,0,0,1,0,0]
 f← assign to f (find)
 ∨/ OR-reduction (does string2 occur at all?); 1
 ⍺/⍨ use that to compress string2 ("" if not found); "bat"
 ⌽ reverse that; "tab"
 r← assign to r (reverse)
 ⍵[…], prepend string2 indexed by the following indices:
  ≢⍵ the length of string2; 3
  ⍳ the indices of that; [0,1,2]
  (…)+ add the following to that:
   f⍳1 index of first 1 in f; 3
  Now we have the indices to be removed; [3,4,5]
  (…)~ the following indices except those indices:
   ≢⍵ length of string2; 12
   ⍳ the indices of that; [0,1,2,3,4,5,6,7,8,9,10,11]
  Now we have the indices we want to keep; [0,1,2,6,7,8,9,10,11]
 This gives us the remaining parts of string1 followed by a reversed string2; "manmanbattab"
 r, prepend r to that; "tabmanmanbattab"

Python, 55 bytes
lambda s,t:s.replace(t,'',1).join(2*[t[::-1]*(t in s)])

Try it online!
Using join to get the a+b+a pattern. This lets us write expression for a only once while still using a lambda. Compare:
Python 2, 57 bytes
def f(s,t):r=t[::-1]*(t in s);print r+s.replace(t,'',1)+r

Try it online!

Ruby, 39 38 35 bytes
-3 bytes due to a neat trick by Asone Tuhid
->x,y{(x[y]&&="")?y.reverse!+x+y:x}

Try it online!

35 bytes

Wow, I was thinking for ages, how to get rid of that duplicated x[y], but didn't even know this was possible

It's the same idea as ||=, +=, etc. I think all a=a<op>b can be reduced to a<op>=b (or a<op>a=b in this case) if that makes sense.

Python 3, 56 bytes
lambda s,t:[s,t[::-1]+s.replace(t,'',1)+t[::-1]][t in s]

Try it online!

Java 8, 126 113 bytes
(a,b)->a.equals(a=a.replaceFirst(java.util.regex.Pattern.quote(b),""))?a:(b=new StringBuffer(b).reverse()+"")+a+b

Port of @lee's C# .NET answer, so make sure to upvote him!
Try it online.
Old 126 byte answer:
a->b->{Object r=new StringBuffer(b).reverse();return a.contains(b)?r+a.replaceFirst(java.util.regex.Pattern.quote(b),"")+r:a;}

Try it online.
Explanation:
a->b->{                    // Method with two String parameters and String return-type
  Object r=new StringBuffer(b).reverse();
                           //  2nd input reversed
  return a.contains(b)?    //  If the 1st input contains the 2nd:
    r                      //   Output the reversed 2nd input
     +a.replaceFirst(java.util.regex.Pattern.quote(b),"")
                           //   Removed the first occurrence of the 2nd in the 1st input,
                           //   escaping any characters like dots, pluses, etc.
                           //   and then append that to the result
     +r                    //   appended with the reversed 2nd input again
   :                       //  Else:
    a;}                    //   Simply output the 1st input

Fails with b = "..." ("Assume all expected inputs are restricted to characters A-Z, numbers, or other special characters visible on your keyboard." : . is a special character visible on every keyboard)

Retina, 35 bytes
^(.*)¶(.*?)\1(.*)
¶$^$1$2$3$^$1
0A`

Try it online! $^ is new in Retina 1 and reverses its argument which is just what's needed here.

Perl 5 + -pl, 38 34 bytes
$s=<>;s/\Q$s//&&s/^|$/reverse$s/ge

-4 thanks to Ton Hospel
Try it online!

Good method but can be golfed a bit more: -pl $s=<>;s/$s//&&s/^|$/reverse$s/ge. Both versions really need to use s/\Q$s// though since characters like * and . seem allowed

05AB1E, 12 bytes
DIåiIõ.;IR.ø

Try it online!
Explanation
D             # duplicate 1st input
 Iåi          # if 2nd input is in first input
    Iõ.;      # replace the first occurrence of 2nd input with the empty string
        IR.ø  # surround with 2nd input reversed

Only other thing I can think of is 13-bytes: õ.;©Ê²si®¹R.ø but it's pretty different order-wise.

Javascript, ES6 - 73 bytes
b=x=>y=>{v=[...y].reverse().join``;u=x.replace(y,"");alert(u==x?x:v+u+v)}

please support me to improve it!

Several of the JavaScript and ES6 tips will let you shave off a number of bytes.

Also, we format code blocks with 4-spaces indentation. See this.

@user202729 thank you for reminding me!

Javascript (ES6), 69 65 64 bytes
x=>y=>x.match(y)?(k=[...y].reverse().join``)+x.replace(y,'')+k:x

Try it online!

Welcome to PPCG! / (1) In the way how we normally count byte count, the m= is not counted if you don't use it in the function (i.e., it doesn't call itself). (2) You can save a byte by currying.

Also you may find Tips for golfing in Javascript useful.

You can use [...y].reverse().join``  to reverse a string, save 2 bytes.

Doesn't work when y contain |?

Jelly, 18 bytes
œṣ⁹Ḣ;jɗ⁹ṭṚ};Ṛ}ðẇ@¡

Try it online!
Full program.

K4, 36 bytes
Solution:
{$[#s:x ss y;r,(x_/(#y)#*s),r:|y;x]}

Examples:
q)k){$[#s:x ss y;r,x_/(#y)#*s,r:|y;x]}["batman";"bat"]
"tabman"
q)k){$[#s:x ss y;r,(x_/(#y)#*s),r:|y;x]}["batman";"bat"]
"tabmantab"
q)k){$[#s:x ss y;r,(x_/(#y)#*s),r:|y;x]}["thebatman";"bat"]
"tabthemantab"
q)k){$[#s:x ss y;r,(x_/(#y)#*s),r:|y;x]}["batman";"cat"]
"batman"
q)k){$[#s:x ss y;r,(x_/(#y)#*s),r:|y;x]}["batbatbat";"bat"]
"tabbatbattab

Explanation:
If string 2 (y) is found in string 1 (x) then drop first indices of first occurrence.
{$[#s:x ss y;r,(x_/(#y)#*s),r:|y;x]} / the solution
{                                  } / lambda with implicit x,y
 $[         ;                   ; ]  / $[condition;true;false]
      x ss y                         / string-search for y in x
    s:                               / save result as s
   #                                 / count length
                              |y     / reverse (|) y
                            r:       / save as r
                           ,         / join with
               (          )          / do this together
                        *s           / first (*) s
                       #             / take
                   (#y)              / length of y
                x_/                  / drop (_) over (/)
             r,                      / join with r
                                 x   / (else) return x

Javascript 85 bytes
a=>b=>a.includes(b)?[...b].reverse().join``+a.replace(b,'')+[...b].reverse().join``:a

If someone knows how to avoid using split('').reverse().join('') for reversing string, please let me know

f=a=>b=>a.includes(b)?[...b].reverse().join``+a.replace(b,'')+[...b].reverse().join``:a

console.log(f('batman')('bat'))

console.log(f('thebatman')('bat'))

console.log(f('batman')('cat'))

for help, you can't get much better than the Tips for golfing in javascript, and I'm sure somebody will come along to help -- I don't know javascript.

There's really no better way to reverse a string. What you could do is ...?(c=[...b].reverse().join``)+a.replace(b,'')+c:a to save quite a few bytes.

Jelly, 21 20 bytes
œṣµḢ;j⁹$ɓ;;@ðU}
ç¹w?

Try it online!

Ouch! Why can other languages get 11~12 bytes? Am I doing something wrong?
And finally, I think I know how chain separators works...
œṣµḢ;j⁹$ɓ;;@ðU}   Helper link (dyadic). General structure:
œṣ                <dyad>                    - given x and y, split x at
                                              sublists equal to y.
   Ḣ;j⁹$                <monad>             - given x, join with y except at
                                              first index.
         ;;@                   <dyad>       - given x and y, return y+x+y.
                                              Note that this link is flipped.
             U}                      <dyad> - reverse right argument.

ç¹w?    Main link. Evaluate the last link if the second input is a substring
        of the first input, otherwise - apply identity (do nothing).

Python 2, 62 Bytes
def f(a,b):b*=b in a;a=a.replace(b,"",1);b=b[::-1];print b+a+b

SNOBOL4 (CSNOBOL4), 73 bytes
	S =INPUT
	T =INPUT
	S T =	:F(O)
	T =REVERSE(T)
	S =T S T
O	OUTPUT =S
END

Try it online!
What's a regular expression?

Python 3, 58 bytes
def f(a,b):z=(b in a)*b[::-1];return z+a.replace(b,'',1)+z

AWK, 85 bytes
{for(;x++<N=split($0,a,"");)p=a[x]p;$0=NR%2?L=$0:sub($0,"",L)?p L p:L}!(NR%2)

Try it online!
Input is: primary string on odd-lines, replacement on even lines. Replacement is case sensitive.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
This challenge is about recursion (Cops' thread)
Cops' thread
In this thread, your task is to make a recursion-based program/function to generate any integer series. Robbers will try and find a shorter non-recursive solution over in the Robbers' thread.
Challenge synopsis
In many languages, recursive functions can significantly simplify a programming task. However, the syntax overhead for a proper recursion may limits its usability in code-golf.
The cops will create a program or function taking a single integer n, which will generate the first n entries of an integer series, using only recursion1. They should also make sure there is a shorter nonrecursive way to generate the sequence in order to mark their entry as safe.
The robbers will try to find a shorter program or function in the same language, generating the same integer series, using no recursion2.
If the cops' submission is not cracked within ten days (240 hours), the cop will prove it was in fact possible to have a shorter non-recursive approach by revealing their own solution. They may then mark their submission as safe.
The winner of the cops challenge will be the shortest (according to code-golf) recursion-based submission marked safe.
The winner of the robbers challenge will be the robber who cracked the most solutions.
1: It only needs to be recursive in syntax; you don't need to worry about for example tail call optimization.
2: Again, non-recursive in syntax; so you can't post a recursive solution and claim its compiled to a loop thanks to tail call optimization.
Submission requirements
Each submission will take a single integer n (zero- or one-based). The submission will then output or return the first n entries of an integer series of choice. (note that this integer series must not depend on n). The input and output method may differ between the recursive and non-recursive approach. The integer series may be any deterministic series with a length of at least 5. The series should be explained properly.
Your submission does not have to work for arbitrary large n, but should work for at least n=5. The non-recursive approach must be able to work up to at least the same n as the recursive approach, or up to n=2^15-1, whichever is smaller.
Recursion
For the sake of this challenge, recursion is defined as creating the desired sequence using a function (or function-like construct) that calls itself (or calls a sequence of functions that ends up calling itself; this includes constructs like the Y combinator). The recursion depth should go to infinity as n goes to infinity. The non-recursive approach is anything that is not recursive.

For Thyme where for is done by recursive behind, is for recursive or loop?

Can I say a code works for arbitrarily large n if it's theoretically correct, but it cannot be run due to time or memory constraints?

@Bubbler Certainly, but at least n=5 must be computed

@l4m2 Not all languages can compete. It seems like this language does not have a native way of not using recursion (unless xfor is available through some kind of import?) so perhaps this language cannot compete.

A recursive that don't go that much when n go large, is it a recursive?

@l4m2 You mean like a recursion depth of O(log n) or? Please be more specific.

maybe O(log n) or O(1)[f(x)=x%3?f(x-1)*x:x], or anything

@l4m2 The latter makes zero sense.But the former is completely fine. I quote, The recursion depth should go to infinity as n goes to infinity. Anything over O(1) fulfills that requirement.

why zero sense?

@l4m2 It doesn' seem to generate an integer series of length n but only the nth entry. Correct me if I'm wrong.

@Sanchises If it's not recursive i can use it in the loop solution

Can we choose a sequence in which a program to compute it must use recursion (Assuming such a sequence exists)?

@caird No. You must provide your own nonrecursive solution to mark your entry as safe. Also, I do not think such a sequence exists as any computable sequence can be generated with a Turing-complete language, which does not need to support recursion

@cairdcoinheringaahing Fractran doesn't have recursion, and it's still TC. Anything that is computable with recursion can also be able to compute without recursion.

Is it correct that the series technically needs to be infinite?

@flawr It may be a finite series, but the program should be agnostic of that (to fulfill the requirement that recursion depth should go to infinite as n goes to infinity). Your program may exhibit undefined behaviour if n is larger than the sequence length. The sequence length must be larger than 5.

@flawr (I am not necessarily a fan of this definition, but as you can see by the number of comments, there's been some debate over what exactly constitutes recursion. This definition so far seems to hold up to the spirit of the challenge. If you have another suggestion on how to handle finite sequences, feel free to comment!)

Aww, the titles could've been something like (for the cops and robbers respectively): Visit the Robber's Thread and Visit the Cop's Thread

Python 3, 65 bytes (Safe)
f=lambda n,a=3,b=0,c=6,d=6:n*[1]and[a+b]+f(n-1,c,d,2*c+d,2*a+3*b)

Try it online!
Another try in Python.
The sequence is "the number of ways to fill a 2-by-n board with dominoes in three colors, so that no two same-colored dominoes touch each other". Not on OEIS.

Let's say n=6. The board looks like:
######
######
and these are valid domino tilings in three colors (1-3 represent a color each):
123123 122331 212332 212121 113311
123123 133221 212112 212121 331133
but these are not (two same-colored dominoes are touching each other):
112323 332333 211113
112323 112311 233223
The sequence counts all possible domino tilings that satisfy the rules for each n.

Intended solution, 58 bytes
n=int(input());a=3;b=12
for _ in[0]*n:print(a);a,b=b,a*4+b

Try it online!
Unfortunately it looks like no one bothered to simplify the recurrence relation, which was clearly shown in the recursive code. Making a program with the given double recurrence as-is doesn't work since it's Python 3.

Could you give a more detail explain on the sequence please.

@tsh Added some explanation. Does it look better?

Python 3, 75 bytes, cracked by xnor
f=lambda n,a=[1]:a*n and[a[0]]+f(n-1,sorted({*a[1:],a[0]*2,a[0]*3,a[0]*5}))

Try it online!
The famous Hamming numbers, a.k.a. 5-smooth numbers (A051037).
Cracked solution, 51 bytes
lambda n:[k for k in range(1,2**n)if 60**k%k<1][:n]

Try it online!
Intended solution, 74 bytes
lambda n:sorted(2**(i%n)*3**(i//n%n)*5**(i//n**2)for i in range(n**3))[:n]

Try it online!

Cracked?

Octave, 47 bytes, cracked by l4m2
@(n)(f=@(r,m){@()[r(r,m-1),m],[]}{~m+1}())(f,n)

Try it online!
As an example, here is an Octave entry which generates the first n positive integers, https://oeis.org/A000027.

Cracked. +1 for making a recursive anonymous function though... Not often those are used :)

@StewieGriffin I absolutely love golfing recursive anonymous functions in Octave, although they never turn out shorter than their loop-based version. The reverse of this challenge would definitely be a challenge in Octave for the cops.

@StewieGriffin Not sure if the ping in chat worked, by the way, but l4m2 beat you to it.

Forth (gforth), 39 bytes, cracked by NieDzejkob
: | dup 1 > if dup 1 - recurse then . ;

Try it online!

You're allowed different integer series than [1,2,...,n], you know that right?

Cracked

I thought about that because the crack is just a google search away for counted loops using forth. But really whatever is inside the function can be easily recreated inside the loop anyway.

Röda, 40 bytes
f x,a=1,b=2{[a];f x-1,a=b,b=a+b if[x>1]}

Try it online!
This function gives the following finite sequence (the 90 first Fibonacci numbers):
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
1597
2584
4181
6765
10946
17711
28657
46368
75025
121393
196418
317811
514229
832040
1346269
2178309
3524578
5702887
9227465
14930352
24157817
39088169
63245986
102334155
165580141
267914296
433494437
701408733
1134903170
1836311903
2971215073
4807526976
7778742049
12586269025
20365011074
32951280099
53316291173
86267571272
139583862445
225851433717
365435296162
591286729879
956722026041
1548008755920
2504730781961
4052739537881
6557470319842
10610209857723
17167680177565
27777890035288
44945570212853
72723460248141
117669030460994
190392490709135
308061521170129
498454011879264
806515533049393
1304969544928657
2111485077978050
3416454622906707
5527939700884757
8944394323791464
14472334024676221
23416728348467685
37889062373143906
61305790721611591
99194853094755497
160500643816367088
259695496911122585
420196140727489673
679891637638612258
1100087778366101931
1779979416004714189
2880067194370816120
4660046610375530309

I know it can generate more Fibonacci numbers, but for purposes of this challenge it is enough to produce these numbers.

JavaScript (Node.js), 91 bytes, Cracked by l4m2
f=x=>[w=~-x&&(g=(n,y=2)=>~-n&&(n<y?1:n%y?g(n,y+1):1+g(n/y,y)))(x)+f(x-1),console.log(w)][0]

Try it online!
Prints the first n terms of the OEIS sequence A022559 (starting from i=1).
l4m2 fit 3 for loops into 74 72 bytes and cracked my cop post:
n=>{for(i=s=0;j=i++<n;console.log(s))for(x=i;j++<i;)for(;x%j<1;x/=j)s++}

However, my intended answer actually has only 2 for loops:
n=>{for(i=c=0;i++<n;console.log(c))for(p=2,z=i;p<=z;z%p?p++:(z/=p,c++));}

Try it online!

hacked

@l4m2 Actually I have a 73-byte one ;) Anyway congrats

Go on golfing guy It's now 72 @user71546

x86 .COM function, 12 bytes, Cracked by NieDzejkob
0000 52                     push dx
0001 4A                     dec dx
0002 7403                   je 0007
0004 E8F9FF                 call 0000
0007 58                     pop ax
0008 F7E0                   mul ax
000A AB                     stosw

000B C3                     ret

Input DX, Output [DI] ~ [DI+2*DX-1]
Cracker's solution:
0: 31 C0    xor ax, ax
2: BF 01 00 mov di, 1
5: 01 F8    add ax, di
7: AB       stosw
8: E2 FB    loop 5
A: C3       ret

Intended solution:
  xor bx,bx
c:inc bx
  mov ax,bx
  mul ax
  stosw
  loop c
  ret

Cracked

I've changed the output method. Can you look?

Gol><>, 15 bytes, cracked by mbomb007
I1AZZ;
M:K:?ZNB

Try it online!
The series is 0,1,2,3,4,5 but each element is followed by that many 0s.
For example, the first few values are:
 1: 0  First element, followed by 0 zeroes
 2: 1  Followed by 1 zero
 3: 0
 4: 2  Followed by 2 zeroes
 5: 0
 6: 0
 7: 3  Followed by 3 zeroes
 8: 0
 9: 0
10: 0
    etc.

Cracked

Python 3, 62 bytes, Cracked by mwchase
def f(x):
 if(x<1):return[1]
 return f(x-1)+[sum(f(x-1)[-2:])]

Try it online!
I feel like this one is going to be too easy...
The sequence is the Fibonacci sequence f(n) = f(n-1) + f(n-2) with f(0) = f(1) = 1

You can switch to an inline ternary statement made out of boolean operators, which puts it in one statement, which can then go directly after the colon. Saves eight bytes, at least.

Switching to lambda saves two (EDIT: four) more.

@mwchase while I appreciate your suggestions and will keep them in mind for future python code golf submissions, I will not be golfing a cops and robbers submission for a couple of reasons. First if I continue to golf it then it sets a moving target for the robber, which is not desired in this type of post. Second golfing this would mean I would need to golf my iterative version as well, which I might not be able to do to the same extent

cracked

JavaScript, 63 bytes, Cracked
f=x=>(x?[f(x-1)[0]&&1?3*f(x-1)[0]+1:f(x-1)[0]/2,...f(x-1)]:[7])

Try it online!
Returns the first n elements in a reversed array

Cracked

Also reversed array returning seem currently not allowed

Windows .BAT, 80 Bytes
@set /a n=%1-1
@echo 8%3
@if 0 neq %n% @call %0 %n% 2%3 6%2%3

Usage:
CD <PATH>
<FILENAME> <N_1>
<FILENAME> <N_2>
<FILENAME> <N_3>

The loop version can assume in the current dictionary, but have to init or reset

Python, 82 bytes; cracked
This is a recursive Python implementation of OEIS sequence A004001 in 82 bytes. More background on this series can  be found on Wolfram's Mathworld.
def A(n):
 if n in[1,2]:return[1]*n
 S=A(n-1);return S+[S[S[n-2]-1]+S[n-S[n-2]-1]]

The first 30 numbers in this sequence are:
1, 1, 2, 2, 3, 4, 4, 4, 5, 6, 7, 7, 8, 8, 8, 8, 9, 10, 11, 12, 12, 13, 14, 14, 15, 15, 15, 16, 16, 16

Cracked

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
This challenge is about recursion (Robbers' thread)
Robbers thread
In this thread, your task is to find a non-recursive solution which produces the same integer series of a submission not marked as 'safe' in the Cops' thread.
Challenge synopsis
In many languages, recursive functions can significantly simplify a programming task. However, the syntax overhead for a proper recursion may limits its usability in code-golf.
The cops will create a program or function taking a single integer n, which will generate the first n entries of an integer series, using only recursion.1.
The robbers will try to find a shorter program or function in the same language, generating the same integer series, using no recursion2.
If the cops' submission is not cracked within ten days (240 hours), the cop will prove it was in fact possible to have a shorter non-recursive approach by revealing their own solution. They may then mark their submission as safe.
The winner of the cops challenge will be the shortest (according to code-golf) recursion-based submission marked safe.
The winner of the robbers challenge will be the robber who cracked the most solutions.
1: It only needs to be recursive in syntax; you don't need to worry about for example tail call optimization.
2: Again, non-recursive in syntax; so you can't post a recursive solution and claim its compiled to a loop thanks to tail call optimization.
Requirements
Each submission will take a single integer n (zero- or one-based). The submission will then output or return the first n entries of the same integer series as the cops' entry. The input and output method may differ between the recursive and non-recursive approach.
Your robbers' entry must be strictly shorter in byte-count than the recursive solution. It must work for at least the same n, or up to n=2^15-1, whichever is smaller.
Recursion
For the sake of this challenge, recursion is defined as creating the desired sequence using a function (or function-like construct) that calls itself (or calls a sequence of functions that ends up calling itself). The recursion depth should go to infinity as n goes to infinity. The non-recursive approach is anything that is not recursive.

Let us continue this discussion in chat.

Now make a mirror question

Python 3, 75 bytes by Bubbler
Python 3, 51 bytes
lambda n:[k for k in range(1,2**n)if 60**k%k<1][:n]

Try it online!
Tests for 5-smoothness of k with 60**k%k<1.

You may have missed my comment, but I consider using the Y combinator a recursive solution.

The robber's solution should be shorter than the cop's, so Y combinator doesn't work in general anyway.

@Sanchises I only saw your comment after posting this. I think this is non-recursive by all definitions I've seen, so I think you should define what it means more cleanly. But I had missed that the new solution needs to be shorter, so the Y combinator method shouldn't work in general.

But the second solution looks good though the current upper bound doesn't work at n>=1000 or so; you can throw in 2**n for correctness, then I'll mark my solution as cracked.

@xnor Interesting, I would've never considered that non-recursive. Any ideas for a good definition which really encompasses the "nested function"-ness that is typical of recursion, whether true recursion or via a helper function?

@Sanchises Well, what makes sense in my head would allow the Y combinator trick, so I don't know how helpful I can be for you here. I would say that a function can do whatever it wants with its arguments, but when its definition mentions another function, we take note of that. And if a function references itself or there's a cycle in the graph of mentions, that's recursive. So, a function can't hide using helper functions inside it. But the Y combinator trick is special in that there's really no cycle in the graph.

@xnor And yet (in your first version), h keeps calling h (well, it's calling g, which just so happens to be h). So there's no cycle in definitions, but there's definitely a cycle going on during execution. And I would consider this a very different cycle than a loop; I would much rather implement mergesort with a Y combinator than with just do-while constructs. So, perhaps the ability to branch into self-similar loops sets my idea of recursion apart from nonrecursion?

@xnor Looking at this SO answer, the Y combinator is described as allows you to implement recursion (first answer), it generalizes recursion (second answer), [it] calculates [...] recursively (third answer). So perhaps it's fair to call using a Y combinator recursive after all? Or are all these answers wrong?

Octave, by Sanchises 27 bytes
There are so many, many ways to do this in a loopy-way. For instance this one, if an explicit loop is needed:
for i=1:input('')disp(i)end

Try it online!
Or, if you want to create a vector (I haven't golfed this terribly well, since using a loop like this is kinda pointless):
x=0;for i=1:input(''),x(i)=i;end,x

Or 7 bytes if it's OK to not use a loop at all:
@(n)1:n

JavaScript (Node.js), by user71546, 74 72 Bytes
n=>{for(i=s=0;j=i++<n;console.log(s))for(x=i;j++<i;)for(;x%j<1;x/=j)s++}

Gol><> by Jo King, 12 bytes iterative
I:FL:R0|rRN;

Try it online
Makes good use of R, the repeat command. Once I thought of this method, I knew it would be shorter than trying to use a for loop within a while loop.
Explanation:
I:              Input and duplicate (will be used at the end to print).
  F             For loop input times.
   L:           Push and duplicate loop counter (leaving one on the stack).
     R0         Pop counter and push that many zeros.
       |        End of loop.
        r       Reverse the stack.
         RN;    Print input times and halt.

List of language commands (D debug is useful for understanding what is going on)
Golfish

https://codegolf.stackexchange.com/a/158075/76323, 78 Bytes
def A(n):
 x=[1]*n
 for i in range(2,n):x[i]=x[x[i-1]-1]+x[i-x[i-1]]
 return x

https://codegolf.stackexchange.com/a/157397/76323, 7 bytes assuming it's not recursive
@(n)1:n

or if use for,
function o=f(n);for i=1:n;disp(i);end;end;

COM function, by l4m2, 11 bytes iterative
0: 31 C0    xor ax, ax
2: BF 01 00 mov di, 1
5: 01 F8    add ax, di
7: AB       stosw
8: E2 FB    loop 5
A: C3       ret

Input CX, output [ES:1] ~ [ES:2*CX] (inclusive)

Is backward array allowed?

@l4m2 I don't see a reason for it to be not allowed, but if you insist, std is one byte.

Asked about that on meta

meta leads to Default for Code Golf: Input/Output methods where only https://codegolf.meta.stackexchange.com/a/13262/76323 matters

Forth (gforth), by jmarkmurphy, 22 bytes iterative
: | 0 do i 1+ . loop ;

Try it online!

JavaScript (Node.js), 45 bytes
x=>[...Array(x)].map(_=>h=h&1?3*h+1:h/2,h=14)

Try it online!

Python 3 by PunPun1000, 59 bytes iterative
def f(x):
 l=[1]
 while x>0:l+=[sum(l[-2:])];x-=1
 return l

I tried my hardest to do a closed-form one-liner, but I only got as low as the original submission.

Couldn’t you just do while x: rather than x>0?

@JoKing Probably. I was basing this off the original code, and I wasn't sure what some of the intent was.