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.
Python:
Execution time: 246.01 microseconds
This barely tells anything to the person solving the kata.
python version
just how good does the solution need to be? I get times around 200 - 280 ms for running all 10 random tests (100 invocations each) so average time around 250 usec, this seems pretty good (to me). however, not a single random test passes the time constraint (all rsults are correct)
Description states that
$-1600 \le r \le 1600$
, however the test cases in Python (and possibly other language) only have positive radii. Possible typo?Kata is unbalanced between languages. Brute-force works easily in JS while it times out in Python (yeah because Python slow, a big test case runs in under 50 ms in JS while the same takes more than 2 seconds in Python).
Haskell translation
I think the Python performance tests are broken.
I can't be sure, because it won't let me pass the test, but the test harness outputs this:
The log entry and 'execution time' were produced by the tests, while the
Completed in
line is the Codewars test library itself. The latter meshes with my own local tests, that my solution is plenty fast (my laptop completes any of the performance test inputs in ~170µs).Why does the kata test report the time taken as 12.37ms here? The whole performance section only takes 14.81ms, in total.
Are there any cases that take a long time to execute (javascript)?
In the basic tests, the longest execution time falls between 30 to 50 ms.
However, I still fail to pass the 12000ms limit.
Additionally, due to the timeout error, I am unable to print anything.
Haskell translation
The reference solution sometimes finds the wrong solution (this happens quite rarely). Here is one expression I came across in random tests:
Haskell random tests have some issues
c
are rarely products of items in the listFork that fixes these along with some improvements to the reference solution.
I checked and found that the Java and Kotlin translations have the exact same issues with hidden zeros. The JS version is fine, but needs to have the same test updates.
Here are forks that fix these issues:
Interestingly enough, the Kotlin translation has a direct port of the Python and Java reference solution used for testing but the 'Solution' solution is a different one altogether, one that doesn't have the hidden zeros issue.
A note on the
MINE_RATIO
constant: the Kotlin and Java translations were using a random range (from 8 up to 12, inclusive), but that's variability doesn't really add anything to the tests in my experience. In the interest of consistency I felt it better to just use the fixed constant there too.now on dart
Translation Dart
I got to kata myjinxin2015
Translation Dart
Thanks for the interesting kata!
I noticed the description invites us to go for a one-liner:
While I accepted the challenge for fun, I generally don’t support encouraging the one-liner culture — especially in a 7 kyu kata where many less experienced Codewarriors are just getting started.
Writing overly compact code may look clever, but it often sacrifices readability and maintainability — a double loss, both for the author and the reviewer.
You can absolutely mention this kind of challenge in the description as a fun side quest — just be sure to remind others:
challenge yourself, but don't try this at home! 😄
That said, the underlying idea and use of bitwise manipulation made for an enjoyable problem.
Thanks again for the challenge!
now on dart
Translation Dart
Loading more items...