Problem Statement
Martha is interviewing at Subway. One of the rounds of the interview requires her to cut a bread of size $\ell \times b$ into smaller identical pieces such that each piece is a square having maximum possible side length with no left over piece of bread.
$\ell$ and $b$ denote the length and breadth of the bread, respectively.
The way I approached it:
def restaurant(l, b):
area = l * b
list1 = []
for i in range(1, int(math.sqrt(area)) + 1):
d = i * i
a = area % d
if a == 0:
list1.append(d)
list1.sort(reverse=True)
return area // list1[0]
But this code is failing 11 of 12 test cases.
What is my mistake?