Ad
  • Custom User Avatar

    This solution returns true when false is due for:

    snattleField = [

    [1, 0, 0, 0, 0, 1, 1, 0, 0, 0],

    [1, 0, 0, 0, 0, 0, 0, 0, 1, 0],

    [1, 1, 0, 0, 1, 1, 1, 0, 1, 0],

    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],

    [0, 0, 0, 0, 0, 0, 0, 0, 1, 0],

    [0, 0, 0, 0, 1, 1, 1, 0, 0, 0],

    [0, 0, 0, 0, 0, 0, 0, 0, 1, 0],

    [0, 1, 0, 1, 0, 0, 0, 0, 0, 0],

    [0, 1, 0, 0, 0, 0, 0, 1, 0, 0],

    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]

    Elegant but not correct!
    Can I share a screengrab from my G Colaboratory to confirm this?

  • Custom User Avatar

    my problem is I am having partial success, so the code works for some nxn array, seemingly...
    here is whst i get:

    Test Results:

    Fixed tests
    Tests

    Test Passed

    Test Passed

    [1, 2, 3, 4, 5, 6, 7, 8, 9] should equal [1, 2, 3, 6, 9, 8, 7, 4, 5]
    [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25] should equal [1, 2, 3, 4, 5, 10, 15, 20, 25, 24, 23, 22, 21, 16, 11, 6, 7, 8, 9, 14, 19, 18, 17, 12, 13]

    [1, 2, 3, 4, 5, 6, 20, 21, 22, 23, 24, 7, 19, 32, 33, 34, 25, 8, 18, 31, 36, 35, 26, 9, 17, 30, 29, 28, 27, 10, 16, 15, 14, 13, 12, 11] should equal [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]

  • Custom User Avatar

    I am having problems with this one, how can I turn 1D list with n elements into a 2D array that my code is able to then traverse and snail_map?

    for example: the test input [1, 2, 3, 8, 9, 4, 7, 6, 5] when I run through my python solutions in G Colaboratory yields - TypeError: 'numpy.int64' object is not iterable
    but when I pass:
    array = [[1,2,3],
    [8,9,4],
    [7,6,5]] yields - [1, 2, 3, 4, 5, 6, 7, 8, 9] - correct result!

    How does one create a 2d array out of 1d array of unknown size?
    Sure, if all input would lend itself to 3x3 that would not be a problem ... how do I work this out, please help!