aboutsummaryrefslogtreecommitdiff
path: root/challenge-202/eric-cheung/python/ch-1.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-202/eric-cheung/python/ch-1.py')
-rwxr-xr-xchallenge-202/eric-cheung/python/ch-1.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/challenge-202/eric-cheung/python/ch-1.py b/challenge-202/eric-cheung/python/ch-1.py
new file mode 100755
index 0000000000..b223c4f32c
--- /dev/null
+++ b/challenge-202/eric-cheung/python/ch-1.py
@@ -0,0 +1,16 @@
+
+def IsConsecOdds(arrSubInput):
+ arrSubInput.sort()
+
+ for nIndx in range(0, len(arrSubInput) - 3 + 1):
+ if arrSubInput[nIndx] % 2 == 1 and arrSubInput[nIndx + 1] - arrSubInput[nIndx] == 2 and arrSubInput[nIndx + 2] - arrSubInput[nIndx + 1] == 2:
+ return 1
+
+ return 0
+
+## arrInput = [1, 5, 3, 6] ## Example 1
+## arrInput = [2, 6, 3, 5] ## Example 2
+## arrInput = [1, 2, 3, 4] ## Example 3
+arrInput = [2, 3, 5, 7] ## Example 4
+
+print (IsConsecOdds(arrInput))