simple-exercises/ruby-exercises/easy-1.rb
# Write a method that takes an array of numbers in. Your method should
# return the third greatest number in the array. You may assume that
# the array has at least three numbers in it.
Write a method that takes an array of numbers in. Your method should
return the third greatest number in the array. You may assume that
the array has at least three numbers in it.
Write a method that takes an array of numbers in . Your method should return the third greatest number in the array . You may assume that the array has at least three numbers in it .
def third_greatest(nums)
  first, second, third = nil, nil, nil
  nums.each do |n|
    if first == nil or n > first
      first, second, third = n, first, second
    elsif second == nil or n > second
      second, third = n, second
    elsif third == nil or n > third
      third = n
    end
  end
  third
end
def third_greatest ( nums ) first , second , third = nil , nil , nil nums . each do | n | if first == nil or n > first first , second , third = n , first , second elsif second == nil or n > second second , third = n , second elsif third == nil or n > third third = n end end third end
Write a method that takes an array of numbers in.
Write a method that takes an array of numbers in .
nums
<not_specific>