Ad
  • Custom User Avatar

    Same here. It's interesting that more people have solved Valid Braces than this one. I took the opportunity to translate my javascript solution there to a python solution here. I can't explain the level disparity.

  • Custom User Avatar

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

  • Custom User Avatar

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

  • Custom User Avatar

    No I didn't see what you posted before the edits.

    Well, I was passing all the tests (except that one random test)... but once I fixed that bug I don't pass all the tests any more. Wow, this is a challenge.

    I'm back to failing test 17.

    How does one make progress, logically, here?

    Three hidden mines:
    0 0 0 0 0 0 0 
    1 1 1 1 1 0 0 
    x 2 3 x 2 0 0 
    2 ? ? x 2 0 0 
    ? ? 3 3 2 1 0 
    ? ? ? 2 x 1 0 
    ? ? ? 2 1 1 0 
    
  • Custom User Avatar

    0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1
    0 0 0 0 0 0 0 1 1 1 0 0 0 1 x 2
    0 0 0 0 0 0 0 1 x 1 0 0 0 1 2 x
    0 0 0 0 0 0 0 1 1 1 0 0 1 1 2 1
    0 0 0 1 2 2 1 0 0 0 0 0 1 x 1 0
    1 1 1 2 x x 2 2 1 2 1 1 1 1 1 0
    ? ? 2 D C 4 x 2 x 2 x 1 0 0 0 0
    1 1 2 x 3 B 2 2 1 2 1 1 0 0 1 1
    0 0 1 1 2 A 1 0 0 0 0 0 0 0 1 x

    My code is (incorrectly) doing this:

    It knows 1 mine is in AB based on the 2 next to B.
    Then it knows 1 mine is in CB based on the 4 above B.
    Since ABCD has 2 mines based on the 3 next to B, it assumes D is empty, and opens that square.

    It's not taking into account that AB and CB have B in common... I should test that the first two groups have a null intersection before it opens a square this way.

    So now I should fix this bug while also speeding up my code by a factor of 2. I can never get past 50 of the random tests. Sigh.

  • Custom User Avatar

    From the Python random tests:

    Test #22: Your solution succeeded where the original didn't.
    Might be that yours is smarter... Or you made a wrong (but successful) guess somewhere ?
    Please post a comment in the discourse about that, providing the informations below:

    FAILED TEST !

    Number of mines: 14
    Original map (not necessarily the expected one !):
    0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1
    0 0 0 0 0 0 0 1 1 1 0 0 0 1 x 2
    0 0 0 0 0 0 0 1 x 1 0 0 0 1 2 x
    0 0 0 0 0 0 0 1 1 1 0 0 1 1 2 1
    0 0 0 1 2 2 1 0 0 0 0 0 1 x 1 0
    1 1 1 2 x x 2 2 1 2 1 1 1 1 1 0
    1 x 2 3 x 4 x 2 x 2 x 1 0 0 0 0
    1 1 2 x 3 3 2 2 1 2 1 1 0 0 1 1
    0 0 1 1 2 x 1 0 0 0 0 0 0 0 1 x

    Game map:
    0 0 0 0 0 0 0 0 0 0 0 0 0 ? ? ?
    0 0 0 0 0 0 0 ? ? ? 0 0 0 ? ? ?
    0 0 0 0 0 0 0 ? ? ? 0 0 0 ? ? ?
    0 0 0 0 0 0 0 ? ? ? 0 0 ? ? ? ?
    0 0 0 ? ? ? ? 0 0 0 0 0 ? ? ? 0
    ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0
    ? ? ? ? ? ? ? ? ? ? ? ? 0 0 0 0
    ? ? ? ? ? ? ? ? ? ? ? ? 0 0 ? ?
    0 0 ? ? ? ? ? 0 0 0 0 0 0 0 ? ?

    Your answer:
    0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1
    0 0 0 0 0 0 0 1 1 1 0 0 0 1 x 2
    0 0 0 0 0 0 0 1 x 1 0 0 0 1 2 x
    0 0 0 0 0 0 0 1 1 1 0 0 1 1 2 1
    0 0 0 1 2 2 1 0 0 0 0 0 1 x 1 0
    1 1 1 2 x x 2 2 1 2 1 1 1 1 1 0
    1 x 2 3 x 4 x 2 x 2 x 1 0 0 0 0
    1 1 2 x 3 3 2 2 1 2 1 1 0 0 1 1
    0 0 1 1 2 x 1 0 0 0 0 0 0 0 1 x

  • Custom User Avatar

    I learned about generators from this solution. Thanks! Maybe some day they will be widely browser compatible.

  • Custom User Avatar

    You need to add a call to a Test method in the test cases. You can't simply call the function and nothing else. In order to solve this kata people have had to add a call to Test inside the code!

  • Custom User Avatar

    Perhaps write a test that examines the solution to see if a big integer module module is loaded. I gather you intended us to reinvent the wheel. But I couldn't help but try a solution that already exists.

  • Custom User Avatar

    I've updated the test cases to included randomly-selected test cases, as opposed to randomly-generated. Your current solution no longer passes the tests.

  • Custom User Avatar

    Thanks. I'm not really familiar with the best practice for adding random tests. Do I need to include my solution code in the test to get the expected result from the random tests? (In that case I've seen people use arguments.callee to refer to the embedded solution, cheating another way).

  • Custom User Avatar

    Nicely done. I like how your solution can be easily extended to larger numbers. Thanks for trying my beta kata.

  • Custom User Avatar

    This is difficult to do properly I think. Server load varies. If it's done right, then I'm all for it.

  • Custom User Avatar

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

  • Custom User Avatar

    ~~x is shorter than Math.floor(x)

  • Loading more items...