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.
You don't need second reverse as you end up using reduce :)
In this, to type digit 7, one needs to press 5 times. This test is not present! I can hardcode presses for [2-9] as 4 and still it works! Please add the testcase having 7 or 9 digit in string.
This comment is hidden because it contains spoiler information about the solution
Does this needs to be sequential replacement? Damn.
This comment is hidden because it contains spoiler information about the solution
Ah.. Done it :)
I am so close... But the unary negative and subtraction is making me still fail... Spent almost three hours till now. Now I need some break before trying again :)
Good kata. The brute force is generally the first thought, but once it fails, you think of more elegant solution. It was fun to solve :)
I have done in System.out at begining and end of method (you can see the method body attached).
This comment is hidden because it contains spoiler information about the solution
Yes. I agree. I was facing issues with rounding. Thanks for this. I was getting some weird values at my local machine, hence I used BigDecimal.
Nik
I have to crank up calculations using very precise bigdecimals!! Also, return type of int for output was lot troublesome. Return type should be array of double instead of array of int.
Also, for this example I think Java was not most easy language to use due to floating point arithmatic messes.