I am working on a project and am getting stuck on the following bit : I have a boolean array and I would like to determine if a specific pattern is present in this array.
For example, let's imagine I have this boolean array : [True, False, False, True, False, False, True, False, True, True, True] and I would like to know if it contains the following pattern [False, False, True, False].
My first idea was to loop through all values of the boolean array, define a variable that counts the number of consecutive "False" then loops again to find if "True" is following that sequence, etc... But it seems a bit tedious and I imagine there is a better way to do this...
Any advice would be very welcomed ! Thank you
Aucun commentaire:
Enregistrer un commentaire