Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

Efficient algorithm for comparing lists [closed]

$
0
0

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.


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>