title: Simplify multiple nested loop
body: <p>for a math riddle i wrote that python program to bruteforce the solutions. ABCD * 3 = EFGHI with each ABCDEFGHI different from each other (and 3 of course).</p>
  <pre><code>#   Game looking like : ****
  #                       X   3
  #                     = *****
  # with each * diferent from others and is in interval [0-9] except 3 (as the last * being imposed)
  
  
  import time
  t1 = time.time()
  occurence = 0
  for a in range(0,10):
      if a == 3 : continue    
      tn = time.time()
      delta = tn - t1
      # each number should be different so a,b,c,d,e,f,g,h,i are
      # each one and unique number in [0-9] excluding 3    
      for b in range(0,10):
          if a == b or b == 3 : continue
          
          for c in range(0,10):
              if a == c or b ==c or c == 3 : continue
              for d in range(0,10):
                  if d==a or d==b or d==c or d == 3 : continue
                  for e in range(0,10):
                      if e==a or e==b or e==c or e==d or e == 3: continue
                      for f in range(0,10):
                          if f ==a or f==b or f==c or f==d or f==e or f == 3: continue
                          for g in range(0,10):
                              if g ==a or g==b or g==c or g==d or g==e or g==f or g == 3: continue
                              for h in range(0,10):
                                  if h ==a or h==b or h==c or h==d or h==e or h==f or h==g or h == 3: continue
                                  for i in range(0,10):
                                      if i == a or i==b or i==c or i==d or i==e or i==f or i==g or i==h  or i == 3: continue
                                      first = 1000*a + 100*b + 10*c + d
                                      result = 10000*e + 1000*f + 100*g + 10*h + i
                                      if (first *3 == result):
                                          #on a un gagnant
                                          occurence +=1
                                          print(first, &quot;* 3 =&quot;, result)
                                          t2 = time.time()
  print(occurence, &quot;positiv results&quot;)
  print(t2-t1, &quot;seconds&quot;)
  </code></pre>
  <p>I'm pretty sure this code could have been way lighter using list and that's why i post today.</p>