parent
8d8cc46bde
commit
8a8d9cfdd8
@ -0,0 +1,11 @@
|
||||
def task1(array)
|
||||
indices = array.each_with_index.to_a
|
||||
sorted_indices = indices.sort_by { |(element, index)| -element }
|
||||
result = sorted_indices.map { |(element, index)| index }
|
||||
result
|
||||
end
|
||||
|
||||
# Ex
|
||||
array = [5, 3, 8, 1, 7]
|
||||
puts "Indices in order of decreasing elements:"
|
||||
puts task1(array).join(", ")
|
Loading…
Reference in new issue