Monday, August 6, 2018

Drawing Book : Algorithms - Implementation

#The solution in Python3 is as follows:


n=int(input())
p=int(input())
if (n%2!=0 and p%2!=0) or (n%2!=0 and p%2==0) or (n%2==0 and p%2==0):
        print(min(p//2,(n-p)//2))
elif n%2==0 and p%2!=0:
        print(min(p//2,((n-p)//2)+1))

#Keep visiting for more solutions of HackerRank problems in Python 3.Thank you!!!