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.
duplicate:
Random test cases added.
Negative numbers should be handled as regular, - * - = + .
You should tell how to handle the edge cases, instead of guessing after attempting the solution.
Looking at the reference solution, it would seem that
"1"
and similar strings of numbers are not to be rejected. This is not tested for though.NaN
?) instead of discovering what to do when they fail the actual test cases upon submission.Would happily translate your Kata into PHP when it is ready and approved :) (that is, if someone doesn't beat me to it first ;) )
Agree with (1) and (3). Wrt (2): well, return the maximum possible product, which is
-7 × -4 × 3 = 84
. But a mention negative numbers are possible would have been nice.A reasonable decision to handle less than three numbers would have been to throw an exception BTW, not return some string instead of a number. And just ignoring non-numbers is also perfectly reasonable, after which there may or may not be three or more left. Solvers are asked to guess what author was thinking and do that instead. Sorry, I do not consider returning strings when a number is asked for reasonable. It's bad design and it should not be practised. Zozo has a beautifully subtle way of implying what he thinks of it. :]
-4*-7*3=84
There are some issues on this kata:
[-4,3,-7,2]
84 is expected, but 2x3x-4 is -24.Would love contributors to write solutions for other languages.