Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Numbers Factory by sts10131
def checkio(number):
result=[[number,0]]
tempResult=[]
help=1
while 1:
for x in result:
for y in range(2,10):
if x[0]%y==0:
tempResult.append([x[0]/y,x[1]*10+y])
if tempResult[-1][0]==1:
return tempResult[-1][1]
if tempResult==[]:
break
else:
result=tempResult[:]
tempResult=[]
return 0
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert checkio(20) == 45, "1st example"
assert checkio(21) == 37, "2nd example"
assert checkio(17) == 0, "3rd example"
assert checkio(33) == 0, "4th example"
assert checkio(3125) == 55555, "5th example"
assert checkio(9973) == 0, "6th example"
Dec. 27, 2016