From 8d9cfd8d2ac39bb5d0b0f7452bf57d200bbdd62f Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Sat, 4 Feb 2023 14:04:38 +0000 Subject: - 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. --- challenge-202/eric-cheung/python/ch-1.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 challenge-202/eric-cheung/python/ch-1.py (limited to 'challenge-202/eric-cheung/python/ch-1.py') 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)) -- cgit