Skip to content

Instantly share code, notes, and snippets.

@JoshuaPaulBarnard
Created May 19, 2021 12:02
Show Gist options
  • Save JoshuaPaulBarnard/12a98a2101b0c7165b24bd40191dadb4 to your computer and use it in GitHub Desktop.
Save JoshuaPaulBarnard/12a98a2101b0c7165b24bd40191dadb4 to your computer and use it in GitHub Desktop.
Get the position of all the max values
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