I am trying to do this: spoj.pl/problems/GCD/
import itertools as it
def gcd(a,b):
if b==0: return a
return gcd(b,a%b)
s=raw_input()
while s:
t=int(s)
ans=0
for i in set(it.permutations(s)):
ans=gcd(t,int(''.join(i)))
print ans
s=raw_input()
I checked for the itertools module. It is acceptable at SPOJ.
I think maybe the problem lies with ''.join(i), but I am not getting any testcases for it. Any help is appreciated..