Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions disorderly_escape.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,16 @@ def cycle_partitions(n, i=1):
for p in cycle_partitions(n-i, i):
yield [i] + p

def answer(w, h, s):
def solution(w, h, s):
grid=0
for cpw in cycle_partitions(w):
for cph in cycle_partitions(h):
m=cycle_count(cpw, w)*cycle_count(cph, h)
grid+=m*(s**sum([sum([gcd(i, j) for i in cpw]) for j in cph]))

return grid//(factorial(w)*factorial(h))
print grid//(factorial(w)*factorial(h))

print answer(3, 3, 3)
#print answer(3, 3, 3)


#this will surely 100% work by Pratik Ghule