import math def solution(brown, red): answer = [] sq_red=int(math.sqrt(red)) a,b=0,0 for num in range(1,sq_red+1): flt_rv=red/num int_rv=red//num if flt_rv==int_rv: flt_bv=(brown+red)/(int_rv+2) int_bv=(brown+red)//(int_rv+2) if flt_bv==int_bv: b=int_bv a=(brown+red)//b answer=[a,b] return answer