aboutsummaryrefslogtreecommitdiff
path: root/challenge-202/eric-cheung/python/ch-1.py
diff options
context:
space:
mode:
author冯昶 <fengchang@novel-supertv.com>2023-02-06 18:29:49 +0800
committer冯昶 <fengchang@novel-supertv.com>2023-02-06 18:29:49 +0800
commit0f18fa3badcf6e6ddc58e793c868ce041054a496 (patch)
treead0b6ebe9b4b6b896475079163a282aec6b3fee3 /challenge-202/eric-cheung/python/ch-1.py
parentb99b26aef8b033642ff3794f0fddf6deb3234b43 (diff)
parentf92e84261b474f81c014f4982268d6e2797b66d9 (diff)
downloadperlweeklychallenge-club-0f18fa3badcf6e6ddc58e793c868ce041054a496.tar.gz
perlweeklychallenge-club-0f18fa3badcf6e6ddc58e793c868ce041054a496.tar.bz2
perlweeklychallenge-club-0f18fa3badcf6e6ddc58e793c868ce041054a496.zip
Merge remote-tracking branch 'upstream/master'
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))