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.
Very concise and readable code, I like it 👍
This is unbelievably shit. How did everyone else solve this in 10 lines??? :|
If you know Swift and have time it would also be cool if you guys could vote on my Swift Translation. Thanks!
https://www.codewars.com/kumite/63a9dde183e9d80bd5b11963?sel=63a9dde183e9d80bd5b11963
Ah it's already approved, cool. Thanks guys.
I couldn't quite follow @Madjosz's comment, but that's probably because I'm new to automated testing and codewars. I don't see any problem by shuffling the test cases, so that's totally fine with me.
Hey markus, thanks for getting back! I feel pretty strongly about having at least one test case that tests a non-narcisstic number. Because the current tests would return that your program is correct if your program simply returns true for any input.
I feel relatively strongly about not including the ^ operator hint, because I was confused by it at first and it's really just explaining a basic feature of the language. If you feel strongly about including it I would be fine with that though.
Thanks also for your info on the PHP translation, that should then probably also be adjusted I guess
The original poster is probably inactive, so if anyone wants to fork this and implement some of the improvements mentioned in the comments that would be awesome!
Also there is
testRandomNonNarcissisticNumbers()
which does test random shuffled numbers. But only non-narcissitic ones.I think it makes sense to test the narcissistic numbers in a non-randomized manner because we can easily list them all. And it makes sense to test the non-narcissistic numbers in a randomized manner because there are too many to list them all. But why are there two different test functions for testing non-narcissitic numbers? The randomized one and the non-randomized one? That seems a little redundant. Althought I guess it doesn't do any harm.
In
testExampleNumbers()
it might be nice to have a few more numbers than 2. Because maybe the user's code randomly gets the right answer just for those two numbers, but is generally incorrect.Here are the sample test cases from the Haskell version:
Why is
10
part oftestEdgeCases()
? Why is 10 considered an edge-case?What do you mean by "too obvious"? Why should the test cases be non-obvious? What problem would shuffling the testcases solve?
Sorry if I'm not understanding something that is common knowledge I'm new to codewars and automated testing.
The line in the description
"(Hint: The ^ operator (exclusive or) is probably not what you want to use in your solution.)"
feels a little out of place to me. I think that's something I would want to figure out on my own when trying to solve the problem.