+ 13
CHALLENGE: Permutation of digits 💻⌨️🖱️
Level: easy Initial number n is an integer greater than 0. Try to rearrange the digits of the initial number so that the new number is divisible by inital number (the new number contains exactly the same digits as the initial number, but in a different order) . For example: Input: 100035 Output: Possible (300105) 300105/10035=3 Input: 102345 Output: Impossible NOTE: ✔️ Use any language. 🚫 Don't use: String, char or char array. https://code.sololearn.com/cuzywif8t9r7/?ref=app
8 odpowiedzi
+ 1
https://code.sololearn.com/cneNRX712MWQ/?ref=app
+ 3
trying
+ 3
I couldn't work out a way in python in which I wouldn't have to use a string if I gave an input. But here is my try with input.
https://code.sololearn.com/c3l5QqWibfXh/?ref=app
+ 1
Good, I work.
+ 1
+ 1
For digits, I replaced the dictionary with the list and removed the check for presence in it - it seems to me that this should work faster.
Для цифр заменил словарь на список и убрал проверку на присутствие в нём - мне кажется, что так должно работать быстрее.
https://code.sololearn.com/csdrXhOC6hCR/?ref=app
+ 1
I deliberately refused to go through all the permutations of the digits, since for large numbers this is too slow.