Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
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.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
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?
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.
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
I learned about generators from this solution. Thanks! Maybe some day they will be widely browser compatible.
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!
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.
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.
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).
Nicely done. I like how your solution can be easily extended to larger numbers. Thanks for trying my beta kata.
This is difficult to do properly I think. Server load varies. If it's done right, then I'm all for it.
This comment is hidden because it contains spoiler information about the solution
~~x is shorter than Math.floor(x)
Loading more items...