aboutsummaryrefslogtreecommitdiff
path: root/challenge-199/eric-cheung/python/ch-1.py
diff options
context:
space:
mode:
author冯昶 <fengchang@novel-supertv.com>2023-01-30 10:57:33 +0800
committer冯昶 <fengchang@novel-supertv.com>2023-01-30 10:57:33 +0800
commita785019bfb14427d0bb59ab53197e4b052e2b571 (patch)
treee0cc4d1621b596c327750f5c7b3100b68f03ca35 /challenge-199/eric-cheung/python/ch-1.py
parentde8820341c75c44bfa1b66dcaccbd9116681067e (diff)
parentcf6032137206c6845182d0211fa1aa2097ae85c3 (diff)
downloadperlweeklychallenge-club-a785019bfb14427d0bb59ab53197e4b052e2b571.tar.gz
perlweeklychallenge-club-a785019bfb14427d0bb59ab53197e4b052e2b571.tar.bz2
perlweeklychallenge-club-a785019bfb14427d0bb59ab53197e4b052e2b571.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-199/eric-cheung/python/ch-1.py')
-rwxr-xr-xchallenge-199/eric-cheung/python/ch-1.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/challenge-199/eric-cheung/python/ch-1.py b/challenge-199/eric-cheung/python/ch-1.py
new file mode 100755
index 0000000000..5227a2c7b1
--- /dev/null
+++ b/challenge-199/eric-cheung/python/ch-1.py
@@ -0,0 +1,20 @@
+
+from itertools import combinations
+
+def get_GoodPairs_List(arrInput):
+
+ arrGoodPairsList = []
+
+ nIndxTuple = combinations(range(0, len(arrInput)), 2)
+
+ for nIndxLoop_01, nIndxLoop_02 in list(nIndxTuple):
+ if arrInput[nIndxLoop_01] == arrInput[nIndxLoop_02]:
+ arrGoodPairsList.append([nIndxLoop_01, nIndxLoop_02])
+
+ return arrGoodPairsList
+
+## arrInputList = [1, 2, 3, 1, 1, 3] ## Example 1
+## arrInputList = [1, 2, 3] ## Example 2
+arrInputList = [1, 1, 1, 1] ## Example 3
+
+print (len(get_GoodPairs_List(arrInputList)))