-
-
Save anonymous/306f0a1fe2a694c9a0b54ba41e244b71 to your computer and use it in GitHub Desktop.
coupon.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ruby coupon.py 100 50 5 | |
# 1-50|2-100|3-150|4-200|5-250 | |
# ruby coupon.rb 199 155 10 | |
# 1-44|2-88|3-132|4-176|5-220|6-264|7-308|8-352|9-396|10-440 | |
reg = ARGV[0].to_i | |
sale = ARGV[1].to_i | |
coupon_max = ARGV[2].to_i | |
price = reg - sale | |
coupon = '' | |
1.upto(coupon_max) do |index| | |
coupon << "#{index}-#{price * index}|" | |
end | |
coupon = coupon[0...-1] | |
puts coupon |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment