From 5b79a36456694c1c77104ddec7c315cffa74b994 Mon Sep 17 00:00:00 2001 From: Roger Bell_West Date: Tue, 7 Nov 2023 13:27:23 +0000 Subject: RogerBW solutions for challenge no. 242 --- challenge-242/roger-bell-west/python/ch-2.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 challenge-242/roger-bell-west/python/ch-2.py (limited to 'challenge-242/roger-bell-west/python/ch-2.py') diff --git a/challenge-242/roger-bell-west/python/ch-2.py b/challenge-242/roger-bell-west/python/ch-2.py new file mode 100755 index 0000000000..c01ccf6c74 --- /dev/null +++ b/challenge-242/roger-bell-west/python/ch-2.py @@ -0,0 +1,19 @@ +#! /usr/bin/python3 + +def flipmatrix(a): + b = [] + for row in a: + b.append(list(reversed([1 - i for i in row]))) + return b + +import unittest + +class TestFlipmatrix(unittest.TestCase): + + def test_ex1(self): + self.assertEqual(flipmatrix([[1, 1, 0], [1, 0, 1], [0, 0, 0]]), [[1, 0, 0], [0, 1, 0], [1, 1, 1]], 'example 1') + + def test_ex2(self): + self.assertEqual(flipmatrix([[1, 1, 0, 0], [1, 0, 0, 1], [0, 1, 1, 1], [1, 0, 1, 0]]), [[1, 1, 0, 0], [0, 1, 1, 0], [0, 0, 0, 1], [1, 0, 1, 0]], 'example 2') + +unittest.main() -- cgit