Created
July 12, 2023 04:24
-
-
Save steshaw/92fc9b06399048b8ad61a96c4b13dc6d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def parity(p): | |
return sum( | |
1 | |
for (x, px) in enumerate(p) | |
for (y, py) in enumerate(p) | |
if x < y and px > py | |
) % 2 == 0 | |
print(parity([1,2,3])) | |
print(parity([1,2,3,4])) | |
print(parity([3,1,2,4])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment