• (EDIT by @kazk: Updated for Codewars framework)

    Consider using numpy testing once this is deployed. This gives beautified and helpful output for test failures:

    import numpy as np
    
    @test.describe('Example Tests')
    def example_tests():
        @test.it('Example Test Case')
        def example_test_case():
            actual = np.reshape(range(16), [4, 4])
            expected = np.reshape(range(1, 17), [4, 4])
            np.testing.assert_equal(expected, actual)
    

  • If anyone is getting the error:

    ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

    Remember you have to a .tolist() at the end of your return statement to convert numpy scalars back to python's.

    Cheers!

  • Why is the list split in 2? Just to do the same thing twice?

    Also, why the hell was this approved? This is a duplicate.

  • You definitely need to improve the instructions for this kata. Even now, I have no idea how this worked ---> pattern(30, 7) = [-1, -8, -3, -2, -1]. It would be helpful if you made the example better by showing why the output of [-1, -8, -3, -2, -1] makes sense coming from (30, 7).