Ad
  • Custom User Avatar

    I think the solution should be inside the tests

    
    
    @test.describe("Example")
    def test_group():
        def cal(mat):
            return mat[len(mat) // 2][len(mat[len(mat) // 2]) // 2] if len(mat) & 1 == 1 and len(mat[len(mat) // 2]) & 1 == 1 else None
        
        @test.it("test case")
        def test_case():
            test.assert_equals(center([ [ 5, 1, 3 ], [ 6, 2, 6 ], [ 7, 4, 5 ] ]), 2)
            test.assert_equals(center([ ]), None)
            test.assert_equals(center([ [ 5, 1, 3 ], [ 7, 4, 5 ] ]), None)
            test.assert_equals(center([ [ 3 ] ]), 3)
            test.assert_equals(center([ [ 5, 1, 3 ], [ 6, 2, 6 ], [ 7, 4, 5 ], [ 10, 12, 12 ], [ 14, 0, 0 ] ]), 4)
            test.assert_equals(center([ [ 5, 1 ], [ 6, 2 ], [ 7, 4 ], [ 1, 3 ] ]), None)
            test.assert_equals(center([ [ 5, 1, 3 ] ]), 1)
            test.assert_equals(center([ [ 5, 1, 3 ], [ 6, 7, 6 ], [ 7, 4, 5 ] ]), 7)
            
        @test.it("random test")
        def test_case():        
            for i in range(1000-8):
                mtx = numpy.random.rand(randrange(500), randrange(500))
                test.assert_equals(center(mtx), cal(mtx))