Problem: A positive integer X is said to be a lunlun number if and only if the following condition is satisfied:    * In the base ten representation of X (without leading zeros), for every pair of two adjacent digits, the absolute difference of those digits is at most 1.  For example, 1234, 1, and 334 are lunlun numbers, while none of 31415, 119, or 13579 is.  You are given a positive integer K. Find the K-th smallest lunlun number.

Submission attempts (in order):
import queue
K = int(intut())
q = queue.Queue()
for i in range(9):
  q.put(i + 1)
for i in range(K):
  tmp = q.get()
  if tmp % 10 == 0:
    q.put(10 * tmp)
    q.put(10 * tmp + 1)
  elif tmp % 10 == 9:
    q.put(10 * tmp + 8)
    q.put(10 * tmp + 9)
  else:
    for t in range(-1,2):
      q.put(10 * tmp + tmp % 10 + t)
print(tmp)

import queue
K = int(intut())
q = queue.Queue()
ans = 0
for i in range(9):
  q.put(i + 1)
for i in range(K):
  ans = q.get()
  if tmp % 10 == 0:
    q.put(10 * tmp)
    q.put(10 * tmp + 1)
  elif tmp % 10 == 9:
    q.put(10 * tmp + 8)
    q.put(10 * tmp + 9)
  else:
    for t in range(-1,2):
      q.put(10 * tmp + tmp % 10 + t)
print(ans)


import numpy as np
K = int(input())
lis = ['1','2','3','4','5','6','7','8','9']
lis = np.array(lis)
if K == 1:
  print(1)
elif K < 10:
  print(K)
else:
  count = 9
  sub_count = 0
  while count < K:
    tmp = lis[sub_count]
    if tmp[-1] == '9':
      count += 2
      lis.append(tmp + '8')
      lis.append(tmp + '9')
      sub_count += 1
    elif  tmp[-1] == '0':
      count += 2
      lis.append(tmp + '0')
      lis.append(tmp + '1')
      sub_count += 1
    else:
      count += 3
      for i in range(-1,2):
        lis.append(tmp + str(int(tmp[-1]) + i))
      sub_count += 1
  print(lis[count-1])


import numpy as np
K = int(input())
lis = ['1','2','3','4','5','6','7','8','9']
lis = np.array(lis)
if K == 1:
  print(1)
elif K < 10:
  print(K)
else:
  count = 9
  sub_count = 0
  while count < K:
    if lis[sub_count][-1] == '9':
      count += 2
      lis.append(lis[sub_count] + '8')
      lis.append(lis[sub_count] + '9')
      sub_count += 1
    elif  lis[sub_count][-1] == '0':
      count += 2
      lis.append(lis[sub_count] + '0')
      lis.append(lis[sub_count] + '1')
      sub_count += 1
    else:
      count += 3
      for i in range(-1,2):
        lis.append(lis[sub_count] + str(int(lis[sub_count][-1]) + i))
      sub_count += 1
  print(lis[count-1])

import numpy as np
K = int(input())
lis = [1,2,3,4,5,6,7,8,9]
lis = np.array(lis)
  
if K < 10:
  print(K)
    
else:
  count = 9
  sub_count = 0
  while count < K:
    tmp = lis[sub_count]
    if tmp % 10 == 9:
      count += 2
      lis.append(tmp * 10  + 8)
      lis.append(tmp * 10 + 9)
      sub_count += 1
    elif  tmp % 10== 0:
      count += 2
      lis.append(tmp * 10 )
      lis.append(tmp * 10 + 1)
      sub_count += 1
    else:
      count += 3
      for i in range(-1,2):
        lis.append(tmp * 10 + tmp % 10 + i)
      sub_count += 1
  print(lis[count-1])


import numpy as np
K = int(input())
lis = [1,2,3,4,5,6,7,8,9]
lis = np.array(lis)
  
if K < 10:
  print(K)
    
else:
  count = 9
  sub_count = 0
  while count < K:
    tmp = lis[sub_count]
    if tmp % 10 == 9:
      count += 2
      lis.append(tmp * 10  + 8)
      lis.append(tmp + 9)
      sub_count += 1
    elif  tmp % 10== 0:
      count += 2
      lis.append(tmp * 10 + 0)
      lis.append(tmp * 10 + 1)
      sub_count += 1
    else:
      count += 3
      for i in range(-1,2):
        lis.append(tmp * 10 + tmp % 10 + i)
      sub_count += 1
  print(lis[count-1])


import queue
K = int(input())
q = queue.Queue()
count = 0
for i in range(1,10):
  q.put(str(i))
while count < K:
  tmp = q.get()
  count += 1
  if count == K:
    print(tmp)
    break
  if tmp[-1] == '0':
    for k in ['0', '1']:
      q.put(tmp + k)
  elif tmp[-1] == '9':
    for t in ['8', '9']:
      q.put(tmp + t)
  else:
    for c in [str(int(tmp[-1]) - 1),tmp[-1], str(int(tmp[-1]) + 1)]:
      q.put(tmp + c)

    


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted