We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
It shouldn't be. It goes over the two lists twice. What if they have 1M elements? This is not really readable, but should be faster. The bool translates ai-bi to 1 if there is a difference, or 0. The if/else gives (b,0) if Alice wins, and (0,b) if it is a draw or Bob wins, where b is 0 if the scores are equal, and 1 otherwise.
Compare the Triplets
You are viewing a single comment's thread. Return to all comments →
It shouldn't be. It goes over the two lists twice. What if they have 1M elements? This is not really readable, but should be faster. The bool translates ai-bi to 1 if there is a difference, or 0. The if/else gives (b,0) if Alice wins, and (0,b) if it is a draw or Bob wins, where b is 0 if the scores are equal, and 1 otherwise.
Then again, for larger arrays using numpy and looping twice would be faster (and simpler) than the custom python solution: