finish level5/disorderly-escape #8
@ -9,7 +9,10 @@ def solution(w, h, s):
|
|||||||
if c not in memo_sp:
|
if c not in memo_sp:
|
||||||
memo_sp[c] = s ** c
|
memo_sp[c] = s ** c
|
||||||
cases += memo_sp[c]
|
cases += memo_sp[c]
|
||||||
return str(cases / (memo_f[w] * memo_f[h]))
|
result = cases
|
||||||
|
result /= memo_f[w]
|
||||||
|
result /= memo_f[h]
|
||||||
|
return str(result)
|
||||||
|
|
||||||
def generate_cycle_count(w, h, memo_f = {}):
|
def generate_cycle_count(w, h, memo_f = {}):
|
||||||
memo_c = {}
|
memo_c = {}
|
||||||
@ -75,7 +78,9 @@ def count_permutation(s, memo_f, memo_p):
|
|||||||
for size, freq in group.items():
|
for size, freq in group.items():
|
||||||
if freq not in memo_f:
|
if freq not in memo_f:
|
||||||
memo_f[freq] = math.factorial(freq)
|
memo_f[freq] = math.factorial(freq)
|
||||||
result /= memo_f[freq] * (size ** freq)
|
result /= memo_f[freq]
|
||||||
|
for i in range(freq):
|
||||||
|
result /= size
|
||||||
memo_p[s] = result
|
memo_p[s] = result
|
||||||
return memo_p[s]
|
return memo_p[s]
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user