Let's say I have the following matrices:
A = [[a row with a lot of numbers],[another row with a lot of numbers], ...]
B = [[num1, num2, num3, num4],[num5, num6, num7, num8], ..., other rows with 4 numbers]
What would be an efficient way to loop through all rows in A checking if:
- num1 and num2 are consecutively in this row
and - num3 and num4 are consecutively in this row
or
- num5 and num6 are consecutively in this row
and - num7 and num8 are consecutively in this row
or... (the same check with every other row in B)
If some of these 'or' happens, return True.
I've managed to do these checks by looping through B for every element in A, but since A is a very long matrix, it's taking too long to run, because I have 4 for loops, one inside of the other. Is there a more efficient way?