Skip to content

Instantly share code, notes, and snippets.

@mikalai-yankouski
Last active November 22, 2018 20:58
Show Gist options
  • Save mikalai-yankouski/b5c030ca4ff656c0ce76d71b1ef2d023 to your computer and use it in GitHub Desktop.
Save mikalai-yankouski/b5c030ca4ff656c0ce76d71b1ef2d023 to your computer and use it in GitHub Desktop.
В одном массиве записан рост некоторых студентов, а в другом (с тем же числом элементов) - их фамилии в том же порядке, в котором указан рост. Известно, что все студенты разного роста. Напечатайте фамилию самого высокого студента.
require 'faker'
def random_names(n)
Array.new(n) { Faker::Name.unique.name }
end
students = random_names(10)
height_of_students = (150..200).to_a.sample(10)
highest_i = height_of_students.index(height_of_students.max)
puts "The highest student is #{students[highest_i]}, with height: #{height_of_students[highest_i]} cm"
@aya-soft
Copy link

🥇

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