From 90c1b5a124fe2e150b4ecf6f087d6e15b4e71649 Mon Sep 17 00:00:00 2001 From: Roger Bell_West Date: Sun, 5 Feb 2023 00:32:08 +0000 Subject: RogerBW solutions for challenge no. 202 --- challenge-202/roger-bell-west/python/ch-1.py | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 challenge-202/roger-bell-west/python/ch-1.py (limited to 'challenge-202/roger-bell-west/python/ch-1.py') diff --git a/challenge-202/roger-bell-west/python/ch-1.py b/challenge-202/roger-bell-west/python/ch-1.py new file mode 100755 index 0000000000..1700e2824b --- /dev/null +++ b/challenge-202/roger-bell-west/python/ch-1.py @@ -0,0 +1,30 @@ +#! /usr/bin/python3 + +import unittest + +def consecutiveodds(a): + i = 0 + for v in a: + if v % 2 == 1: + i += 1 + if i >= 3: + return True + else: + i = 0 + return False + +class TestConsecutiveodds(unittest.TestCase): + + def test_ex1(self): + self.assertEqual(consecutiveodds([1, 5, 3, 6]), True, 'example 1') + + def test_ex2(self): + self.assertEqual(consecutiveodds([2, 6, 3, 5]), False, 'example 2') + + def test_ex3(self): + self.assertEqual(consecutiveodds([1, 2, 3, 4]), False, 'example 3') + + def test_ex4(self): + self.assertEqual(consecutiveodds([2, 3, 5, 7]), True, 'example 4') + +unittest.main() -- cgit