Ad
  • Default User Avatar

    I agree that this is still a problem.

  • Custom User Avatar

    Exactly the same thing happened to me. I would argue that the test should get a new report each time so code that just returns a new object from report() will work.

    A "report" is conceptually static. It's confusing to expect we should return an object that is later updated by the function and call it a "report." If this functionality is part of what's intended to be taught by the kata then it should be described explicitly since it's not intuitive.

  • Custom User Avatar

    Ah ok - I hadn't thought about the "cheating" angle, was thinking of this from a deterministic testing standpoint. In this kata, though ALL the tests are randomized so I still think it should include predefined tests to address the possibilty of not-very-random random tests.

  • Custom User Avatar

    The arrays being produced by the test code aren't symmetric, this should be

    theField.push(new Array(dimension+1).join('0').split('').map(function(e){return parseInt(e);}));

    Also, I don't think using randomized test cases is a good idea, since in doesn't create predictable results. If there's an edge case that might trip up someone's code, randomized tests may or may not produce it.

    Instead why not just iterate through all possible cases, or just pre-select the mine positions for each sized grid you're testing?

  • Custom User Avatar

    The solutions to this kata are interesting because they highlight how you can write more terse but less efficient code. The most upvoted solutions to this problem all skip the step of optimizing the column map up front, and instead use indexOf to test each column against the map on each iteration - very inefficient. Optimizing the map first to create a valid lookup table is a superior approach, even if it's a few more lines of code and means you can't solve it in a single statement.

    This is not a criticism of the kata at all but sort of an observation that codewars users seem to prefer short/"clever" solutions to more efficient ones. I wonder if there's some way to develop katas that can build the notion of good algorithmic design vs. just typing the least into the solution.

  • Custom User Avatar

    Took me five minutes to figure out what was being asked, I think the layout of the input needs to be explained more explicitly. Just lay it out.. "the first six elements are people in rooms on the first floor, the next 6 represent people in rooms on the 2nd floor, and so on..." It wasn't clear to me at all that "numbered consecutively" means across floors and how that mapped to what we should be expecting for input.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution