aboutsummaryrefslogtreecommitdiff
path: root/challenge-199/eric-cheung/python/ch-2.py
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2023-01-23 01:51:15 +0000
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2023-01-23 01:51:15 +0000
commit3a0d3971fee4f0e88baa2cf83e7a4a33b24ca8ec (patch)
tree8c67d01edbb6591029af2b3f44fba80427971172 /challenge-199/eric-cheung/python/ch-2.py
parent297f41de92d136922e9c85c2f8075966d6ef80ed (diff)
downloadperlweeklychallenge-club-3a0d3971fee4f0e88baa2cf83e7a4a33b24ca8ec.tar.gz
perlweeklychallenge-club-3a0d3971fee4f0e88baa2cf83e7a4a33b24ca8ec.tar.bz2
perlweeklychallenge-club-3a0d3971fee4f0e88baa2cf83e7a4a33b24ca8ec.zip
- Added solutions by Roger Bell_West.
- Added solutions by Dave Jacoby. - Added solutions by David Ferrone. - Added solutions by Luca Ferrari. - Added solutions by Mark Anderson. - Added solutions by W. Luis Mochan. - Added solutions by Peter Campbell Smith. - Added solutions by Mariano Spadaccini. - Added solutions by Thomas Kohler. - Added solutions by Bob Lied. - Added solutions by Jorg Sommrey. - Added solutions by Flavio Poletti. - Added solutions by Pip Stuart. - Added solutions by E. Choroba. - Added solutions by Stephen G. Lynn. - Added solutions by Matthew Neleigh. - Added solutions by Robert Ransbottom. - Added solutions by Athanasius. - Added solutions by Simon Green. - Added solutions by Cheok-Yin Fung. - Added solutions by Tyler Wardhaugh. - Added solutions by Jan Krnavek. - Added solutions by Bruce Gray. - Added solutions by James Smith. - Added solutions by Robbie Hatley. - Added solutions by Solathian. - Added solutions by Arne Sommer. - Added solutions by Carlos Oliveira. - Added solutions by Marton Polgar. - Added solutions by Adam Russell. - Added solutions by Duncan C. White. - Added solutions by Lars Balker. - Added solutions by Colin Crain. - Added solutions by Laurent Rosenfeld. - Added solutions by Robert DiCicco. - Added solutions by Ulrich Rieke.
Diffstat (limited to 'challenge-199/eric-cheung/python/ch-2.py')
-rwxr-xr-xchallenge-199/eric-cheung/python/ch-2.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/challenge-199/eric-cheung/python/ch-2.py b/challenge-199/eric-cheung/python/ch-2.py
new file mode 100755
index 0000000000..2ed1c89d29
--- /dev/null
+++ b/challenge-199/eric-cheung/python/ch-2.py
@@ -0,0 +1,25 @@
+
+from itertools import combinations
+
+def get_GoodTriplets_List(arrInput, arrInputInt):
+
+ arrGoodPairsList = []
+
+ nIndxTuple = combinations(range(0, len(arrInput)), 3)
+
+ for nIndxLoop_01, nIndxLoop_02, nIndxLoop_03 in list(nIndxTuple):
+ if abs(arrInput[nIndxLoop_01] - arrInput[nIndxLoop_02]) <= arrInputInt[0] and abs(arrInput[nIndxLoop_02] - arrInput[nIndxLoop_03]) <= arrInputInt[1] and abs(arrInput[nIndxLoop_01] - arrInput[nIndxLoop_03]) <= arrInputInt[2]:
+ arrGoodPairsList.append([nIndxLoop_01, nIndxLoop_02, nIndxLoop_03])
+
+ return arrGoodPairsList
+
+
+## Example 1
+## arrInputList = [3, 0, 1, 1, 9, 7]
+## arrInputList_Int = [7, 2, 3]
+
+## Example 2
+arrInputList = [1, 1, 2, 2, 3]
+arrInputList_Int = [0, 0, 1]
+
+print (len(get_GoodTriplets_List(arrInputList, arrInputList_Int)))