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.
This comment is hidden because it contains spoiler information about the solution
Massive W to all Java devs on StackOverflow
Had to relearn reflections for this. 100% worth it, I enjoyed it a lot!
What do you think happens if a String argument is given? What is supposed to happen?
This may be my new favorite kata on the site, very well made!
Hey! Awesome Kata. I haven't used Reflection in a while and this was a nice refresher:)
One suggestion. Some test cases that check some error handling would kick it up a notch?
Probably because it shows understanding of Java syntax.
Also, what is your solution? Do you know a faster way to perform it?
You can just use var keyword for java 11, without needing to import Annotation
Nice approach, I like it.
approved and slightly updated
I think it would be better if java.lang.annotation.Annotation would also be imported in the starting code.
I know it does. It is easy to fix it but guess what, I didn't CARE.
Also dividing integers by 2 is FAST and len() is also FAST.
This implementation calls len(s) FIVE times when it only needs to call it once. It also divides len(s) by 2 FIVE times when it only needs to calculate it once.
Nevermind. I was testing for the best case, which is a 10-element array. But with an average case of a 5-element array, they are even more similar, producing 4.0-4.1 unique elements each. So I still don't understand what do you mean.
I think you are mistaken about the chances of duplicate elements being lower on my translation. I tested both the JavaScript implementation with ~~(10*Math.random())+1 and my Ruby implementation using rand(1..10), and if I generate 100 arrays with 10 elements, both come back with between 6.3-6.6 unique elements on average. In fact, most of the times Ruby's kernel rand yields slightly more duplicates. So I'm not really sure what looks off to you about my translation.
Loading more items...