diff options
| author | Dave Jacoby <jacoby.david@gmail.com> | 2022-11-20 14:22:01 -0500 |
|---|---|---|
| committer | Dave Jacoby <jacoby.david@gmail.com> | 2022-11-20 14:22:01 -0500 |
| commit | dd682dfee966fe63cbfbbbf6a9cb903b1d831416 (patch) | |
| tree | a71619e10c8dcd29fc13a08beb1325f4a7bc5a84 /challenge-191/eric-cheung | |
| parent | d6d01468fd7a5647b9ba96ebf7a0157ff79f3352 (diff) | |
| parent | bde0adaf7b8dfe99c4e494c932d8702eb8cf9a56 (diff) | |
| download | perlweeklychallenge-club-dd682dfee966fe63cbfbbbf6a9cb903b1d831416.tar.gz perlweeklychallenge-club-dd682dfee966fe63cbfbbbf6a9cb903b1d831416.tar.bz2 perlweeklychallenge-club-dd682dfee966fe63cbfbbbf6a9cb903b1d831416.zip | |
Merge branch 'master' of https://github.com/manwar/perlweeklychallenge-club
Diffstat (limited to 'challenge-191/eric-cheung')
| -rwxr-xr-x | challenge-191/eric-cheung/python/ch-1.py | 16 | ||||
| -rwxr-xr-x | challenge-191/eric-cheung/python/ch-2.py | 35 |
2 files changed, 51 insertions, 0 deletions
diff --git a/challenge-191/eric-cheung/python/ch-1.py b/challenge-191/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..1ea6346e91 --- /dev/null +++ b/challenge-191/eric-cheung/python/ch-1.py @@ -0,0 +1,16 @@ +
+## arrInputList = [1, 2, 3, 4] ## Example 1
+## arrInputList = [1, 2, 0, 5] ## Example 2
+## arrInputList = [2, 6, 3, 1] ## Example 3
+arrInputList = [4, 5, 2, 3] ## Example 4
+
+arrInputList_Sort = list(set(arrInputList))
+arrInputList_Sort.sort()
+
+## print (arrInputList[-1])
+## print (arrInputList[-2])
+
+if arrInputList[-1] > 2 * arrInputList[-2]:
+ print ("1")
+else:
+ print ("-1")
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))
|
