Perhaps it would be convenient to solve first ```Probabilities for Sums in Rolling Cubic Dice``` see at: http://www.codewars.com/kata/probabilities-for-sums-in-rolling-cubic-dice

Suppose that we roll dice that we never used, a tetrahedral die that has only 4 sides(values 1 to 4), or perhaps better the dodecahedral one with 12 sides and 12 values (from 1 to 12), or look! an icosahedral die with 20 sides and 20 values (from 1 to 20).

Let's roll dice of same type and try to see the distribution of the probability for all the possible sum values.

Suppose that we roll 3 tetrahedral dice:
```
Sum   Prob    Amount of hits           Combinations
3   0.015625     1             {1,1,1}
4   0.046875     3             {1,2,1},{2,1,1},{1,1,2}
5   0.09375      6             {3,1,1},{1,1,3},{1,2,2},{1,3,1},{2,2,1},{2,1,2}
6   0.15625     10             {2,2,2},{1,3,2},{3,2,1},{1,4,1},{2,1,3},{1,1,4},{4,1,1},{3,1,2},{1,2,3},{2,3,1}
7   0.1875      12             {2,3,2},{1,2,4},{2,1,4},{1,4,2},{3,2,2}, {4,2,1},{3,3,1},{3,1,3},{2,2,3},{4,1,2},{2,4,1},{1,3,3}
8   0.1875      12             {2,3,3},{3,3,2},{2,2,4},{4,3,1},{2,4,2},{4,1,3},{4,2,2},{3,4,1},{1,3,4},{3,2,3},{3,1,4},{1,4,3}
9   0.15625     10             {3,3,3},{4,4,1},{2,4,3},{4,2,3},{4,3,2},{1,4,4},{4,1,4},{3,4,2},{2,3,4},{3,2,4}
10  0.09375      6             {3,4,3},{4,4,2},{3,3,4},{4,2,4},(2,4,4),{4,3,3}
11  0.046875     3             {4,3,4},{3,4,4},{4,4,3}
12  0.015625     1             {4,4,4}
tot: 1.0000
```
Note that the total sum of all the probabilities for each end has to be ```1.0000```

The register of hits per each sum value will be as follows:
```
[[3, 1], [4, 3], [5, 6], [6, 10], [7, 12], [8, 12], [9, 10], [10, 6], [11, 3], [12, 1]]
```
Create the function ```reg_sum_hits()``` that receive two arguments:

- number of dice, ```n```
- number of sides of the die, ```s```

The function will output a list of pairs with the sum value and the corresponding hits for it.

For the example given above:
```python
reg_sum_hits(3, 4) == [[3, 1], [4, 3], [5, 6], [6, 10], [7, 12], [8, 12], [9, 10], [10, 6], [11, 3], [12, 1]]
```
You will find more examples in the Example Test Cases.

Assumption: If the die has n sides, the values of it are from ```1``` to ```n```

Source: codewars | Difficulty: EASY
Tags: Combinatorics

Mathematics

Probability

Starter code: def reg_sum_hits(n, s):
	

Solutions:
def reg_sum_hits(dices, sides=6):
	(d, s) = (sides * [1], sides - 1)
	for i in range(dices - 1):
		t = s * [0] + d + s * [0]
		d = [sum(t[i:i + sides]) for i in range(len(t) - s)]
	return [[i + dices, prob] for (i, prob) in enumerate(d)]


reg_sum_hits = lambda n, s: sorted(map(list, __import__('collections').Counter(map(sum, __import__('itertools').product(range(1, s + 1), repeat=n))).items()))


def reg_sum_hits(n, s):
	faces = list(range(1, s + 1))
	sums = []
	for r in range(n):
		if not sums:
			new_sums = [[f, 1] for f in faces]
		else:
			new_sums = []
			for (value, count) in sums:
				for f in faces:
					new_sums.append([value + f, count])
			new_sums.sort()
			i = 0
			while i < len(new_sums) - 1:
				(a, b) = new_sums[i:i + 2]
				if a[0] == b[0]:
					new_sums[i:i + 2] = [[a[0], a[1] + b[1]]]
				else:
					i += 1
		sums = new_sums
	return sums


from collections import Counter
from itertools import product

def reg_sum_hits(n, s):
	return list(map(list, sorted(Counter(map(sum, product(range(1, s + 1), repeat=n))).items())))


from itertools import product

def reg_sum_hits(n, s):
	d = {}
	for i in product(*[list(range(1, s + 1))] * n):
		r = sum(i)
		d[r] = d.get(r, 0) + 1
	return list(map(list, d.items()))


import itertools

def reg_sum_hits(diceAmount, sides):
	possibilities = calculatepermutations(sides, diceAmount)
	sumvalues = calculatesumvalues(sides, diceAmount)
	distributionofsums = calculatedist(possibilities, sumvalues)
	return distributionofsums

def calculatepermutations(sides, diceAmount):
	facevalues = (i for i in range(1, sides + 1))
	allpermutations = itertools.product(facevalues, repeat=diceAmount)
	return [sum(i) for i in allpermutations]

def calculatesumvalues(sides, diceAmount):
	biggestnumber = sides * diceAmount
	smallestnumber = diceAmount
	return (i for i in range(smallestnumber, biggestnumber + 1))

def calculatedist(possibilities, sumvalues):
	return [[i, possibilities.count(i)] for i in sumvalues]


import itertools
import collections

def reg_sum_hits(num_dice, sides):
	rollsums = [sum(x) for x in itertools.product([side for side in range(1, sides + 1)], repeat=num_dice)]
	return [[k, v] for (k, v) in sorted(collections.Counter(rollsums).items())]


from itertools import product
from collections import Counter

def reg_sum_hits(n, s):
	return sorted([[k, v] for (k, v) in Counter((sum(p) for p in product(*[[i for i in range(1, s + 1)] for _ in range(n)]))).items()])


from itertools import product

def reg_sum_hits(n, s):
	pairs = [[i, 0] for i in range(n, n * s + 1)]
	for i in product(range(1, s + 1), repeat=n):
		sum = 0
		for j in i:
			sum += j
		index = sum - n
		pairs[index][1] += 1
	return pairs