diff options
| author | Simon Green <mail@simon.green> | 2024-09-28 23:13:22 +1000 |
|---|---|---|
| committer | Simon Green <mail@simon.green> | 2024-09-28 23:13:22 +1000 |
| commit | 84ff106a8fcdd33662eaa42e6f196f390eda7e3b (patch) | |
| tree | fe59361ce3680b372756b51b9fec02e741f0a259 /challenge-288/sgreen/python/test.py | |
| parent | 5d153977cad3f0d33e3f3512f7e61f249e0ceee8 (diff) | |
| download | perlweeklychallenge-club-84ff106a8fcdd33662eaa42e6f196f390eda7e3b.tar.gz perlweeklychallenge-club-84ff106a8fcdd33662eaa42e6f196f390eda7e3b.tar.bz2 perlweeklychallenge-club-84ff106a8fcdd33662eaa42e6f196f390eda7e3b.zip | |
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() |
