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.

  • Default User Avatar

    Thanks for the answer, it helped a lot

  • Default User Avatar

    Hi ah2023,

    When I try your solution it passes all the tests, so I can't reproduce the issue. But in general, if you print out the customers variable at the top of your code, you should be able to see what causes any failing test.

    Regards,

    brodiemark

  • Default User Avatar

    can I find out which example test is causing the following message:

      Number of allocated rooms is larger than necessary
      Expected: True
      But was:  False
      
    An identifier would be great.
    
  • Custom User Avatar

    Performance constraints are different, and the identifyable parts are also different enough to make these two different kata's.

  • Default User Avatar

    Fixed the other languages.

  • Default User Avatar

    I have modified the tests so that, even if the user's code modifies the argument 'customers', the tests and validation messages refer to the original customer list. I think this is preferable to making the argument const in order to be consistent with the other languages.

  • Default User Avatar

    I have modified the tests so that, even if the user's code modifies the list of customers, the validation messages refer to the original customer list. I also modified the validation procedure to give a diagnostic message that explicitly compares the number of rooms used by the user solution to the correct number of rooms.
    (This refers to Python - I will do the other languages as soon as possible.)

  • Default User Avatar

    Thanks for doing that! Sorry that I have been "out of action". I got distracted by the T20 cricket :-) Hopefully I will have some time to fix the other languages soon.

  • Custom User Avatar

    I can't imagine how to speed up an algorithm) Apparently, learning programming at 35 is too late

  • Custom User Avatar

    Fixed for Java.

  • Custom User Avatar

    Nice to practice with.

  • Loading more items...