Assessment For Team Lead - Quality Testing at Emoha
Assessment For Team Lead - Quality Testing at Emoha
Code:
def flatten_array(nested_array):
a = []
else:
a.append(item)
return a
result = flatten_array(input_array)
print (f"The flattened array with all the element are: {result}")
Output:
The array of arbitrary depth : [1, [2, [3, [4]], 5], 6]
The flattened array with all the element are: [1, 2, 3, 4, 5, 6]
Q2. Implement a function to find all subsets of an array.
Code:
def find_subset(array):
sets = [[]]
for i in sets:
new.append(i + [element])
sets = new + sets
return sets
result = find_subset(input_array)
print(f'The subsets of the array : {result}')
Output:
The array entered: [1, 2, 3]
The subsets of the array : [[], [1], [2], [1, 2], [3], [1, 3], [2, 3], [1, 2, 3]]