diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2023-02-04 14:04:38 +0000 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2023-02-04 14:04:38 +0000 |
| commit | 8d9cfd8d2ac39bb5d0b0f7452bf57d200bbdd62f (patch) | |
| tree | 0e3759046de6e318d1c9e8e305f683b4324d43c6 /challenge-202/eric-cheung/python/ch-1.py | |
| parent | 1b0c04f4b45857a5b8024860663bf58f353bf1ed (diff) | |
| download | perlweeklychallenge-club-8d9cfd8d2ac39bb5d0b0f7452bf57d200bbdd62f.tar.gz perlweeklychallenge-club-8d9cfd8d2ac39bb5d0b0f7452bf57d200bbdd62f.tar.bz2 perlweeklychallenge-club-8d9cfd8d2ac39bb5d0b0f7452bf57d200bbdd62f.zip | |
- Added solutions by james Smith.
- Added solutions by Luca Ferrari.
- Added solutions by Aut0exec.
- Added solutions by W. Luis Mochan.
- Added solutions by Bob Lied.
- Added solutions by David Ferrone.
- Added solutions by E. Choroba.
- Added solutions by Mark Anderson.
- Added solutions by Robbie Hatley.
- Added solutions by Dave Jacoby.
- Added solutions by Thomas Kohler.
- Added solutions by Jaldhar H. Vyas.
- Added solutions by Peter Campbell Smith.
- Added solutions by Mariano Spadaccini.
- Added solutions by Jorg Sommrey.
- Added solutions by Pip Stuart.
- Added solutions by Simon Green.
- Added solutions by Laurent Rosenfeld.
- Added solutions by Ulrich Rieke.
- Added solutions by Robert DiCicco.
Diffstat (limited to 'challenge-202/eric-cheung/python/ch-1.py')
| -rwxr-xr-x | challenge-202/eric-cheung/python/ch-1.py | 16 |
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))
|
