Skip to content

Instantly share code, notes, and snippets.

@manojnaidu619
Last active July 1, 2019 17:34
Show Gist options
  • Save manojnaidu619/0a7b7877d5733b741c0a86abfae6aa47 to your computer and use it in GitHub Desktop.
Save manojnaidu619/0a7b7877d5733b741c0a86abfae6aa47 to your computer and use it in GitHub Desktop.
Codechef ATM problem in ruby
#problem link : https://www.codechef.com/problems/HS08TEST
$stdin.each do |num|
arr = num.strip.split(/\s+/).map(&:to_f)
final = arr.last - arr.first - 0.50
if (arr.first % 5) == 0 and arr.first < arr.last and arr.first > 0 and final >= 0
puts ('%.2f' % final)
else
puts ('%.2f' % arr.last)
end
end
=begin
'%.2f' % value <-- This returns 2 digits after decimal of the given value
=end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment