Skip to content

Instantly share code, notes, and snippets.

@mattisebastian
Created August 14, 2015 05:15
Show Gist options
  • Save mattisebastian/62f9372485c8cfdf638d to your computer and use it in GitHub Desktop.
Save mattisebastian/62f9372485c8cfdf638d to your computer and use it in GitHub Desktop.
def stockprice(prices)
puts "From the stocks:\n"
prices.each { |x| puts x}
to_buy = prices.min
prices.delete(to_buy)
to_sell = prices.max
puts "Buy for : #{to_buy}$\n"
puts "Sell for: #{to_sell}$\n"
puts "For a profit of #{to_sell - to_buy}$"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment