Google-Foobar/2.a. bunny-prisoner-locating/solution.py
2024-04-16 02:50:37 -07:00

20 lines
382 B
Python

def solution(x, y):
prisonerID = 0
#traverse down the x axis first
i = x
while i > 0:
prisonerID += i
i -= 1
#traverse up the y axis second
while y > 1:
prisonerID += x
x += 1
y -= 1
#return the string of the id
return str(prisonerID)
print "Case 1,1: " + solution(1,1)