A number is simply made up of digits.  
The number 1256 is made up of the digits 1, 2, 5, and 6.  
For 1256 there are 24 distinct permutations of the digits:  
1256, 1265, 1625, 1652, 1562, 1526, 2156, 2165, 2615, 2651, 2561, 2516,   
5126, 5162, 5216, 5261, 5621, 5612, 6125, 6152, 6251, 6215, 6521, 6512.
  
Your goal is to write a program that takes a number, n, and returns the average value of all distinct permutations of the digits in n.  Your answer should be rounded to the nearest integer. For the example above the return value would be 3889. * 
  
  n will never be negative
  
A few examples:
```python
permutation_average(2)
return 2

permutation_average(25)
>>> 25 + 52 = 77
>>> 77 / 2 = 38.5
return 39 *

permutation_average(20)
>>> 20 + 02 = 22
>>> 22 / 2 = 11
return 11

permutation_average(737)
>>> 737 + 377 + 773 = 1887
>>> 1887 / 3 = 629
return 629

```

Note: Your program should be able to handle numbers up to 6 digits long
~~~if:python
\* Python version 3 and above uses Banker Rounding so the expected values for those tests would be 3888 and 38 respectively
~~~
~~~if-not:python
\* ignore these marks, they're for Python only
~~~

Difficulty: introductory

Starter code:

def permutation_average(n):
	

Solutions:
from itertools import permutations

def permutation_average(n):
    perms = [float(''.join(e)) for e in permutations(str(n))]
    return int(round(sum(perms) / len(perms)))


def permutation_average(n):
    n = str(n)
    n, l = sum(map(int, n)) / float(len(n)), len(n)
    
    n = n * ((10 ** l - 1) / 9)
    
    return round(n)


def permutation_average(n):
    n = str(n)
    avg = sum(map(int, n)) / len(n)
    return round(avg * int("1" * len(n)))

from itertools import permutations

def permutation_average(n):
    a = [int("".join(x)) for x in set(permutations(str(n)))]
    return round(float(sum(a)) / len(a))

from itertools import permutations

def permutation_average(n):
  perms = [float(''.join(x)) for x in permutations(str(n))]
  return round(sum(perms) / len(perms))

from itertools import permutations
from math import factorial

def permutation_average(n):
    return round(sum(int(''.join(x)) for x in permutations(str(n))) / float(factorial(len(str(n)))))

from math import factorial


def permutation_average(n):
    m = len(str(n))
    s = sum(map(int, str(n)))
    return round(sum(s * 10 ** i for i in range(m)) / float(m))

def permutation_average(n):
    digits = [int(i) for i in str(n)]
    length = len(str(n))
    
    def factorial(n): 
        if n is 1 or n is 0:
            return 1
        else:
            return n * factorial(n-1)

    averager = factorial(length) #denominator of the average

    def get_coefficient(width): #after adding up all the digits, a pattern is seen dependent on
        coefficient = 0  #the number of digits there are. This exploits that
        if width <= 1:
            coefficient = 1
        else:
            for x in range(width):
                coefficient += factorial(width-1)*(10**x)

        return coefficient

    total = 0
    for index in digits:  #just multiplying the same coefficient (ironically enough) with every digit
        multiplier = get_coefficient(length)
        total += multiplier * index

    average = total/float(averager)
    avg = int(round(average, 0))
    return avg