diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2024-09-29 19:41:10 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-29 19:41:10 +0100 |
| commit | 994174d6863980e2fd017bc613671453c7f9368e (patch) | |
| tree | fc01a7b6d382f206d16208ca14b7ee5b20e95a1c /challenge-288/sgreen/python/test.py | |
| parent | 9437b5a4b5fa7e256f5afd0e347ccc81149bc136 (diff) | |
| parent | 84ff106a8fcdd33662eaa42e6f196f390eda7e3b (diff) | |
| download | perlweeklychallenge-club-994174d6863980e2fd017bc613671453c7f9368e.tar.gz perlweeklychallenge-club-994174d6863980e2fd017bc613671453c7f9368e.tar.bz2 perlweeklychallenge-club-994174d6863980e2fd017bc613671453c7f9368e.zip | |
Merge pull request #10918 from simongreen-net/master
sgreen solutions to challenge 288
Diffstat (limited to 'challenge-288/sgreen/python/test.py')
| -rwxr-xr-x | challenge-288/sgreen/python/test.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/challenge-288/sgreen/python/test.py b/challenge-288/sgreen/python/test.py new file mode 100755 index 0000000000..51af278fbe --- /dev/null +++ b/challenge-288/sgreen/python/test.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 + +import unittest +ch_1 = __import__('ch-1') +ch_2 = __import__('ch-2') + + +class TestClass(unittest.TestCase): + def test_ch_1(self): + self.assertEqual(ch_1.closest_palindrome(123), 121) + self.assertEqual(ch_1.closest_palindrome(2), 1) + self.assertEqual(ch_1.closest_palindrome(1400), 1441) + self.assertEqual(ch_1.closest_palindrome(1001), 999) + + def test_ch_2(self): + matrix_1 = [ + ['x', 'x', 'x', 'x', 'o'], + ['x', 'o', 'o', 'o', 'o'], + ['x', 'o', 'o', 'o', 'o'], + ['x', 'x', 'x', 'o', 'o'], + ] + + matrix_2 = [ + ['x', 'x', 'x', 'x', 'x'], + ['x', 'o', 'o', 'o', 'o'], + ['x', 'x', 'x', 'x', 'o'], + ['x', 'o', 'o', 'o', 'o'], + ] + + matrix_3 = [ + ['x', 'x', 'x', 'o', 'o'], + ['o', 'o', 'o', 'x', 'x'], + ['o', 'x', 'x', 'o', 'o'], + ['o', 'o', 'o', 'x', 'x'], + ] + + self.assertEqual(ch_2.contiguous_block(matrix_1), 11) + self.assertEqual(ch_2.contiguous_block(matrix_2), 11) + self.assertEqual(ch_2.contiguous_block(matrix_3), 7) + + +if __name__ == '__main__': + unittest.main() |
