Skip to main content
2 of 4
added 228 characters in body
mbomb007
  • 23.5k
  • 7
  • 63
  • 135

#Python 2, 116 bytes

Meh. Not that short. The simple iterative solution.

L=[1,2,3]
n=input()
while len(L)<n:
 for i in range(2,n):
    if L.count(i)<L[i-1]and L[-1]!=i:L+=[i];break
print L[-1]

Try it online

Here's a really bad attempt at a recursive solution (128 bytes):

def f(n,L=[1,2,3]):
 if len(L)>=n:print L[-1];exit(0)
 for i in range(2,n):
    if L.count(i)<L[i-1]and L[-1]!=i:f(n,L+[i])
 f(n,L)
mbomb007
  • 23.5k
  • 7
  • 63
  • 135