diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2023-11-15 21:58:16 +0000 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2023-11-15 21:58:16 +0000 |
| commit | 46bef5068ef2a61feb02ee68942af6cb9b1bbafe (patch) | |
| tree | 152fd486af72f4fb4faa5ce11b4911f96ab9d6cc /challenge-243/eric-cheung/python | |
| parent | 98ed69a96a5be7e2e3da225d28af307323aaa4c0 (diff) | |
| download | perlweeklychallenge-club-46bef5068ef2a61feb02ee68942af6cb9b1bbafe.tar.gz perlweeklychallenge-club-46bef5068ef2a61feb02ee68942af6cb9b1bbafe.tar.bz2 perlweeklychallenge-club-46bef5068ef2a61feb02ee68942af6cb9b1bbafe.zip | |
- Added solutions by E. Choroba.
- Added solutions by Dave Jacoby.
- Added solutions by Matthew Neleigh.
- Added solutions by Luca Ferrari.
- Added solutions by Roger Bell_West.
- Added solutions by Mariano Spadacinni.
- Added solutions by Bob Lied.
- Added solutions by Peter Meszaros.
- Added solutions by Jaldhar H. Vyas.
- Added solutions by Robbie Hatley.
- Added solutions by Athanasius.
- Added solutions by Ali Moradi.
- Added solutions by Clifton Wood.
- Added solutions by Ulrich Rieke.
- Added solutions by Peter Campbell Smith.
Diffstat (limited to 'challenge-243/eric-cheung/python')
| -rwxr-xr-x | challenge-243/eric-cheung/python/ch-1.py | 18 | ||||
| -rwxr-xr-x | challenge-243/eric-cheung/python/ch-2.py | 13 |
2 files changed, 31 insertions, 0 deletions
diff --git a/challenge-243/eric-cheung/python/ch-1.py b/challenge-243/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..9ee2534f4b --- /dev/null +++ b/challenge-243/eric-cheung/python/ch-1.py @@ -0,0 +1,18 @@ +
+from itertools import combinations
+
+def IsReversePair (arrInput):
+ if arrInput[0] > 2 * arrInput[1]:
+ return True
+ return False
+
+
+## arrNum = [1, 3, 2, 3, 1] ## Example 1
+arrNum = [2, 4, 3, 5, 1] ## Example 2
+
+
+arrCombList = combinations(arrNum, 2)
+arrOutputList = [arrLoop for arrLoop in list(arrCombList) if IsReversePair(arrLoop)]
+
+
+print (len(arrOutputList))
diff --git a/challenge-243/eric-cheung/python/ch-2.py b/challenge-243/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..8d186c9bf5 --- /dev/null +++ b/challenge-243/eric-cheung/python/ch-2.py @@ -0,0 +1,13 @@ +
+from itertools import combinations
+
+def GetFloorSum (arrInput):
+ return int(arrInput[0] / arrInput[1]) + int(arrInput[1] / arrInput[0])
+
+## arrNum = [2, 5, 9] ## Example 1
+arrNum = [7, 7, 7, 7, 7, 7, 7] ## Example 2
+
+arrCombList = combinations(arrNum, 2)
+nSum = len(arrNum) + sum([GetFloorSum(arrLoop) for arrLoop in list(arrCombList)])
+
+print (nSum)
|
