title: How to eliminate numbers that do not have different scrambled combinations within the range in Python
body: <p>Prompt is 
  Given integers A and B with the same number of digits and no leading zeroes, how many distinct scrambled pairs (i, j) are there that satisfy: A &lt;= i &lt; j &lt;= B?</p>
  
  <p>For instance, if we let A = 10 and B = 99, the answer is 36:</p>
  
  <pre><code>(12,21), (13,31), (14,41), (15,51), (16,61), (17,71), (18,81), (19,91), (23,32), (24,42), (25,52), (26,62), (27,72), (28,82), (29,92), (34,43), (35,53), (36,63), (37,73), (38,83), (39,93), (45,54), (46,64), (47,74), (48,84), (49,94), (56,65), (57,75), (58,85), (59,95), (67,76), (68,86), (69,96), (78,87), (79,97), (89,98)
  </code></pre>
  
  <p>This is my code:</p>
  
  <pre><code>import random
  import itertools
  
  A = input("Enter integer with no leading zero:")
  B = input("Enter integer greater than A with no leading zero:")
  
  A=int(A)
  B=int(B)
  realArray = []
  myArray = []
  temparray = []
  heyArray = []
  count = 0
  totalcount = 0
  printcount = 0
  x = 0
  
  def checkArray(myArray):
      global x
      global temparray
      for i in myArray:
          x = int(i)
          if x not in temparray:
              temparray.append(x)
  
  
    def allcombos(li):
      global count
      global myArray
      global realArray
      global heyArray
      global temp
      global printcount
      global A
      global B
  
      for subset in itertools.permutations(li, len(li)):
          s = ''.join(map(str, subset))
          if int(s) in range(A,B):
              myArray.append(int(s))
              if len(myArray)&gt; 1:
                 checkArray(myArray)
                  myArray = []
  
  def scrambleint(i):
      i_string = str(i)
      li = list (map(int, i_string))
      allcombos(li)
  
  
  
  def main():
      for i in range(A, B):
          scrambleint(i)
      print (temparray)
      print(len(temparray))
  
  main()
  </code></pre>
  
  <p>My output right now is 89</p>
  
  <pre><code>[10, 11, 12, 21, 13, 31, 14, 41, 15, 51, 16, 61, 17, 71, 18, 81, 19, 91, 20, 22, 23, 32, 24, 42, 25, 52, 26, 62, 27, 72, 28, 82, 29, 92, 30, 33, 34, 43, 35, 53, 36, 63, 37, 73, 38, 83, 39, 93, 40, 44, 45, 54, 46, 64, 47, 74, 48, 84, 49, 94, 50, 55, 56, 65, 57, 75, 58, 85, 59, 95, 60, 66, 67, 76, 68, 86, 69, 96, 70, 77, 78, 87, 79, 97, 80, 88, 89, 98, 90]
  </code></pre>
  
  <p>I want to get rid of numbers such as 10 and 11 from the list that don't have scrambled numbers within the range. (For example the only way to scramble 10 is 01 which is not in the range from A= 10 to B = 99). Any help is appreciated thanks!</p>