From 4a6109910c67852630b4d5b50d2a1bf465cfbeaa Mon Sep 17 00:00:00 2001 From: deadmarshal Date: Sun, 20 Nov 2022 10:46:28 +0330 Subject: Challenge191 --- challenge-191/deadmarshal/python/ch2.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 challenge-191/deadmarshal/python/ch2.py (limited to 'challenge-191/deadmarshal/python/ch2.py') diff --git a/challenge-191/deadmarshal/python/ch2.py b/challenge-191/deadmarshal/python/ch2.py new file mode 100644 index 0000000000..30ac0b9f78 --- /dev/null +++ b/challenge-191/deadmarshal/python/ch2.py @@ -0,0 +1,15 @@ +from itertools import permutations + +def is_cute(arr): + for i in range(1,len(arr)+1): + if i % arr[i-1] != 0 and arr[i-1] % i != 0: return False + return True + +def cute_list(n): + arr = list(range(1,n+1)) + count = 0 + for perm in permutations(arr): + if is_cute(perm): count += 1 + return count + +print(cute_list(2)) -- cgit