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.
They're in a numbered list, so minimizing
i
should take precedence over minimizingj
.Chrono79, as you say
i
must be as small as possible. But it also says the same aboutj
with no statement about which should take precedence. In the case of0, 1
it could also be done as1, 0
with the same effect (and this would be the simpler way too). I might have misunderstood but it seems for the0, 1
case to make sense another explicit rule would need to be in the text.No problem, but starting from
269045
and usingi = 0
andj = 3
would be690245
, don't forget the 0 will be still there ;)I get it now, [26945, 0, 3] will give 69245, wich is > 26945.
Thank you very much :D!
The input is
269045
right?The smallest number you get following the kata instructions is
26945
i
is the index of the digit you move, you don't get26945
moving the 2 (index 0), you get that number moving the 0 (index 3)Maybe you'll see it better if you write it as
026945
that as a number is26945
. You don't swap two digits either, you take a single digit and move it.The solution I dont understand is not this one [29917, 0, 1].
It it this one [26945, 3, 0], if you want i as small as possible it should be [26945, 0, 3].
No, they're not, read what I wrote again, first case you move the 2 and second case you move the 0, why? Because you want
i
as small as possible, so[29917, 1, 0]
is not a solution and[29917, 0, 1]
is. In the second case you have to move the 0, not the 2 to get the smallest possible number.Sorry I'll go for the question next time, but I still dont get it.
Both cases are 2 (index 0) inserted at the index of 0 (index 1 and 3).
What am I missing?
Next time use Question, not issue if you don't understand something.
Finding the smallest digit and moving it is not the first step in both cases.
In the first case, you take the 2 (index 0) and insert it back at index 1.
In the second case, you take the 0 (index 3) and insert it back at index 0.
Can someone explain me why both of these case doesnt work the same way?
testing(209917, "[29917, 0, 1]");
testing(269045, "[26945, 3, 0]");
The way I understand it:
1): You find the smallest number (0)
2): You find the index of the digit i as small as possible (0 and 0)
3): You find the index of j, both the zeros (1 and 3)
In both cases you need to swap a Zero with the First element, why are the results [0,1] and [3,0] not in the same order?
Thanks :)
Test.assertDeepEquals
should be used in JavaScript.Nobody's going to change kata specifications after 6k+ people solved it.
A plain dictionary should be returned.
Bumping an issue from 2 years ago - Python 3 should be enabled.
Loading more items...