Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Numbers Factory by flowerinapot
def checkio(number):
#replace this for solution
res = '99999999999999'
for n in range(9, 1, -1):
temp = ''
temp_check = 1
delet = n
num_check = number
while num_check >= 10 and delet > 1:
if num_check % delet != 0:
delet -= 1
continue
else:
num_check = num_check / delet
temp += str(delet)
if num_check < 10:
temp += str(int(num_check))
for r in temp:
temp_check *= int(r)
if temp_check == number and int(temp[::-1]) < int(res):
res = temp[::-1]
if res == '99999999999999':
return 0
else:
return int(res)
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"
print("Coding complete? Click 'Check' to review your tests and earn cool rewards!")
May 3, 2023