Input – list of 24 integers from -15 to 15; let’s call it Sequence. Another input – list of 7000+ lists of four integers from 0 to 23 representing offsets of Sequence. For example [0, 3 , 5,8] or [5,7,7,11]; let’s call them Moves. I need to test each Move against Sequence to see if they match based on certain conditions. The output will be subset of Moves. For example for a Move [0,2,4,7] the code will be
if Sequence[Move[0]]>0 and Sequence[Move[1]]>-1:
OutputList.append(move)
each Move runs primitive conditions like that. I can do it nicely testing every individual Move like this. The problem is that in that approach the same condition runs multiple times. My question is can it be done by using unique conditional statement only once?
I tried different methods, but I am looking for the most efficient one.
John Bird is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1