Given a list of stack heights, calculate the number of ways those heights could have been arrived at by stacking blocks one at a time. Shortest code wins.
Test cases:
[2, 2] 6
[3,3,3] 1680
[1,5,9,1] 480480
[] 1
[10] 1
[2,2,2,10] 720720
Reference Python implementation:
def stacking_count(stacks):
if sum(stacks) == 0:
return 1
count = 0
for i, n in enumerate(stacks):
if n == 0:
continue
stacks[i] -= 1
count += stacking_count(stacks)
stacks[i] += 1
return count