From c4efc8d7d1aebecb2f0518016c14bf9da70bc278 Mon Sep 17 00:00:00 2001 From: Seongbeom Park Date: Sun, 20 Mar 2022 07:38:10 +0900 Subject: [PATCH] Using Burnside lemma Need to implement counting the cycles for each combination * Reference: https://youtu.be/D0d9bYZ_qDY --- level5/disorderly-escape/solution.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/level5/disorderly-escape/solution.py b/level5/disorderly-escape/solution.py index b28a30b..9f8a63c 100644 --- a/level5/disorderly-escape/solution.py +++ b/level5/disorderly-escape/solution.py @@ -1,9 +1,22 @@ +import math + def solution(w, h, s): - return '0' + return str(sum([s**cycle for cycle in generate_cycles(w, h)])/(math.factorial(w)*math.factorial(h))) + +def generate_cycles(w, h): + yield 1 + tests = [ ([2, 3, 4], '430'), ([2, 2, 2], '7'), + ([1, 1, 2], '2'), + ([1, 1, 3], '3'), + ([2, 1, 2], '3'), + ([1, 2, 2], '3'), + ([3, 1, 2], '4'), + ([1, 3, 2], '4'), + ([2, 3, 2], '13'), ] for i, o in tests: