given two arrays I'm trying to get all the different combinations of the arrays with no repeats of sequences and without using itertools. My problem comes when I try to combine a 2 dimensional
array with a 1 dimensional array. given arrays [1,2],[1,3],[1,4],[2,3],[2,4] and [1,2,3,4] I want it to yield [1,2,3],[1,2,4],[1,3,4],[2,3,4]. currently it will produce [1,2,3], [1,2,4] and [1,3,4] but not [2,3,4] and I can't figure out why.
What I have tried:
change_array = [1,2],[1,3],[1,4],[2,3],[2,4]
base_array = [1,2,3,4]
save_array = []
def candidate_generation2(change_array, base_array, save_array):
current_iteration = []
for x in range(0, len(change_array)):
d = []
for y in range(0, len(change_array[0])):
d.append(change_array[x][y])
for z in range(x + 1, len(base_array)):
e = d.copy()
tag = 0
for a in range(0, len(e)):
if e[a] == base_array[z]:
tag = 1
if tag == 0:
e.append(base_array[z])
save_array.append(e)
current_iteration.append(e)
chenge_array = current_iteration.copy()
candidate_generation2(change_array, base_array, save_array)
print(save_array)<pre>
thanks in advance for any help