aboutsummaryrefslogtreecommitdiff
path: root/challenge-241/eric-cheung/python/ch-1.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-241/eric-cheung/python/ch-1.py')
-rwxr-xr-xchallenge-241/eric-cheung/python/ch-1.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/challenge-241/eric-cheung/python/ch-1.py b/challenge-241/eric-cheung/python/ch-1.py
new file mode 100755
index 0000000000..6e19580d14
--- /dev/null
+++ b/challenge-241/eric-cheung/python/ch-1.py
@@ -0,0 +1,28 @@
+
+from itertools import combinations
+
+def IsAriTriplet (arrInput, nDiffInput):
+ if arrInput[1] - arrInput[0] != nDiffInput:
+ return False
+ if arrInput[2] - arrInput[1] != nDiffInput:
+ return False
+ return True
+
+
+## Example 1
+## arrNum = [0, 1, 4, 6, 7, 10]
+## nDiff = 3
+
+## Example 2
+arrNum = [4, 5, 6, 7, 8, 9]
+nDiff = 2
+
+
+arrCombList = combinations(arrNum, 3)
+arrOutputList = []
+
+for arrLoop in list(arrCombList):
+ if IsAriTriplet(arrLoop, nDiff):
+ arrOutputList.append(arrOutputList)
+
+print (len(arrOutputList))