Created
May 19, 2021 12:02
-
-
Save JoshuaPaulBarnard/12a98a2101b0c7165b24bd40191dadb4 to your computer and use it in GitHub Desktop.
Get the position of all the max values
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 allmax_positions( input_array ): | |
if len(input_array) == 0: | |
return [] | |
positions_of_max_values = [0] | |
the_max_values = input_array[0] | |
for counter_i in range(1, len(input_array)): | |
if input_array[counter_i] > the_max_values: | |
positions_of_max_values = [counter_i] | |
the_max_values = input_array[counter_i] | |
elif input_array[counter_i] == the_max_values: | |
positions_of_max_values.append(counter_i) | |
return positions_of_max_values |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment