Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. def count_presentations(n):
  2.     print("n =", n)
  3.     global options
  4.     sub_bars = []
  5.     print("подстроки: ")
  6.     for i in range(len(n) - 1):
  7.         option = n[i: i + 2]
  8.         if option not in sub_bars:
  9.             sub_bars.append(option)
  10.             print("\t", option)
  11.     for i in sub_bars:
  12.         if int(n) != int(n[0]) + int(n[1]):
  13.             j = n.find(i)
  14.             n = n[:j] + str(int(n[j]) + int(n[j+1])) + n[j + 2:]
  15.             print("Новый n =", n)
  16.             if n not in options:
  17.                 options.append(n)
  18.                 count_presentations(n)
  19. n =int(input())
  20. options = ["1" * n]
  21. count_presentations(options[0])
  22. print(len(options))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement