Solve hanging lantern problem: Difference between revisions

(Added solution for Pascal.)
Line 636:
 
=={{header|Python}}==
; ==Recursive version==
<lang python>
def getLantern(arr):
Line 654:
a.append(int(input()))
print(getLantern(a))
</lang>
==Math solution==
<lang python>
import math
n = int(input())
a = []
tot = 0
for i in range(0, n):
a.append(int(input()))
tot += a[i]
res = math.factorial(tot)
for i in range(0, n):
res /= math.factorial(a[i])
print(int(res))
</lang>
 
43

edits