6 deleted 2 characters in body
source | link

Python 3, 128 114 111 102 99 bytes

-3 bytes, thanks to Jonathan Frech

f=lambda n,i=1,l=[0]:f(n,i+1,l+[l[i-2::-1].index(l[-1])+1if l[-1]in l[:-1]else 0])if n-in>i else l[-1]

Try it online!Try it online!

Python 3, 128 114 111 102 99 bytes

-3 bytes, thanks to Jonathan Frech

f=lambda n,i=1,l=[0]:f(n,i+1,l+[l[i-2::-1].index(l[-1])+1if l[-1]in l[:-1]else 0])if n-i else l[-1]

Try it online!

Python 3, 128 114 111 102 99 bytes

-3 bytes, thanks to Jonathan Frech

f=lambda n,i=1,l=[0]:f(n,i+1,l+[l[i-2::-1].index(l[-1])+1if l[-1]in l[:-1]else 0])if n>i else l[-1]

Try it online!

5 added 47 characters in body
source | link

Python 3, 128 114 111 102102 99 bytes

-3 bytes, thanks to Jonathan Frech

f=lambda n,i=1,l=(0,)l=[0]:l[-1]if i==n else f(n,i+1,l+(l[il+[l[i-2::-1].index(l[-1])+1if l[-1]in l[:-1]else 0,)0])if n-i else l[-1]

Try it online!Try it online!

Python 3, 128 114 111 102 bytes

f=lambda n,i=1,l=(0,):l[-1]if i==n else f(n,i+1,l+(l[i-2::-1].index(l[-1])+1if l[-1]in l[:-1]else 0,))

Try it online!

Python 3, 128 114 111 102 99 bytes

-3 bytes, thanks to Jonathan Frech

f=lambda n,i=1,l=[0]:f(n,i+1,l+[l[i-2::-1].index(l[-1])+1if l[-1]in l[:-1]else 0])if n-i else l[-1]

Try it online!

4 deleted 5 characters in body
source | link

Python 3, 128 114 111111 102 bytes

f=lambda n,i=1,l=(0,):l[-1]if i==n else f(n,i+1,l+(0if l[-1]not in l[:-1]else l[len(l)l[i-2::-1].index(l[-1])+1+1if l[-1]in l[:-1]else 0,))

Try it online!Try it online!

Python 3, 128 114 111 bytes

f=lambda n,i=1,l=(0,):l[-1]if i==n else f(n,i+1,l+(0if l[-1]not in l[:-1]else l[len(l)-2::-1].index(l[-1])+1,))

Try it online!

Python 3, 128 114 111 102 bytes

f=lambda n,i=1,l=(0,):l[-1]if i==n else f(n,i+1,l+(l[i-2::-1].index(l[-1])+1if l[-1]in l[:-1]else 0,))

Try it online!

3 added 4 characters in body
source | link
2 added 3 characters in body
source | link
1
source | link