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.
Well, it certainly isn't best practice.
Might seem a bit complicated, but I wanted to avoid writing all or any possibilities at all cost and see how it goes.
There is only "one case" when addition will be greater than multiplying and it is when it involves a
1
operand.So whenever I found a
1
I add it to its smallest neighbour.(a + 1) * b > a * (b + 1)
ifa < b
.If
1
is found at the beginning then I add it to the second operand hence the first line, avoiding to make the second line over complicated.The rest is just multiplied.
Then the function might be of operands quantity free :) .
If there is either a simpler or a "cleaner" (in a way of more Ruby friendly or better practise and still the same conditions) way of doing this I am interested :) .
Either I do not understand with the kata or I disagree with the last test.
From my understanding the following:
Should sort into (from most desired to least):
Which should give the result
[1, 0, 1, 0, 1]
(note that this is a special case wheresize
ANDvalue
sort the same way).Instead we got strangely something like that? :
As the exercise expect
[2, 1, 1, 0, 0]
.That is super strange, no?