Ad
  • Default User Avatar

    facepalm Thank you!

  • Default User Avatar

    I'm confused on how you get the final answer. Given [5,7,8,9,0] from one of the example tests, how do you get 8? There's certainly more than 8 possible permutations.

    If these are the mappings based on digits adjacent neighbors:

    1: ['1', '2', '4'],

    2: ['1', '2', '5', '3'],

    3: ['2', '3', '6'],

    4: ['1', '4', '5', '7'],

    5: ['2', '4', '5', '8', '6'],

    6: ['3', '5', '6', '9'],

    7: ['4', '7', '8'],

    8: ['5', '7', '8', '0', '9'],

    9: ['6', '8', '9'],

    0: ['0', '8']

    Then you could have the possible permutations:

    1.) [5, 4, 8, 9, 0]

    2.) [5, 4, 8, 9, 8]

    3.) [5, 4, 8, 6, 0]

    4.) [5, 4, 8, 6, 8]

    5.) [5, 4, 8, 8, 0]

    6.) [5, 4, 8, 8, 8]

    7.) [5, 4, 5, 9, 0]

    8.) [5, 4, 5, 9, 8]

    9.) [5, 4, 5, 6, 0]

    10.) [5, 4, 5, 6, 8]

    etc, etc.

    [5, (4,7,8), (8,5,7,0,9), (9,6,8), (0,8)]

    [2, (4,7,8), (8,5,7,0,9), (9,6,8), (0,8)]

    [4, (4,7,8), (8,5,7,0,9), (9,6,8), (0,8)]

    [8, (4,7,8), (8,5,7,0,9), (9,6,8), (0,8)]

    [6, (4,7,8), (8,5,7,0,9), (9,6,8), (0,8)]

    So how does 8 become the final answer?

  • Default User Avatar

    Not a bad one. I think the example walkthrough can be way more clear. Like even after solving it, I'm still not sure how starting with the solution (2,2) aids in understanding. I had to just go through the other examples and write it out to figure out my solution. Maybe something like: So for example, lets say you have lst = [1,2,3,4]. Think of the first 2 indices as the start of the left and right side. So starting from left to right, we have 1 box (lst[0]) on the left going to the right (lst[1]). So now we have (0, 3) where 0 is the left and 3 is the right. Now it's time to go from right to left. The next amount of boxes to move comes from index lst[1] since we are now going through each move operation in lst. So now we are moving 2 (lst[1]) from the right side, 3, to the left side, 0. So we get (2, 1). Find the amount of additional boxes needed if the current amount of required boxes lst[i] operation (left or right movement) is short for the current side.