https://www.hackerrank.com/challenges/cats-and-a-mouse/problem
HackerRank - Cats and a Mouse
#!/bin/python3
import math
import os
import random
import re
import sys
def catAndMouse(x, y, z):
catA = x - z
catB = y - z
output = ''
if(catA < 0):
catA = catA * -1
if(catB < 0):
catB = catB * -1
if(catA == catB):
output = 'Mouse C'
elif(catA > catB):
output = 'Cat B'
elif(catA < catB):
output = 'Cat A'
return output
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
q = int(input())
for q_itr in range(q):
xyz = input().split()
x = int(xyz[0])
y = int(xyz[1])
z = int(xyz[2])
result = catAndMouse(x, y, z)
fptr.write(result + '\n')
fptr.close()
'알고리즘 문제 풀기 > HackerRank' 카테고리의 다른 글
HackerRank - Electronics Shop (0) | 2019.01.30 |
---|---|
HackerRank - Drawing Book (0) | 2019.01.29 |
HackerRank - Sock Merchant (0) | 2019.01.28 |
HackerRank - Bon Appétit (0) | 2019.01.27 |
HackerRank - Day of the Programmer (0) | 2019.01.25 |