Sunday, July 29, 2018

Cats and a Mouse : Algorithms - Implementation

#The solution in Python3 is as follows:


for _ in range(int(input())):
    x,y,z=map(int,input().split())
    if x==y:
        print("Mouse C")
    elif x==z:print("Cat A")
    elif y==z:print("Cat B")
    elif (x>z and y<z) or (x<z and y>z):
        if abs(x-z)==abs(y-z):
            print("Mouse C")
        elif min(abs(x-z),abs(y-z))==abs(x-z):
            print("Cat A")
        else:
            print("Cat B")

    elif (x<z and y<z and x<y) or (x<z and y<z and x>y):
        a=max(x,y)
        if a==y:
            print("Cat B")
        else:
            print("Cat A")
    elif (x>z and y>z and y>x) or (x>z and y>z and y<x):
        b=min(x,y)
        if b==x:
            print("Cat A")
        else:
            print("Cat B")

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