Ad
  • Default User Avatar

    Hi thr3zims,

    For each sample test, it should return only the sequence of swaps for that input. For the second sample test, the last snapshot should be [18, 20, 30], but your program doesn't return that. That's why you are getting that message.

    The sample tests are just examples. You shouldn't hardcode them, because your code is supposed to work for any list, not only the sample ones. Once you pass the sample tests, your code is going to be tested on other, hidden, lists, and it has to return the correct sequence of swaps for all of them as well.

    I really suggest trying an easier problem as your first one, so that you understand the problem-solving process before trying harder problems.

    Regards,

    brodiemark

  • Custom User Avatar

    I've made the proper changes so it's a list of arrays of integers. Now it's saying "The last snapshot is NOT the sorted list [18, 20, 30]. ==> expected: <true> but was: <false>". It seems someone else here had a similar problem but I'm not quite sure how to fix it.

  • Default User Avatar

    Hi thr3zims,

    Two issues:

    (1) In almost all codewars problems, you need to return the final result, not print it. Your program is returning the empty list, which is only the correct answer if no swaps are needed (meaning the original list was sorted).

    (2) Your list of swaps is a list of lists of integers, but the problem definition requires the return value to be a list of arrays of integers. (This is because all the inner data-structures are all the same size, so it's more convenient to have them be arrays.)

    It might be worth getting experience solving easier problems before trying this one.

    Regards,

    brodiemark

  • Custom User Avatar

    I keep getting the fail message "Initial list is not sorted, so correct answer is NOT []. ==> expected: <true> but was: <false>". I've tried everything i can think of or find online to try and fix this but nothing seems to work. This is my output whenever I test it:

    [30, 18, 5, 30, 51, 10, 20, 99, 50, 30, 100, 33]
    [30, 18, 5, 30, 20, 10, 51, 99, 50, 30, 100, 33]
    [10, 18, 5, 30, 20, 30, 51, 99, 50, 30, 100, 33]
    [10, 5, 18, 30, 20, 30, 51, 99, 50, 30, 100, 33]
    [5, 10, 18, 30, 20, 30, 51, 99, 50, 30, 100, 33]
    [5, 10, 18, 20, 30, 30, 51, 99, 50, 30, 100, 33]
    [5, 10, 18, 20, 30, 30, 51, 33, 50, 30, 100, 99]
    [5, 10, 18, 20, 30, 30, 30, 33, 50, 51, 100, 99]
    [5, 10, 18, 20, 30, 30, 30, 33, 50, 51, 99, 100]

    If anyone could help me with this, I would greatly appreciate it.