Ad
  • Custom User Avatar

    They're in a numbered list, so minimizing i should take precedence over minimizing j.

  • Custom User Avatar

    Chrono79, as you say i must be as small as possible. But it also says the same about j with no statement about which should take precedence. In the case of 0, 1 it could also be done as 1, 0 with the same effect (and this would be the simpler way too). I might have misunderstood but it seems for the 0, 1 case to make sense another explicit rule would need to be in the text.

  • Custom User Avatar

    No problem, but starting from 269045 and using i = 0 and j = 3 would be 690245, don't forget the 0 will be still there ;)

  • Custom User Avatar

    I get it now, [26945, 0, 3] will give 69245, wich is > 26945.
    Thank you very much :D!

  • Custom User Avatar

    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 get 26945 moving the 2 (index 0), you get that number moving the 0 (index 3)

    1. the index i of the digit d you took, i as small as possible
    2. the index j (as small as possible) where you insert this digit d to have the smallest number.

    Maybe you'll see it better if you write it as 026945 that as a number is 26945. You don't swap two digits either, you take a single digit and move it.

  • Custom User Avatar

    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].

  • Custom User Avatar

    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.

  • Custom User Avatar

    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?

  • Custom User Avatar

    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.

  • Custom User Avatar

    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 :)

  • Custom User Avatar

    Test.assertDeepEquals should be used in JavaScript.

  • Custom User Avatar

    Nobody's going to change kata specifications after 6k+ people solved it.

  • Custom User Avatar

    A plain dictionary should be returned.

  • Custom User Avatar
  • Custom User Avatar

    Bumping an issue from 2 years ago - Python 3 should be enabled.

  • Loading more items...