Skip to content

Instantly share code, notes, and snippets.

@andriiburka
Created February 21, 2020 22:49
Show Gist options
  • Save andriiburka/e7cb80a6da5fbee9d22d8489c2504733 to your computer and use it in GitHub Desktop.
Save andriiburka/e7cb80a6da5fbee9d22d8489c2504733 to your computer and use it in GitHub Desktop.
def permute(nums):
result_perms = [[]]
for num in nums:
new_perms = []
for perm in result_perms:
for i in range(len(perm) + 1):
new_perms.append(perm[:i] + [num] + perm[i:])
result_perms = new_perms
return reversed(result_perms)
digits_list = []
digit = 0
while len(digits_list) < 3:
digit = int(input())
digits_list.append(digit)
divider = sum(digits_list)
new_int_list = []
is_possible = False
length_list = len(new_int_list)
for x in permute(digits_list):
x = str(x)[1:-1]
a = int(''.join(x.split(', ')))
new_int_list.append(a)
new_int_list.sort(reverse=True)
new_int_list = set(new_int_list)
for y in new_int_list:
if y % divider == 0:
result = f'{y / divider}:0f'
is_possible = True
else:
result = y / divider
if is_possible:
print('Digitivision successful!')
else:
print('No digitivision possible.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment