Ad
  • Default User Avatar

    Actually, what I left out is test.describe. I have @test.it('Example Tests'). If I include both, the output shows two levels of indentation, which to me looks strange. Is it OK to leave out test.describe?

  • Default User Avatar

    Thanks for the feedback! I clarified the meaning of smallest, and changed index to position.

  • Default User Avatar

    Changed to array of 2 vectors of integers.

  • Default User Avatar

    There can be more than one treasure in the grid, but only one is reachable from any given starting position. The random tests generate one treasure and clues to it. The other numbers are random, so there could be other treasures.

    I am thinking of creating a harder version in which you have to find all the treasures, and also avoid clues that lead into a cycle.

  • Default User Avatar

    Shouldn't the description say something about the size of values being tested, so that one knows that something quicker than the straightforward approach is needed?

  • Default User Avatar

    My apologies for not responding to your original suggestion. Obviously the question of whether indexes should start at 0 or 1 is a matter of style. I prefer 1 in this case for the following reason: If someone says something like "the maximizing move was move 8", they most likely mean the 8th one, not the 9th one.

  • Default User Avatar

    whats the point of large random test?

    Good question. I was following other kata which divide the random tests into two groups: small tests, which print the test input to help the user with debugging, and large tests which don't. The large tests could be removed, but maybe it's fun to see the size of the trees.

    In terms of changing the range, random.randint(10, 100000) is not the size of the tree; it's the minimax value of the tree. So making it 10000 - 100000 wouldn't make a difference.

  • Default User Avatar

    It looks like 6kyu has taken the lead in the votes. That was my original assessment, and I'd actually prefer it, because I think more people will do it at a easier rank.

  • Default User Avatar
  • Default User Avatar
  • Default User Avatar
  • Default User Avatar

    The trees are generated using a random depth and random branching factors at each node. But the depth or number of siblings will never be close to a million.

  • 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

  • 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

  • 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

  • Loading more items...