diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2022-11-15 19:07:06 +0000 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2022-11-15 19:07:06 +0000 |
| commit | d86f0a6e9d60b52336abab61bcf5bcb6aebc6240 (patch) | |
| tree | 0eb0735611da537b53431713de56934d19af7f1a /challenge-191/eric-cheung/python/ch-2.py | |
| parent | c0fd35656b1707cb785e5da2e4c067dcdd6f2aa1 (diff) | |
| download | perlweeklychallenge-club-d86f0a6e9d60b52336abab61bcf5bcb6aebc6240.tar.gz perlweeklychallenge-club-d86f0a6e9d60b52336abab61bcf5bcb6aebc6240.tar.bz2 perlweeklychallenge-club-d86f0a6e9d60b52336abab61bcf5bcb6aebc6240.zip | |
- Added guest contributions by Eric Cheung.
Diffstat (limited to 'challenge-191/eric-cheung/python/ch-2.py')
| -rwxr-xr-x | challenge-191/eric-cheung/python/ch-2.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/challenge-191/eric-cheung/python/ch-2.py b/challenge-191/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..39eb9c5c1e --- /dev/null +++ b/challenge-191/eric-cheung/python/ch-2.py @@ -0,0 +1,35 @@ +
+from itertools import permutations
+
+def IsCuteList(arrInput):
+ for nIndx in range(0, len(arrInput)):
+ if arrInput[nIndx] % (nIndx + 1) != 0 and (nIndx + 1) % arrInput[nIndx] != 0:
+ return False
+
+ return True
+
+## nInput = 2
+## nInput = 3
+## nInput = 4
+## nInput = 5
+## nInput = 6
+## nInput = 7
+## nInput = 8
+## nInput = 9
+## nInput = 10
+## nInput = 11
+## nInput = 12
+## nInput = 13
+## nInput = 14
+nInput = 15
+
+nCount = 0
+
+arrPermList = permutations(list(range(1, nInput + 1)))
+
+for pernLoop in list(arrPermList):
+ if IsCuteList(pernLoop):
+ print (pernLoop)
+ nCount = nCount + 1
+
+print (str(nCount))
|
