Ad
  • Custom User Avatar

    thank you @hobovsky

  • Custom User Avatar

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

  • Custom User Avatar

    @FArekkusu thanks, now i see where the problem is

  • Custom User Avatar

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

  • Custom User Avatar

    The first version of my code passed all tests and was submitted but got an error when arr[0] == arr[1]. This was evident when the random tests put the same value for both indexes. The initial fixed tests should include a test to check it. My code was not right because it included as a peak the value of arr[1] when arr [0] == arr [1], and in this case, arr[1] cannot be a peak.

  • Custom User Avatar

    It was my mistake, I did not consider cleaning the vars before sending the return, and being global they also kept the values of the previous tests.

  • Custom User Avatar

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

  • Custom User Avatar

    I am having a problem with the use of global variables, out the box my code works correctly, but here in the tests, it fails flat out in all the tests. I have tested with different versions of python and in all of them, it works correctly.

    [spellmell@nexus codewars]$ python3.8 15_pick_peaks.py
    [7, 9, 5, 0, 7, 9, 9, 8, 6]
    pos:[1, 5]
    peaks:[9, 9]
    python 3.8.12 (default, Aug 30 2021, 00:00:00)
    [GCC 11.2.1 20210728 (Red Hat 11.2.1-1)]

    [spellmell@nexus codewars]$ python3.9 15_pick_peaks.py
    [7, 8, 9, 5, 4, 0, 4, 2, 3]
    pos:[2, 6]
    peaks:[9, 4]
    python 3.9.9 (main, Nov 19 2021, 00:00:00)
    [GCC 11.2.1 20210728 (Red Hat 11.2.1-1)]

    [spellmell@nexus codewars]$ python3.10 15_pick_peaks.py
    [6, 1, 0, 3, 4, 8, 7, 2, 8]
    pos:[5]
    peaks:[8]
    python 3.10.1 (main, Dec 7 2021, 00:00:00) [GCC 11.2.1 20211203 (Red Hat 11.2.1-7)]

    Here: Time: 500ms Passed: 0 Failed: 10 Exit Code: 1

    It is confirmed that the problem is the global variables, when removing them the code works.
    I was reading the "troubleshooting" page, and I see that there is some reference to the problem, but
    I can't understand. Any suggestions on how I can solve it?

  • Custom User Avatar
  • Custom User Avatar

    this kata should not be named scramblies it should be named pass the timeout

  • Custom User Avatar

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

  • Custom User Avatar

    @akar-0: I guess Eratostenes never thought of calculating such high numbers :S thx for the hint.

  • Custom User Avatar

    thx for the link, but you can help me to understand why? in my machine "execution time : 0.021 s" and tests here allways says under 600ms.

  • Custom User Avatar

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

  • Custom User Avatar

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

  • Loading more items...