SHARE
TWEET

Untitled

a guest Jun 15th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import itertools
  2. A=[10, 20, 30,40]
  3. B=[11,21,31,41]
  4. list_solutions = []
  5.  
  6.  
  7. for x in range (1,min(len(A),len(B))+1):
  8.     newA = list(itertools.combinations(A,x))
  9.     newB = list(itertools.combinations(B,x))
  10.     for itemA in newA:
  11.         for itemB in newB:
  12.             to_print = True
  13.             for index in range (min(len(itemA),len(itemB))):
  14.                 if itemA[index] >= itemB[index]:
  15.                     to_print = False
  16.                     break
  17.             if to_print == True:
  18.                 list_solutions.append([itemA, itemB])
  19.  
  20. #Print only valid solutions:
  21. for item in list_solutions:
  22.     print_valid = True
  23.     for index in range (len(item[0])):
  24.         if item[0][index] >= item[1][index]:
  25.             print_valid = False
  26.             break
  27.         if index >= 1:
  28.             if item[0][index] <= item[1][index-1]:
  29.                 print_valid = False
  30.                 break
  31.     if print_valid == True:
  32.         for index in range (len(item[0])):
  33.             print (item[0][index], item[1][index], sep = " ", end = " ")
  34.         print ("")
  35.     if print_valid == False:
  36.         continue
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top