4 kyu

Snail

31,988 of 80,109stevenbarragan
Description
Loading description...
Arrays
Algorithms
  • Please sign in or sign up to leave a comment.
  • ranmori Avatar

    that was a tricky one i struggled alot, tip consider it like a snake

  • Runaho Avatar

    That was fun, i completed with only one loop. I seem to be enjoying these type of questions more, apparently. :)

  • Omerta2 Avatar

    It would be great to have more representative test samples. I got a timeout, so I assume the tests triggered an infinite loop, but there was no information about what caused it. I tested my code with lists from 3 to 10 items, and it worked fine, but now I have no idea how to fix it without knowing what went wrong. Are all the arrays in the test square?

  • Hishamismael Avatar

    This comment has been hidden.

  • 2BitSalute Avatar

    Could you rename it into "Snail Traversal" in the description? Calling it "Snail Sort" is being sloppy with terms that have meaning and needlessly confusing. I just showed it to a friend, and they immediately fixated on this.

  • eonaissi Avatar

    Test error when empty error. May be the test needs a correction.

  • jacprit Avatar

    Surprisingly fun kata, very enjoyed! The empty array in an array edge case input really confuses me. I was dissapointed when I got the whole thing working except for the empty array in an array test. I guess I don't really understand how to work with an array with only an empty array in it in Java.

  • Adrián333 Avatar

    I had already done more than half of the answer and it has not been saved ;(

  • seba_blue Avatar

    finally solved it and each time i look at all the papers i used and how complex is my code i think i am a freaking genius , tht s all i ve to say

  • lucekdudek Avatar

    Given an n x n array,

    Attempt gives [[]] which is not n x n (it is 0 x 1 array)

    No tests with n x m array. Please fix description

  • seba_blue Avatar

    This comment has been hidden.

  • Ethernel00 Avatar

    Had a lot of fun !

  • Kirill_Simbir Avatar

    Really fun kata, little hint to someone, who dont have any idea of this task, just try to use array as an one-dimensional:) Maybe it will be helpfull, good luck)

  • RYP_w Avatar

    It's been weeks of thinking about how to solve it, I finally finished it.

  • paraliterary 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!

  • ushumgigal Avatar

    Two things:

    • The input matrix is flattened
    • You need to return an array, not int* outsz

    Fun kata, vague instructions.

  • SHAwarma256 Avatar

    Wen .Net 8.0 / C# 12 so we can use collection expressions and inline arrays ? …

  • FadaBoop Avatar

    I've lost my sanity

  • jcbslv Avatar

    Overall, a fun challenge, though I agree with those who are saying the test for the empty list goes against the instructions, as it is not n x n. Yes, there is a note about it and the fix is pretty trivial, but trying to explain it away as a design choice is just silly. It's a bad design choice.

  • Aiyon860 Avatar

    Wow, such a fun kata.

  • AI MAN 228 Avatar

    Amazing kata i am proud finishing this!

  • bendeg Avatar

    Language used : C

    Could someone tell me what is that uncheated snail ? Is it an empty one ?

    It seems the very last attempt (the 15th ?) crashes (signal 11 : SIGSEGV)

    [EDIT]]finally got that last little devil...

  • dietrichR Avatar

    Tried

    from complete_solution import snail as super def snail(array): return super(array)to see if this is possible thank goodness it's not

  • sourav-iitm Avatar

    Fun kata, not that my solution is efficient.

  • ohno0805 Avatar
        ______
       /  ___ \
      |  / ,.\ |O    O
      | |  \d/ | \__/
      |__\_____/-(..)
    _/_____________/  
    SNAILICIOUS KATA
    
  • SAC.489 Avatar

    very proud for finishing it

  • KayleighWasTaken Avatar
  • jonkarrer Avatar

    This comment has been hidden.

  • alsampi10 Avatar

    For those doing this kata in Prolog, do NOT use the transpose in

    :- use_module(library(clpfd)).
    

    It gives problems with the tests for some reason, implement your own transpose

  • ghostlypi Avatar

    This comment has been hidden.

  • NoUserName1337 Avatar

    This comment has been hidden.

  • DigitalVita Avatar

    array =return [[1,2,3], [8,9,4], [7,6,5]]

    there is a 'return' in this test snippet

  • racehd Avatar

    Really enjoyed thinking through this one. Thanks!

  • lev-goryachev Avatar

    This comment has been hidden.

  • testst345 Avatar

    This comment has been hidden.

  • coffeejunkie34 Avatar

    this was a doable 4

  • illliliilliililili Avatar

    This is probably the best kata I ever did. There's so much you can learn from this kata. Good luck to anyone trying this kata

  • CALLIKA312 Avatar

    My solution got StackOverflowError, but on local machine it works fine on test samples from attempt

  • VicktorOti Avatar

    Coming up with a performant solution for this one was much trickier than I thought.

  • Dragon20C Avatar

    I have no clue what I am doing wrong on random_tests it keeps complaining about length being 0 but I dont know why its 0, does that mean its empty so I should return an empty vec but its not working still, Im so confused language RUST.

  • jordimsan Avatar

    Recomendations since this problem is kind of difficult if you don't know much about matrices. Write on a paper down the movement, and what does i and j do in each movement, then you'll eventually find a pattern that matches! Write the code first at brute force, then optimize the algorithm. Good luck whoever is reading this, liked this kata, took me a bit to optimize it and I believe it's not the most optimal solution!

  • eSuardOdin Avatar

    This comment has been hidden.

  • lfsegoro Avatar

    This comment has been hidden.

  • yomatias Avatar

    This comment has been hidden.

  • fellms Avatar

    I tried this problem using python

    from what I understood of the instructions, it said that arrays would be provided in the format of "list of lists", like: array = [[1,2,3], [4,5,6], [7,8,9]]

    but random tests provided arrays like just one list: array = [1,2,3,4,5,6,7,8,9]

    I still used math to calculate squareroot of these big lists, used numpy to make it into matrices, returned it to the format "list of lists", found the correct solution and yet the problem wouldn't accept the result, not sure why.

  • fogbanksy Avatar

    This comment has been hidden.

  • Kurogamin Avatar

    My solution works on my machine locally, but in tests it fails a lot of them and sometimes even the super simple ones like 2x2 array which is basically hardcoded in my code.

  • SaltyFrappuccino Avatar

    In Go solutions the function snail returns []int, but NOTE 2 says, that our func should return empty array inside of array [[]], but how I can return [][]int, if return type is []int?

    I mean, I really get destroied by this NOTE, so I really need an hint

  • Thunderfoot Avatar

    Great Kata, the return of the empty array was a little tricky, but overall a great little task. My c# is long, inefficient, but oh well. It works and I had fun. Thanks to the creator for your efforts

  • JoopStark Avatar

    [Ruby] I can get all the test to pass except the first. It says I get [nil] but expect [] (I assume the argument is an an empty array), but when I test an empty array on in zsh on my computer I get [].

  • donaldsebleung Avatar

    [Rust] Random tests sometimes generate an empty vector vec![] which doesn't match the Kata description saying that an empty matrix is represented by vec![vec![]]

  • dzianis.shcharbakou Avatar

    Unfortunetly, I have an exception when array is empty (c#) it seems like a test case defect.

  • LegendaryFartMaster Avatar

    This comment has been hidden.

  • sur4a Avatar

    This comment has been hidden.

  • hfga Avatar

    The details are clear enough in my opinion, but the image after "This image will illustrate things more clearly:" is broken with a 404 error

  • Pandasama Avatar

    Is SnailTest2Empty correct?

    Conditions of the problem are "Given an n x n array", but for input array = [[]] array.Length == 1 but array[0].Length == 0 so it isn't 1 x 1 array, or 0 x 0 array, it's 1 x 0 array

  • Beata13 Avatar

    I think this task is not determined precisely. The first sentence: "Given an n x n array..." is misleading. I was struggling with last test. The information from this test was also misleading. It turned out that my code wasn't prepared for a matrix like [[7,8,9]]. But it shouldn't be! Because it is the matatrix 1X3. When I understood which case I didn't take into consideration I corrected my code easily, but it wasn't my fault. The description of this exercise is to blame.

  • tjrockefeller Avatar

    I think what people are struggling with when doing this in C# is that the empty test case isn't really empty.

    I was using array.Length to get the dimension of the array, but for the empty test case array.Length = 1 which caused some of my loops to go out of bounds because the dimension was not 1, it should have been 0. The array is passed as a jagged array and the empty case is a length of 1 with an empty array inside of that.

    I had to fix my code by using array[0].Length to get the dimension of the array.

  • Bigoh20 Avatar

    The image in the description test isn't loading

  • Ki113rbak3r Avatar

    In Go is the input supposed to be named "snaipMap" instead of "snailMap"?

  • DK30033 Avatar

    This comment has been hidden.

  • DK30033 Avatar

    More of a snake than a snail if you ask me

  • sr90 Avatar

    This comment has been hidden.

  • yeahyeahcore Avatar

    Is "should tests with random snailmap" test correct?

  • Rafist0 Avatar

    Numpy shows their true power.

  • Kamnielos Avatar

    My code in java works locally for all the test cases that it fails here.... something is fucked up here

  • aliaksandr-batskalevich Avatar

    This task lifted my spirits! Thanks for this)

  • aleksandr.chernikov654 Avatar

    This comment has been hidden.

  • Mister.Joy Avatar

    So far the most satisfactory kata to get through. thoroughly enjoyed!

  • furtidev Avatar

    The fixed cases for Golang have issues. The empty matrix test doesn't work even though there's nothing wrong with the code.

  • Rimanagi Avatar

    This comment has been hidden.

  • nomennescio Avatar

    C translation has confusing initial code which is NOT illustrating what the user should return

      // Return a heap allocated array, report the size in *outsz
      return (int *)(*outsz = 0);
    
  • enricodallastella Avatar

    Is it just me or the empty matrix solution in GO give some problem?

  • l96alex Avatar

    Enjoyed this, was so sure I had a clean solution, but then the solutions provided a solid facepalm. Couldn't ask for more

  • <------------> Avatar

    it does not work in python random tests but when i run it in ide it works fine. anyone has the same problem here?

  • vailcolorado13 Avatar

    My first 4kyu. WoooHoooo!

  • andrewMyName Avatar

    i pass these tests apart but i can not pass them together

  • eltbus Avatar

    Might be a little too easy for a 4th kyu. Could it be possible to filter low performance solutions? My solution is "meh" but it still passed.

  • dmitryspain98 Avatar

    Yooo man cool snail shit

  • JPR95 Avatar

    I've written a function which I am almost certain should solve this kata, but I am having a couple of issues.

    If I click "Test", I get a failure message as the sample test which includes a 36-element array seems to want the numbers in ascending numerical order [1, 2, 3, 4, 5, 6, 7, 8, ..., 36] rather than the actual spiral pattern of [1, 2, 3, 4, 5, 6, 12, 18, 24, 30, 36, 35, 34, ..., 21].

    However, even if I hard code in an ascending numerical order for 36 elements, I am having an issue when I click "Attempt", where the numbers in the given array are not 1 to n, but instead seemingly random unordered numbers, such as [793, 58, 556, 635, 246, ..., 385].

  • shampoo-bit Avatar

    This comment has been hidden.

  • epicshaner Avatar

    This comment has been hidden.

  • kocetomad Avatar

    I am able to pass all examples tests locally, even when switchin to an old version of node. But the random tests cannot set property ? of undefined which is not an operation I am actually performing.

    [ 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 ] my output for the final example test.

    Can also provide my code if required, would love to know what causes this error.

  • Ivo  Avatar

    This comment has been hidden.

  • A.Mahler Avatar

    This comment has been hidden.

  • AndUser99 Avatar

    What should be returned for empty array in Java ? I've tryed return new int[]{} and return new int[0] My brain is broken.

  • kachinski Avatar

    Сложная ката! 😭 Осилил, но не без гугла и пошаговой отладки

  • Bravono Avatar

    This may be usefull for you. You may want to try another computer. I have 2 computers, wrote the same code in vs code on both computers. My solution worked in one and didn't work in the other. I logon to code wars on both computers. Again my solution worked in one and didn't in another. I have no idea why this happened, if you do please explain. I should mention that it worked on one computer both in vs code and codewars but didn't work in the other, both in vs code and codewars.

  • expressobeems Avatar

    So many different Javascript methods and properties are not working in this kata. flat() isn't supported, reverse() isn't supported, and now its even saying .length isn't working. I copied and pasted my function into the console and it has worked with every array I've thrown into it so I am 99% sure my code isn't buggy. Does it really not support something as basic as .length? This one has been SO much fun to figure out but it's frustrating how many fully supported methods and properties can not be used

  • mauiwowie88 Avatar

    This problem is broken it works fine in csbin

  • waspiecess Avatar

    "should return empty array given an empty array" - why does this mean that the array is not empty, but the first element of an input array is an empty array? lang Go []int{} -- empty array [][]int{{}} -- is NOT empty, but kata assumes it is, but the input itself is wrong: it is not 0x0 or 1x1, it is 1x0, but not NxN

  • JeremyKimotho Avatar

    The representation of an empty array is very counterintuitive. I know it has been brought up previously but just have to pile on and reiterate that.

    Edit: for C++

  • soap1 Avatar

    Two of the random tests kept getting errors of 2 numbers out of sequence. I've been looking at my code for an hour, could the random test be possibly erroneous?

  • Waxahazzer Avatar

    this one cant even into understanding the task. Have read the task 10 times, still confusion. What to do here is mistery.

  • coceban.vlad Avatar

    The title in details "Snail Sort" is confusing. I spent 5 more mins to impl. a sort while it was not even needed.

  • EminH Avatar

    Hi. Language is C#

    1. Pass all tests (except Random Test) one by one, but when I run solution on 3-4 tests at the same time it fails. What can be the reason?
    2. It fails every time at Random Tests can anyone show me the way?
  • RolandMarchand Avatar

    The C translation seems to be bugged, I am unsure what output is expected.

    Accessing the same element [0][0] of mx in a loop produces undefined behavior.

  • KayleighWasTaken Avatar

    This comment has been hidden.

  • Glinator Avatar

    It adds random tests.

    Please review and approve, thanks !

  • tabuk Avatar

    Hi! First, thanks for this kata.

    What about to modify this kata and instead of (n x n) size array, provide with (n x k) size array

    (would be more challanging :) )

  • sjuiceyt Avatar

    Очень классная ката!

  • kakakiko Avatar

    When using JavaScript, it keeps throwing errors completely unrelated to my actual code ( cannot set property ? of undefined when I'm not even making such operation and the column index is pointing to whitespace. )

  • FIVe04 Avatar

    This comment has been hidden.

  • david-abell Avatar

    I put my fully passing and submitted solution into the leetcode version of this and discovered it wouldn't pass the testcase:

    Test.assertDeepEquals(snail([[7],[9],[6]]), [7,9,6]);
    

    I was outputting [7,9,6,undefined]

    I'd suggest adding this to the test suite.

    Edit: Javascript in case this isn't clear

  • AuspiciousNotation Avatar

    This comment has been hidden.

  • WheelReinventor Avatar

    My java solution handles all of the tests, except for the empty array test. When array = { {} } it complains about indices. Any advice for how to determine if the array is empty like this?

  • VaxiZ Avatar

    This comment has been hidden.

  • qcy_ Avatar

    Function pop() on JS isn`t work. Please, add it

  • Klick_99 Avatar

    Function 'flat' on JS is not work in this IDE!!!! Please, make something with it, if you can.

  • wannaChill Avatar

    This thing is not working! At least on c# i have checked all of the numbers in sequence, found no difference, but still got an error PrintScreen https://dropmefiles.com/XBg52

    The error code is : System.IndexOutOfRangeException : Index was outside the bounds of the array. i can provide my code

    its just unbelievable! here is another example https://dropmefiles.com/BoVlq

  • Winged7Angel Avatar

    I have "Test Crached" but in Dev C++ 5.4.2 it's OK. is't write "signal 11", but IDK why

  • lukaseepo Avatar

    Amazing kata <3

  • Lucasss Avatar

    Very pleasant kata.

  • Valeriy-Totubalin Avatar

    Hi, my golang solution passes all tests except random ones. However, I checked with a size of 6x6, it works. Are there any problems with kata tests on golang?

  • YoSiSoyVictor Avatar

    It's a very good kata, but I find weird that a len 0 array gets represented as [ [ ] ] since that would make a 1 x 0 grid, yet the description clearly states that it's an n x n grid.

    Yes, I know it says at the bottom how it's represented. It still makes no sense.

    I had to make an additional if statement to my solution so it would pass the empty array case, if it was just [ ] (0 x 0) it would've passed without the need of an additional if, as my solution (and many others from what I've seen in other comments) works for all grids n x n, what the kata asks for.

    I'm rating it as somewhat satisfied instead of very satisfied because of that. I'll rate it very satisfied if it get's changed.

  • almeida20 Avatar

    This comment has been hidden.

  • Meodinger Avatar

    I don't think the "Empty Test" should be in test cases. In that test case, the input array is [[]], which is an 1 x 0 matrix. It doesn't fit to the description of input array is n x n.

  • Kreatorxox Avatar

    This comment has been hidden.

  • Chrono79 Avatar

    This comment has been hidden.

  • Hitrii_crab Avatar

    Kata does not support the method flat(), unfortunately. You give hard tasks, but do not support new tools yourself. This kata should be removed

  • LlewellynMadara Avatar

    This comment has been hidden.

  • user4585678 Avatar

    There is an exception when I'm trying to return an empty array (Array.Empty() or new int[0])

    Log [[]] should be sorted to [] System.IndexOutOfRangeException : Index was outside the bounds of the array.

  • akar-0 Avatar

    COBOL translation, please review carefully.

  • kekia Avatar

    what(size_t *outsz)is used for ??

  • Muhamor Avatar

    Hello, please update golang version or provide returning of nil slice, when i try to return an empty slice golang panics

  • peterolph Avatar

    Working in Python, so I don't know if this issue affects other languages.

    There is a test case for [[]] but this is actually a malformed input, representing a 1 x 0 array ie. not n x n.

    Consider [[],[]] and [[],[],[]] which are 2 x 0 and 3 x 0; an array which is zero in one dimension can be nonzero in another dimension.

    The correct representation for a 0 x 0 array, which I think the test case should be changed to, is simply [].

  • okkdev Avatar

    Haskell random tests broken

  • fanfois Avatar

    With Python I get many test error messages regarding 1D arrays, such as this one:

    [1, 2, 3, 4, 5, 10, 15, 20, 25, 24, 23, 22, 21, 6, 11, 16, 7, 8, 9, 14, 19, 18, 17, 12, 13] 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]

    … but this case is not defined in the instructions (only 2D arrays are mentionned). I suppose the correct result for 1D arrays is a by-product of a specific solution?

  • shoplucaaa Avatar

    This comment has been hidden.

  • astolat Avatar

    This comment has been hidden.

  • PlouklaPenguin Avatar

    I get TypeError: Cannot read properties of undefined (reading '0') when trying to run y < array.length - 1

    What's wrong and how could I fix it?

    Thanks!

  • user2563 Avatar

    This comment has been hidden.

  • RoMishch Avatar

    C#

    SnailTest2Empty Log [[]] should be sorted to [] System.IndexOutOfRangeException : Index was outside the bounds of the array. Stack Trace at SnailSolution.Snail(Int32[][] array) at SnailTest.Test(Int32[][] array, Int32[] result) at SnailTest.SnailTest2Empty()

    NOTE 2: The 0x0 (empty matrix) is represented as en empty array inside an array [[]].

    I don't understand the return format at zero. If I return int [1][] or emty int[], I still don't pass the test.

  • soejdtodxn Avatar

    This comment has been hidden.

  • Svetoslav89 Avatar

    The tests in java are 100% broken. I pass the basic test with 9 elements and then the rest of the tests fail even thought my results are absolutely correct even for the corner cases {{}} and {{1}}. And the test spits some nonsense like "array lengths differed, expected.length=16 actual.length=9" eventhought that's not the case and "actual.length" is different every time I run the same test.

  • asthesus Avatar

    This comment has been hidden.

  • resentry Avatar

    This comment has been hidden.

  • CASIO15 Avatar

    Very fun kata, tried it as a rookie in the past, but now it wasn't too bad.

  • junioryao Avatar

    could you please fix your broken test cases [[953, 579, 241, 809, 554, 782, 1, 756, 846] [91, 833, 225, 143, 469, 42, 140, 805, 848] [811, 256, 613, 444, 490, 974, 159, 196, 389] [362, 408, 480, 854, 52, 829, 777, 189, 791] [524, 623, 269, 527, 661, 912, 167, 76, 802] [2, 296, 308, 819, 597, 242, 26, 808, 476] [489, 537, 690, 630, 601, 275, 907, 953, 413] [222, 444, 162, 102, 762, 262, 808, 507, 728] [324, 946, 41, 540, 396, 205, 444, 562, 497]] should be sorted to [953, 579, 241, 809, 554, 782, 1, 756, 846, 848, 389, 791, 802, 476, 413, 728, 497, 562, 444, 205, 396, 540, 41, 946, 324, 222, 489, 2, 524, 362, 811, 91, 833, 225, 143, 469, 42, 140, 805, 196, 189, 76, 808, 953, 507, 808, 262, 762, 102, 162, 444, 537, 296, 623, 408, 256, 613, 444, 490, 974, 159, 777, 167, 26, 907, 275, 601, 630, 690, 308, 269, 480, 854, 52, 829, 912, 242, 597, 819, 527, 661]

    At index 25 it is expected result to contain the number 2 , whereas from the given array it does not even contain 2

  • bassedOutt Avatar

    Last Java test is broken [[]] should be sorted to []- what it says i'm returning an empty int array, which it expects, but it keeps failing Please fix it, i'd love to see other people solutions

  • sadat_saim Avatar

    At first it looks very scary. But think easy. HINT: think it like CSS box model.

  • khhey Avatar

    There are no tests before submitting which is a shame :)

  • jordanwegener Avatar

    Can't even get started here because an if statement for array === [ [] ] never fires... anyone know why this is?

    I'm passing in exactly what console.log spits out and it never runs the block.

  • ElArbol Avatar

    With javascript I get the error: "expected [ undefined ] to deeply equal []" how to avoid that? Shouldn't "return []" return the right value in that case?

    Thanks!

  • avighna Avatar

    Kata took me 5 hours of drawing diagrams, finding patterns, and making algos to solve. Not one for the light-hearted!

  • janedoe. Avatar

    Nice kata, simple yet challenging

  • Tybylty Avatar

    This comment has been hidden.

  • marekmaskarinec Avatar

    This comment has been hidden.

  • albucathecoder Avatar

    This comment has been hidden.

  • LeotheOne Avatar

    Are all test cases n*n arrays? sure?

  • LeotheOne Avatar

    This comment has been hidden.

  • LeotheOne Avatar

    What are you supossed to return in C?

  • TheGoldenRatio Avatar

    The messiest part about this problem stems from the fact that lists are zero indexed

  • ArpadGBondor Avatar

    This comment has been hidden.

  • Vladimir-82 Avatar

    One of random test faild. What is wrong? Traceback (most recent call last): File "/workspace/default/src/codewars-test/codewars_test/test_framework.py", line 111, in wrapper func() File "tests.py", line 66, in it_1 test.assert_equals(snail(a), solution(b)) File "/workspace/default/solution.py", line 14, in snail if snail_map[i][j] != None: IndexError: list index out of range

    I understand that the index error, but why does everything else go? And what array does not pass it is not clear?

  • dummyaccount Avatar

    DAMN, had no idea this was even possible, i have an idea of what im supposed to do, but not quite sure how to code it yet. Will come back, even the concept of this Kata blows my mind, cheers.

  • ejini战神 Avatar
    • Ruby 3.0 should be enabled (Refer this & this for more detail)
  • ngekoding Avatar

    This is the best Kata until now, need many hours to found the solution. But, when using the same algorithm for both PHP & JavaScript, only JavaScript can passed it while PHP get timeout.

  • OverDriven Avatar

    Very good kata!

  • SunMaster Avatar

    Doing the NASM version

    There is no explanation what the parameters actually are

    In the starting source there is

      ; <-- [dword RAX] snail([qword RDI] outsz, ro [qword [dword RSI]] mx, RDX m, RCX n) -->
      
    

    No explanation there, in the testcode or in the description.

    I guess I will just have to experiment how it's supposed to be.

    In the C-version, which I did solve, there's this comment.

      // the numbers of rows and cols are passed separately for historical reasons
    

    Does it apply to the NASM version as well?

  • DeathNet123 Avatar

    well, i feel like idiot to be honest i just can't get what exactly i have to do i mean i can't get what exactly the question is

  • Zakarpatsky Avatar

    First 4 kuy kata is done:) That's was a funny jorney for good ~5 hours,thanx for your work.

  • Mir Abir Hossain Avatar

    This was one hell of a good kata. Spend whole day and just got it done with python. Now watching other people's solution and I just realised I know nothing. People are just way smarter. Bookmarking this. Will come back later and practice other people's solution.

  • Nikero Avatar

    Expected: [], instead got: [undefined]

    I get this message. I run it anywhere else exept Codewars I get the expected value.

  • cosminelro Avatar

    UndefinedBehaviorSanitizer:DEADLYSIGNAL ==1==ERROR: UndefinedBehaviorSanitizer: SEGV on unknown address 0x000000000000 (pc 0x00000042c8ba bp 0x0000021f7100 sp 0x7ffd9b0c80a0 T1) ==1==The signal is caused by a READ memory access. ==1==Hint: address points to the zero page. ==1==WARNING: invalid path to external symbolizer! ==1==WARNING: Failed to use and restart external symbolizer! #0 0x42c8b9 (/workspace/test+0x42c8b9) #1 0x425597 (/workspace/test+0x425597) #2 0x428213 (/workspace/test+0x428213) #3 0x4269ee (/workspace/test+0x4269ee) #4 0x426549 (/workspace/test+0x426549) #5 0x42613b (/workspace/test+0x42613b) #6 0x42c4f5 (/workspace/test+0x42c4f5) #7 0x42585d (/workspace/test+0x42585d) #8 0x7fea57989bf6 (/lib/x86_64-linux-gnu/libc.so.6+0x21bf6) #9 0x404589 (/workspace/test+0x404589)

    UndefinedBehaviorSanitizer can not provide additional info. ==1==ABORTING

    I dont't understand why I have this error

  • snowfluke Avatar

    Javascript flat() function is prohibited?

  • Nikero Avatar

    This comment has been hidden.

  • chustos96 Avatar

    it was really challenging! thanks for the kata

  • vbccbz Avatar

    I don't understand return (int *)(*outsz = 0);

    What is return? Pointer to allocated memory? Or does function need to change some given array?

  • Sailor Stat Avatar

    This comment has been hidden.

  • piotrKolodziejski Avatar

    I really liked this kata, thank you!

  • sadegh-moayedizadeh Avatar

    This comment has been hidden.

  • sadegh-moayedizadeh Avatar

    This comment has been hidden.

  • sadegh-moayedizadeh Avatar

    This comment has been hidden.

  • jessedo Avatar

    Nice Kata, but isn't this rated a little too high? I think this could be 5kyu or even 6 kyu.

  • StandaSasek Avatar

    Thank you Steven, it was a big satisfaction, when I finally solved your kata.

  • Sudentaivals Avatar

    This comment has been hidden.

  • green142f Avatar

    Max Buffer Size Reached (1.5 MiB). Can someone please explain to me why this is happening?

  • Xanthan Avatar

    SO HARDDD :(

  • user6999815 Avatar

    something has got to be wrong with the attempt-tests!

    The first time I ran an attempt, 0 tests passed. Just for curiosity, I re-ran the tests (without changing any code) and 5 tests passed. I kept re-running and at some point 10 tests passed.

  • 23rdPro Avatar

    Interesting kata, biggest point to note when testing, it's (n x n) and not (m x n)

  • oyemayanq Avatar

    This comment has been hidden.

  • Mxrcon Avatar

    Nice work on this one Steven, Thanks for the experience of solving this kata.

  • dumblessar Avatar

    hello, i couldn't solve this kata. what algorithm or tecnhnique should i learn in order to solve this kata?
    and actually i am having trouble to study data structures and algorithms. would anybody give me some advices about how can i learn and practice data structures and algorithms please?

  • Chieftain.mk7 Avatar

    Great kata, thank you )))

  • cl_tch Avatar

    This comment has been hidden.

  • Turim Avatar

    This comment has been hidden.

  • B1ts Avatar
  • miqrs Avatar

    Has anybody solved this with a Rust solution?

    I ask because I suspect the testing mechanism is broken.

    For example:

    assertion failed: `(left == right)`
      left: `[101, 235, 545, 832]`,
     right: `[101, 235, 832, 545]`: 
    Failed with input [[101, 235], [832, 545]]
    

    The right here corresponds with the expected solution, but clearly it's incorrect if you look at the input.

  • alpha43 Avatar

    Nice Kata

  • thalweg7 Avatar

    There is an issue with either the notes or the tests.

    Test.assert_equals(snail([[]]), [])

    Per Note 2, the result should be [[]], though [] makes more sense. I recommend editing Note 2.

  • NewDeveloper Avatar

    This comment has been hidden.

  • Kappa_ Avatar

    This comment has been hidden.