python section of array compare 1

python section of array compare

def binary_isArrayInArray(main_array, compare_array):
    for i in range(len(main_array)-len(compare_array)):
        temp_array = []
        for j in range(len(compare_array)):
            temp_array.append(main_array[i + j])
        print(f'{temp_array} xor {compare_array} = {np.any(np.logical_xor(temp_array, compare_array))}')
        if np.any(np.logical_xor(temp_array, compare_array)) == False: return True

    return False
#takes in two binary arrays and looks wether the second one is part of the first one

Here is what the above code is Doing:
1. It takes in two arrays
2. It creates a temporary array
3. It checks if the temporary array is equal to the second array
4. If it is, it returns True
5. If it isn’t, it moves the temporary array one index to the right and checks again
6. If it reaches the end of the first array, it returns False

Similar Posts