Created
July 29, 2021 19:50
-
-
Save tsangwpx/971e70bd93eb9653f26e9d6e38557896 to your computer and use it in GitHub Desktop.
argmin in pure Python
This file contains hidden or 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 argmin(seq: Sequence[int]): | |
indices = range(len(seq)) | |
return min(indices, key=seq.__getitem__) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment