ATM problem - What test cases are failing in this case?

In the ATM Problem I submitted this code in Python 2.7

def p():
    draw, balance = map (float,raw_input().split())
    
    if draw % 5 == 0 and draw <= (balance + 0.5):
        balance -= (draw + 0.5)
        
    print "%.2f" %balance

p()

What test cases is this failing? This is my first time with online judging and I am not sure what kind of problem this code is facing.

EDIT:

def p():
    draw, balance = map (float,raw_input().split())

    if draw % 5 == 0 and (draw + 0.5) <= balance:
        balance -= (draw + 0.5)
        print "%.2f" %balance
     
p()

I have tried this also but this isn’t working either.

@anshbansal >> This is the AC version of your code.

Your mistake:

if draw % 5 == 0 and draw <= (balance + 0.5)

Correct line:

if draw % 5 == 0 and draw + 0.5 <= balance

Here is your AC code:

def p():
   draw, balance = map (float,raw_input().split())
    
   if int(draw) % 5 == 0 and (draw + 0.5) < balance:
       balance -= (draw + 0.5)
   print "%.2f" %balance
    
p()

Changes:

  • int(draw) % 5 == 0
  • (draw + 0.5) < balance
  • Cleared indentation of print statement

Hope it helps, Best Luck :slight_smile:

Y is it showing 0 answers but u had answered the question?

1 Like

@rakeshbubli143 >> Its called a hack! :smiley:

:smiley: Teach me :slight_smile:

@rakeshbubli143 >> What? Where 0 answer? Its showing 1 answer. :stuck_out_tongue:

dude… :stuck_out_tongue:

This isn’t working either.

Click on my solution. Click on “This” in my answer.

i think it can be (draw+0.5)<=balance, since condition possible when both are equal but still u can withdraw money…:slight_smile:

Actually (draw+ 0.5) <= balance works. I was messing up the indentation. Your code can fail if the balance is 55.5 and the draw is 55.

Got AC with same solution, see this link CodeChef: Practical coding for everyone