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.
The other kata tells you how to go from
156
to[6,7,11]
. All you have to do is reverse that.Of course, the input might have been
12345
, so you'd get[3,4,5,6,5,6,7,7,8,9]
. Could you get back from that to12345
?Collecting some different inputs and outputs from the other kata might be useful; you might be able to spot patterns without trying to reverse the manipulations from first principles.
any non spoiler - hints?
Not giving out spoilers, sorry.
Was debating asking a question but I gave in :)
I did the other kata being mentioned here - but i'm still lost.
The previous kata returns the array and it looks like what's being passed in this funciton (sums) is that array.
How are we manipulating the array here [6,7,11] to get 156?
Smart and concise solution as there is only one iteration (not including
String.prototype.substring
)Can someone explain me this solution ?
Pooh! That was really difficult but exciting!
But it had to make a hack on the case with one element in the array.
Now will examine other solutions.
Thank you!
It's also testing backwards.
Your input is
[3]
. Allowed return values would be12
,21
or30
.Because there can be multiple possibilities, the test checks the resulting sums of digits, not the return value itself. Those digit sums are unique.
test case which make me so confused!
testing for 12, Expected: [3].
??
Ahhh... Ok thank you, now i understand.
THATS why I'm so damned confused
Because
156 => [ 6, 7, 11 ]
This is the reverse of another kata. The top of the description is from that other kata.
This comment is hidden because it contains spoiler information about the solution
The description is bad. We don't understand why the expected value of the first test is 156.
[6, 7, 11] -> [ 6 + 7, 6 + 11, 7 + 11] => 48, not 156.