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 ;)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.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.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.
Segfault.