import itertools

num = [9, 5, 8, 4, 9, 4, 10]
num_dict = {'0': 9, '1': 5, '2': 8, '3': 4, '4': 9, '5': 4, '6': 10}
length = len(num)
index = []
num_sort = sorted(num)
# print([i for i,v in enumerate(num) if v == 5])
# print(num[1:].index(9))

# for i in range(length):
#     num_total = list(itertools.combinations(num_sort, length - i))
#     for x in num_total:
#         for y in list(x):
#             if ()
#             index.append(str(num.index(y)))
#         if "".join(index) == "".join(sorted("".join(index))):
#             print(x)
#             print(len(x))
#             exit()
#         index.clear()

num_total = list(itertools.combinations(num_sort, 4))
for x in num_total:
    print(x)
    for y in list(x):
        temp = [i for i, v in enumerate(num) if v == y]
        if (len(temp) > 1):
            # for z in temp:
            #     index.append(str(z))
            pass
        else:
            index.append(str(temp[0]))

    if "".join(index) == "".join(sorted("".join(index))):
        print(x)
        print(len(x))
        exit()
    index.clear()





@@ -700,24 +700,45 @@
 rint(x)%0A
+    x_list = list(x)%0A
     for 
 y in lis
@@ -729,30 +729,124 @@
     for 
-y
+i
  in 
-list(x):%0A
+range(len(x_list)):%0A        if i %3C len(x_list) - 1:%0A            if x_list%5Bi%5D != x_list%5Bi + 1%5D:%0A        
         
@@ -853,23 +853,23 @@
 temp = %5B
-i
+y
  for 
-i
+y
 , v in e
@@ -890,17 +890,25 @@
 if v == 
-y
+x_list%5Bi%5D
 %5D%0A      
@@ -909,20 +909,54 @@
         
+ 
-if (
+       if x_list.count(x_list%5Bi%5D) == 
 len(temp
@@ -960,13 +960,8 @@
 emp)
- %3E 1)
 :%0A  
@@ -974,23 +974,50 @@
     
-#
+        index.extend(%5Bstr(x)
  for 
-z
+x
  in temp
 :%0A  
@@ -1012,16 +1012,39 @@
  in temp
+%5D)%0A                else
 :%0A      
@@ -1049,17 +1049,19 @@
         
+ 
-#
+  
      ind
@@ -1078,12 +1078,40 @@
 str(
-z
+temp%5B0%5D
 ))%0A
+            else:%0A    
     
@@ -1153,39 +1153,36 @@
     
-index.append(str(temp%5B0%5D)
+pass%0A    print(index
 )%0A%0A   
+ #
  if 
@@ -1231,24 +1231,26 @@
 ndex))):%0A   
+ #
      print(x
@@ -1250,24 +1250,26 @@
 print(x)%0A   
+ #
      print(l
@@ -1278,24 +1278,26 @@
 (x))%0A       
+ #
  exit()%0A    

Update Combination temp1