Advertisement
matacoder

Untitled

Dec 14th, 2020
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. n = int(input())
  2. k = int(input())
  3.  
  4.  
  5. def convert_string(iter, position, string='0'):
  6.     if iter == 1:
  7.         return string[-1]
  8.     newstring = ''
  9.     for i in range(0, len(string)):
  10.         if string[i] == '0':
  11.             newstring += '01'
  12.         else:
  13.             newstring += '10'
  14.     iter -= 1
  15.     print(newstring)
  16.     return convert_string(iter, position, newstring[:position])
  17.  
  18.  
  19. print(convert_string(n, k))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement