Ad
  • Custom User Avatar

    Sorry, what's the point of this comment? Why are you claiming the solution isn't feasible while it clearly is (as evident by it having passed all test cases) and telling us to do the auditing instead of giving the measured performance backing your claims? Your code provided in this comment isn't even a good way to benchmark - see Vyacheslav Egorov's presentation on performance and benchmarking to learn more on how performance tests can be useful but are prone to inaccuracy especially when ignoring engine optimizations.

    array=Array(100).fill(0).map(()=>Array(100).fill(0));
    console.log(snail(array))
    
    Real time: 0.093 s
    User time: 0.076 s
    Sys. time: 0.017 s
    CPU share: 99.58 %
    Exit code: 0
    

    (benchmarked and averaged over 100 unique instances of nodejs)

    This code runs faster than even your own code submitted for this kata, which yielded the following benchmarks (also averaged over 100 unique instances of nodejs):

    Real time: 0.104 s
    User time: 0.082 s
    Sys. time: 0.021 s
    CPU share: 99.30 %
    Exit code: 0
    
  • Custom User Avatar

    While this solution is easier to implement (which is genius, to be honest), it's not feasible based on time complexity.

    You can use this code to compare this function with other implementations for comparison:

    const runPrimePerformance = (...arguments) => 
    {
        for (let i=0; i < arguments.length; i++) {
            console.time(arguments[i].name);
            arguments[i](/*insert matrix here*/);
            console.timeEnd(arguments[i].name);
        }
    }
    runPrimePerformance(snail1, snail2);