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.
It's a great solution that doesn't assume the three numbers(25,50 and 100)
It's just the opposite.
For future readers Collections.sort(..,Collections.reverseOrder());
It took me a few min to realise that its a good one haha
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Dont mean to burden with this simple operation but I'm left a bit confused on the !(weight % 2) can someone shed some light on this...
inefficient way of implementing simple method using heavy libraries.
Finally a solution which goes the generic way ! I love it ! The value-specific logic proposed in most solutions horrifies me to no end ...
A bit over the top for the task, but solution uses OOP and a decent lookup algorithm which could handle other bills than the ones given in the instructions without codechange.
+Clever for this. (Reverted +BestPractce since it is somewhat contrary to the Effective Java Recommendations, like extending a Hashmap instead of wrapping one).
The condition for n === 1 is actually unnecessary, since if n = 1, triangular(1 - 1) + 1 = triangular(0) + 1 = 0 + 1 = 1.
Indeed, it does call triangular(0), which returns 0, which is added to the recursive summation, causing no change to the value:
triangular(4) =
triangular(3) + 4 =
triangular(2) + 3 + 4 =
triangular(1) + 2 + 3 + 4 =
triangular(0) + 1 + 2 + 3 + 4 =
0 + 1 + 2 + 3 + 4 =
10