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.
I did not know about IdentityHashMap, thanks for sharing! That would definitely work here.
When I used a HashMap, I used Node.toString() as the key. Now I understand that I was making an assumption that the toString() and hashCode() methods where no overridden in a way that would break my HashMap.
I love all of the comments and java docs. well done.
Why did you make a method for
protected static char increment(char c)
? I believe you do not need to do type conversions to increment achar
variableivanightingale, what is wrong with that?
I like the "why break at all if you can return the result straight away?" People should try it out before they say something.
You can get away with putting a return in the middle of a small easy to read function like this. But it is generally better practice to try to limit a method to one return.
It is easier for someone else to understand the method when there is fewer returns from the method. Easier to see where the function can end.
Why can't you return the result straight away using break?
why break at all if you can return the result straight away?
The formula takes a lot less time than recursion or loops for really big numbers as far as I know. Also, the formula only gives integer outputs for intger inputs (the coefficient on the sqrt(5) term always ends up as 0). I think ths formula is a lot more efficient, however there might be an accuracy issue due to the use of doubles, but I never experienced such problems.
instead of using the 'stop' boolean, you could use the built in command 'break' to break the for loop when the condition is met.
I agree with trying to limit the return to the last line in the method. This is small enough to see it easily in the middle.
Interesting use of the formula to define fibonachi numbers. But I would question all of the squareroot and power calls. Possible performance or accuracy hit
Only issue is resorting the array can be a system hit for large arrays, reallocating memory for sorted new arrays.