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.
Slower for what task? It is unlikely that this will be the bottleneck in your code, and stack operations are incredibly fast. They don't even incur garbage collection penalties. Regardless, such talk is certainly premature optimization. Pick a context that the code will run and then optimize for that. If no context is given, this is solution is using best practices.
Big-O notation ignores constant factors. You should not write O(2n). It's just O(n).
No need to apologize :-)
Thank you very much for the information. I'm new to Java and am still learning. You are correct I'm really not sure why I did this but now after reading your comment I can see how stupid it was. Thanks once again.
I can say if it works in Chrome, I don't have Chrome but it works in Google Chrome and Firefox.
I'm not able to see the drawing - in Chrome?
Either way, it's still probably slower since it's building up the stack, which requires register swapping.
You seem to be obsessed by big O notation but is it about this kata?
Yes, I understood that but about what?
He's talking about big O notation, aka asymptotic complexity.
?
Hi, sorry, didn't get you. This solution works perfectly.
What is the issue?
Sure! It works for everyone, not only for you:-)
I used recursion since we're guaranteed never to go more than 12 layers deep. The restriction exists because 13! using ints results in, I believe, something like -215,430,147 (caused by an integer overflow). Basically, you'll hit other problems way before you reach a stack overflow.
In this particular case, I think it's also more clear what's happening than when using a loop, but that's probably just me.
Also, I like to one-line my katas, where possible.
New to Java and playing around with what their collections can do. Definitely not the optimal way to do this. I'll probably do another solution that doesn't use any of their classes and uses a more basic and "manual" approach.