Ad
  • Default User Avatar

    Check the scope of all your variables. Behaviour like this usually indicates some value is persisting between method calls.

  • Default User Avatar

    Of course! That makes sense and I should have saw that. The random tests would use the same input to validate. Static tests would know what output to expect.

    Thanks.

  • Default User Avatar

    Since you fail the random tests I strongly suppose that you modify the given input (for example you reverse it in place) and so the reference solution for the random tests doesn't work on the "good" array. Work on a copy of the given input. Cheers.

  • Custom User Avatar

    Given almost all posts about getting timeout are marked as having spoilers because they have, and the same answers are repeated over and over, read this if that's your case:

    Your code's time complexity is O(n2) and that won't work here. You code's time complexity should be O(n) to pass. Try googling "Big O notation" (it's a long subject to explain it here properly), your code should work in linear time, so if your code use nested loops or a loop and a loop-alike method inside try another way.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    I'm having issues with the large array tests in Powershell. The test case and my code always arrive at the same final sum (value at index 0 in the result) but my results differ from the expected results by a small amount in every other value. I also end up with a shorter array by 2.

    As an example, the first 3 expected totals from a random test are 0, 5, 24 and my results are 0, 4, 14 yet we both end up with a final total of 8398.

    I output the array passed in and manually worked out the first few results. The results calculated manually match what my algorithm is calculating but do not match the expected results. Example from a random test:

    First few values: 16 16 18 14
    Expected results: 0 12 33 38
    My calculated results: 0 16 32 50

    I don't see how the expected results are getting calculated.

  • Custom User Avatar

    New to JS (relatively), working my way through Katas on my second day here on Code Wars. Found this Kata, and wanted to try it. Very interesting, and sneaky. I thought I had a solution but then STAN came along and threw me for a loop. Well not really a loop, but you know what I mean!

  • Default User Avatar

    @BruiserMcCruiser: I slightly modified the tests (Should -BeExactly instead of Should -Be) hence some solutions are invalidated.
    Thanks for your post.

  • Default User Avatar

    Did you try turning it off and on again?

  • Default User Avatar

    I just completed the PowerShell version and realized my solution did not make all characters uppercase. Simple omission on my part that should have been caught by the tests. I realize PowerShell is still in beta. This is probobly just the wrong comparison operator in the test code (easy to get mixed up since it's case insensitive by default).