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.
Approved
Done! Thank you!
Now it looks way more neat, I like it this way as well :)
(And sorry I took a little too long to reply, coulnd't access codewars at all yesterday...)
Good :)
Just one detail: with 1000 random tests, it's very heavy and actually not useful to print an
It
for each random test. I think it's better to make just oneDescribe("Tests", func()
block and include all the random tests in aIt("Random tests", func() {
block inside it. This will display only one message:Test passed
if all the tests passed, otherwise one custom message for the first failed test; also, it avoids to run all the tests for nothing if one test is failing. That's most katas do and it has my preference.Fixed it! (I guess so...) Is it ok now?
The generalization does affect the definition. Generalizing from the whole numbers to the integers (includes negative numbers) makes it natural to generalize the definition of primes. It's strange to do so since generalizing to complex numbers is more useful.
I read the description again. It leaves no ambuiguity, so the fault is on me. I just saw negative numbers and primes and assumed we would use a definition generelized to integers. I should have been more diligent before making an issue. My only excuse is that there are others.
Ok. Answer to this thread when you are done, I should receive a notification.
If you want to see an example, you can have a look at this translation: https://www.codewars.com/kumite/62dc286ded71437251c8693f?sel=62dc286ded71437251c8693f
It is an easy one, if you haven't solved it already, solve it and you will be able to see the translation.
Wikipedia's article first sentence is "A prime number (or a prime) is a natural number...". This excludes de facto negative integers. In the paragraph you mention: " The integers are a ring, and the prime numbers in the integers have been generalized to rings in two different ways,.." This is a generalization of prime numbers, and doesn't affect the definition of what is a prime number. Moreover, if anyone would have a doubt, the description clearly explains what must be considered a prime number in this kata. Removing the kata for this would just be ridiculous.
Thank you for the feedback! That's my first translation and I don't know a lot of nuances, so I genuinely appreciate your help :) I'll fix the translation as soon as possible.
You should add assertion messages to the test to give the input in case of failed test.
The easiest way to do it is to create a function and call it to perform all the tests (fixed and random). Something like this:
And then replace all the tests with
You must keep some consistency with other languages. In most of them, the number of tests is high, and the values tested are much greater. Naive
O(N)
solutions must not pass. I suggest to increase the number of tests to 1000, and the maximum value to 2147483647 (max int32), that's what is done in C++ for example.Go translation
Oh! Sorry, I didn't know my comment was visible since it was under a solution. Thank you!
Please don't post spoilers without using Spoiler flag, as your comments are visible to everyone on front page - even those who haven't solved the kata; knowing the name of "the correct" algorithm or data structure to use is basically 80% of the way towards a solution in many cases.
This comment is hidden because it contains spoiler information about the solution