A function receives a certain numbers of integers ```n1, n2, n3 ..., np```(all positive and different from 0) and a factor ```k, k > 0```
The function rearranges the numbers ```n1, n2, ..., np``` in such order that generates the minimum number concatenating the digits and this number should be divisible by ```k```.
The order that the function receives their arguments is:
```python
rearranger(k, n1, n2, n3,....,np)
```
## Examples
```python
rearranger(4, 32, 3, 34, 7, 12)  == "Rearrangement: 12, 3, 34, 7, 32 generates: 12334732 divisible by 4"
rearranger(10, 32, 3, 34, 7, 12) == "There is no possible rearrangement"
```
If there are more than one possible arrengement for the same minimum number, your code should be able to handle those cases:
```python
rearranger(6, 19, 32, 2, 124, 20, 22) == "Rearrangements: 124, 19, 20, 2, 22, 32 and 124, 19, 20, 22, 2, 32 generates: 124192022232 divisible by 6"
```
The arrangements should be in sorted order, as you see: `124, 19, 20, 2, 22, 32` comes first than `124, 19, 20, 22, 2, 32`.
Have an enjoyable time!
(Thanks to `ChristianE.Cooper` for his contribution to this kata)
from itertools import permutations

def rearranger(k, *args):
    arguments = []
    numbers = []
    min_num = 10 ** 50
    for arg in [*args]:
        arguments.append(str(arg))
    for perm in permutations(arguments):
        num = int("".join(perm))
        if num % k == 0:
            if num == min_num and not perm in numbers:
                numbers.append(perm)
            if num < min_num:
                min_num = num
                numbers = [perm]
                
    if len(numbers) == 0:
        answer = "There is no possible rearrangement"
    elif len(numbers) == 1:
        nums = ', '.join(numbers[0])
        answer = f"Rearrangement: {nums} generates: {min_num} divisible by {k}"
    elif len(numbers) == 2:
        nums1 = ', '.join(numbers[0])
        nums2 = ', '.join(numbers[1])
        answer = f"Rearrangements: {nums1} and {nums2} generates: {min_num} divisible by {k}"
    return answer
from itertools import permutations

def rearranger(k, *args):
    arguments = []
    numbers = []
    min_num = 10 ** 50
    for arg in [*args]:
        arguments.append(str(arg))
    for perm in permutations(arguments):
        num = int("".join(perm))
        if num % k == 0:
            if num == min_num and not perm in numbers:
                numbers.append(perm)
            if num < min_num:
                min_num = num
                numbers = [perm]
                
    if len(numbers) == 0:
        answer = "There is no possible rearrangement"
    elif len(numbers) == 1:
        nums = ', '.join(numbers[0])
        answer = f"Rearrangement: {nums} generates: {min_num} divisible by {k}"
    elif len(numbers) == 2:
        nums1 = ', '.join(numbers[0])
        nums2 = ', '.join(numbers[1])
        answer = f"Rearrangements: {nums1} and {nums2} generates: {min_num} divisible by {k}"
    return answer