嗨,我是 Fly,用 Ruby 寫 Chatbot 並挑戰30天分享心得
為確保不會沒靈感
每日含 Ruby 解題增加內容
https://www.hackerrank.com/domains/tutorials/30-days-of-code
require 'stringio'
io = StringIO.new
io.puts "Hello World"
io.string #=> "Hello World\n"
#!/bin/ruby
require 'json'
require 'stringio'
# Complete the solve function below.
def solve(meal_cost, tip_percent, tax_percent)
(meal_cost*(100+tip_percent+tax_percent)/100).round
end
meal_cost = ARGF.readline.to_f
tip_percent = ARGF.readline.to_i
tax_percent = ARGF.readline.to_i
p solve meal_cost, tip_percent, tax_percent