output_description: Output the minimum number of years before your wish will be fulfilled.
input_description: The input is given in the following format.
  
      
      
      n
      
  
  An integer n is given. Its number of digits is from 2 to 100,000, and each
  digit ranges from 1 to 9.
attempt: n = input()
  length = len(n)
  ans = 10
  
  # 2桁,1桁混合
  lst = []
  ind = 0
  while ind < length:
      if n[ind] == "1" and ind + 1 <= length - 1:
          lst.append(int(n[ind : ind + 2]))
          ind += 2
      else:
          lst.append(int(n[ind]))
          ind += 1
  ans = min(ans, max(lst) - min(lst))
  
  # n桁のみ
  divisors = []
  for i in range(1, length // 2 + 1):
      if length % i == 0:
          divisors.append(i)
  
  for i in divisors:
      lst = []
      for j in range(0, length, i):
          lst.append(int(n[j : j + i]))
      ans = min(ans, max(lst) - min(lst))
  
  print(ans)
  
problem_description: Paper Fortune
  
  If you visit Aizu Akabeko shrine, you will find a unique paper fortune on
  which a number with more than one digit is written.
  
  Each digit ranges from 1 to 9 (zero is avoided because it is considered a bad
  omen in this shrine). Using this string of numeric values, you can predict how
  many years it will take before your dream comes true. Cut up the string into
  more than one segment and compare their values. The difference between the
  largest and smallest value will give you the number of years before your wish
  will be fulfilled. Therefore, the result varies depending on the way you cut
  up the string. For example, if you are given a string 11121314 and divide it
  into segments, say, as 1,11,21,3,14, then the difference between the largest
  and smallest is 21 - 1 = 20. Another division 11,12,13,14 produces 3 (i.e. 14
  - 11) years. Any random division produces a game of luck. However, you can
  search the minimum number of years using a program.
  
  Given a string of numerical characters, write a program to search the minimum
  years before your wish will be fulfilled.
samples: [{"input": "11121314", "output": "3"}, {"input": "123125129", "output": "6"}, {"input": "119138", "output": "5"}]