Last active
July 1, 2019 17:34
-
-
Save manojnaidu619/0a7b7877d5733b741c0a86abfae6aa47 to your computer and use it in GitHub Desktop.
Codechef ATM problem in ruby
This file contains hidden or 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
#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