def test_copy_transform(self): self.assertEqual(copy_transform.rotate_clockwise( [[1, 2, 3], [4, 5, 6], [7, 8, 9]]), [[7, 4, 1], [8, 5, 2], [9, 6, 3]]) self.assertEqual(copy_transform.rotate_counterclockwise( [[1, 2, 3], [4, 5, 6], [7, 8, 9]]), [[3, 6, 9], [2, 5, 8], [1, 4, 7]]) self.assertEqual(copy_transform.top_left_invert( [[1, 2, 3], [4, 5, 6], [7, 8, 9]]), [[1, 4, 7], [2, 5, 8], [3, 6, 9]]) self.assertEqual(copy_transform.bottom_left_invert( [[1, 2, 3], [4, 5, 6], [7, 8, 9]]), [[9, 6, 3], [8, 5, 2], [7, 4, 1]])
def test_copy_transform(self): self.assertEqual(copy_transform.rotate_clockwise( [[1, 2, 3], [4, 5, 6], [7, 8, 9]]), [[7, 4, 1], [8, 5, 2], [9, 6, 3]]) self.assertEqual(copy_transform.rotate_counterclockwise( [[1, 2, 3], [4, 5, 6], [7, 8, 9]]), [[3, 6, 9], [2, 5, 8], [1, 4, 7]]) self.assertEqual(copy_transform.top_left_invert( [[1, 2, 3], [4, 5, 6], [7, 8, 9]]), [[1, 4, 7], [2, 5, 8], [3, 6, 9]]) self.assertEqual(copy_transform.bottom_left_invert( [[1, 2, 3], [4, 5, 6], [7, 8, 9]]), [[9, 6, 3], [8, 5, 2], [7, 4, 1]])
from algorithms.matrix.copy_transform import rotate_clockwise, rotate_counterclockwise, top_left_invert, bottom_left_invert def print_matrix(matrix, name): print('{}:\n['.format(name)) for row in matrix: print(' {}'.format(row)) print(']\n') matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9], ] print_matrix(matrix, 'initial') print_matrix(rotate_clockwise(matrix), 'clockwise') print_matrix(rotate_counterclockwise(matrix), 'counterclockwise') print_matrix(top_left_invert(matrix), 'top left invert') print_matrix(bottom_left_invert(matrix), 'bottom left invert')