# Help me in solving SPCP3 problem

### My issue

what is error in my code. it fails at a hidden testcase

### My code

``````# cook your dish here
def marblebig(x,y):
c = 0
while x%y!=0:
x+=1
y-=1
c+=1
return c
def marblesmall(x,y):
c = 0
while y%x!=0:
x-=1
y+=1
c+=1
return c

def marble(x,y):
if x%y==0 or y%x == 0:
return 0
if x>y:
a = marblesmall(x,y)
b = marblebig(x,y)
return min([a,b])
return marblebig(x,y)

t=int(input())
for _ in range(t):
a,b=map(int,input().split())
print(marble(a,b))
``````

Problem Link: Marbles Practice Coding Problem

@anuskcse
plzz refer my c++ code for better understanding of the logic

``````#include <iostream>
using namespace std;

int main() {
// your code goes here
int t;
cin>>t;
while(t--)
{
int a,b;
cin>>a>>b;
int a1=a;
int b1=b;
int cnt=0;
while(b>1)
{
if(a%b==0)
{

break;
}
a++;
b--;
cnt++;
}
//  cout<<cnt<<endl;
a=a1;
b=b1;
int ans=cnt;
cnt=0;
while(a>1)
{
if(a%b==0)
{
ans=min(ans,cnt);
break;
}
a--;
b++;
cnt++;

}
// ans=min(ans,cnt);
cout<<ans<<endl;
}
return 0;
}``````