## Check Digits

Some numbers are more important to get right during data entry than others: a common example is product codes.

To reduce the possibility of mistakes, product codes can be crafted in such a way that simple errors are detected. This is done by calculating a single-digit value based on the product number, and then appending that digit to the product number to arrive at the product code.

When the product code is checked, the check digit value is stripped off and recalculated. If the supplied value does not match the recalculated value, the product code is rejected.

A simple scheme for generating self-check digits, described here, is called Modulus 11 Self-Check.

## Calculation method

Each digit in the product number is assigned a multiplication factor. The factors are assigned ***from right to left***, starting at `2` and counting up. For numbers longer than six digits, the factors restart at `2` after `7` is reached. The product of each digit and its factor is calculated, and the products summed. For example:

```python
digit     :  1    6    7    7    0    3    6    2    5
factor    :  4    3    2    7    6    5    4    3    2
           ---  ---  ---  ---  ---  ---  ---  ---  ---
             4 + 18 + 14 + 49 +  0 + 15 + 24 +  6 + 10 = 140
```

Then the sum of the products is divided by the prime number `11`. The remainder is inspected, and:

* if the remainder is `0`, the check digit is also `0`
* if the remainder is `1`, the check digit is replaced by an uppercase `X`
* for all others, the remainder is subtracted from `11`

The result is the **check digit**.

## Your task

Your task is to implement this algorithm and return the input number with the correct check digit appended.

## Examples

```python
input: "036532"

product sum = 2*2 + 3*3 + 5*4 + 6*5 + 3*6 + 0*7 = 81
remainder   = 81 mod 11 = 4
check digit = 11 - 4 = 7

output: "0365327"
```

Source: codewars | Difficulty: EASY

Starter code: def add_check_digit(number):
	

Solutions:
from itertools import cycle

def add_check_digit(number):
	fact = cycle([2, 3, 4, 5, 6, 7])
	r = sum((int(c) * next(fact) for c in number[::-1])) % 11
	return number + ('0' if not r else 'X' if r == 1 else str(11 - r))


from itertools import cycle

def add_check_digit(s):
	rem = 11 - sum((int(a) * b for (a, b) in zip(reversed(s), cycle(range(2, 8))))) % 11
	return '{}{}'.format(s, {10: 'X', 11: 0}.get(rem, rem))


def add_check_digit(n):
	rem = sum(((i % 6 + 2) * int(d) for (i, d) in enumerate(n[::-1]))) % 11
	return f"{n}{('X' if rem == 1 else 11 - rem if rem else 0)}"


def add_check_digit(n):
	s = sum((int(n[-1 - i]) * (i % 6 + 2) for i in range(len(n))))
	return n + [str(11 - s % 11), ['X', '0'][s % 11 == 0]][s % 11 < 2]


from itertools import cycle

def add_check_digit(number):
	it = cycle(range(2, 8))
	rem = sum((int(n) * i for (n, i) in zip(reversed(number), it))) % 11
	return number + '0X987654321'[rem]


def add_check_digit(number):
	checksum = sum((int(d) * (2, 3, 4, 5, 6, 7)[i % 6] for (i, d) in enumerate(reversed(number))))
	checkdigit = 11 - checksum % 11
	return number + str({11: 0, 10: 'X'}.get(checkdigit, checkdigit))


add_check_digit = lambda s: s + '0X987654321'[sum(((i % 6 + 2) * int(d) for (i, d) in enumerate(s[::-1]))) % 11]


def add_check_digit(n):
	rem = sum(((i % 6 + 2) * int(d) for (i, d) in enumerate(n[::-1]))) % 11
	return f"{n}{'0X987654321'[rem]}"


from itertools import cycle
from operator import mul

def add_check_digit(number):
	x = sum(map(mul, cycle(range(2, 8)), map(int, str(number)[::-1]))) % 11
	return number + ('0' if x == 0 else 'X' if x == 1 else str(11 - x))