Skip to content

Instantly share code, notes, and snippets.

@syusui-s
Last active August 29, 2015 14:09
Show Gist options
  • Save syusui-s/f0ca0a40bd1f1d11d936 to your computer and use it in GitHub Desktop.
Save syusui-s/f0ca0a40bd1f1d11d936 to your computer and use it in GitHub Desktop.
#! ruby -Ku
puts "「一日何本くらい煙草をお吸いに?」"
print "「N本ですね」: "
cigarettes = gets.to_i
puts "「喫煙年数は?」"
print "「N年です」: "
years = gets.to_i
print "「あそこにベンツが停まってますね」\n「はい」\n「もし"
one_cigarette = 22 # yen
bentz_price = 10117800 # 2 * 22 * 365 * (600 + 30)
per_year = cigarettes * one_cigarette * 365
result = (bentz_price - years * per_year) / per_year
if result < 2 then
puts "あなたが煙草を吸わなければ、あれくらい買えたんですよ」"
else
# あなたが煙草を吸っていなかったら、あと%d年であれくらい買えたんですよ
puts "あと%d年タバコを吸わないようにすればあのベンツが買えるんですよ」" % result
puts "「%d年」" % result if result > 50
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment