Skip to content

Instantly share code, notes, and snippets.

@darya-makarenko
Last active December 16, 2018 21:02
Show Gist options
  • Save darya-makarenko/591b444b39e56cd4f1b333a7822f62d0 to your computer and use it in GitHub Desktop.
Save darya-makarenko/591b444b39e56cd4f1b333a7822f62d0 to your computer and use it in GitHub Desktop.
#gets the index of the biggest height and
#extracts the surname at this index
def get_surname_of_tallest(height_arr, surname_arr)
tallest_index = height_arr.index(height_arr.max)
surname_arr[tallest_index]
end
puts "Enter the heights of students"
heights = gets.chomp.split.map(&:to_i)
puts "Enter the surnames of students"
surnames = gets.chomp.split
puts "The tallest student is #{get_surname_of_tallest(heights, surnames)}"
@aya-soft
Copy link

  1. Как короче записать? .map{ |el| el.to_i }

@aya-soft
Copy link

🥇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment