My task is to select the highest and lowest numbers from the array. I think I have a good idea of ββwhat I want to do, but I'm just trying to access the information in the correct format to meet the criteria for passing.
def high_and_low(numbers)
array = numbers.split(" ").map! {|x| x.to_i}
array.sort! {|a,b| b <=> a}
puts array[0, -1]
end
The numbers may look like "80 9 17 234 100"
, and for the transfer I need to print "9 234"
. I tried puts array.first.last
, but could not figure it out.
source
share