diff options
Diffstat (limited to 'challenge-273/bruce-gray/python/ch-2.py')
| -rwxr-xr-x | challenge-273/bruce-gray/python/ch-2.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/challenge-273/bruce-gray/python/ch-2.py b/challenge-273/bruce-gray/python/ch-2.py new file mode 100755 index 0000000000..d1ce92088f --- /dev/null +++ b/challenge-273/bruce-gray/python/ch-2.py @@ -0,0 +1,19 @@ +#!python +import re + +def task2(str): + p = re.compile('^[^b]*b[^a]*$') + return bool(p.match(str)) + + +import unittest +class TestTask1(unittest.TestCase): + def t(self, str, expected): + self.assertEqual(task2(str), expected, f"task2('{str}')") + + def test_1(self): self.t('aabb' , True ) + def test_2(self): self.t('abab' , False) + def test_3(self): self.t('aaa' , False) + def test_4(self): self.t('bbb' , True ) + +unittest.main() |
