Код распечатывает все комбинации, кроме индекса [0: 4: 3], и я не понимаю, почему. Я хочу решить это, используя только рекурсию. Поэтому мне интересно, почему он пропускает этот индекс. Если кто-то может объяснить, это помогло бы
combination=[] #create array
re=[3,34,2,1] #list to find all combinations
#name of function
def all_combinations(arr,x,y,z):
# if less than length of array for x let it pass
if x < len(arr)+1:
# if less than length of array for y let it pass
if y < len(arr)+1:
# if less than length of array for z let it pass
if z < (len(arr)+2):
if arr[x:y:z] not in combination:
combination.append(arr[x:y:z]) #add to array
z +=1 #increase z
all_combinations(arr,x,y,z) #recurse
y += 1 #increase y
z=1 #reset index
all_combinations(arr,x,y,z) #recurse
x += 1 #next x
y =0 #reset y
z=1 #reset z
all_combinations(arr,x,y,z) #recurse
all_combinations(re,0,1,1) #call function
print(combination) #print result