Ad
  • Custom User Avatar

    your code still doesn't handles cases with arr[0]==arr[1] (you can try this with the example input [18, 18, 10, -3, -4, 15, 15, -1, 13, 17, 11, 4, 18, -4, 19, 4, 18, 10, -4, 8, 13, 9, 16, 18, 6, 7]

    a fixed test has been added with the very same example

    tag these kinds of comments with suggestions/question. issue tags are used when there is a bug with the kata, where this is a problem with your code

  • Custom User Avatar

    your first approach is not good enough because its complexity is not sufficient. you need something better than O(n). The second approach is O(1) (kinda) and would be ok if you had decimal numbers with a veeeeeeeeery large precision at your disposal. 1024 bits of precision is not enough for numbers with thousands of digits.

    you need to find an algorithm which is better than linear complexity, and uses precise numbers thorough all calculations.

  • Custom User Avatar

    OP solved it, closing

  • Custom User Avatar

    my code works fine with python 3.8

    No, your code works with your tests. If you called your function with the same inputs as the ones tested here, it would raise the same exception(s). You already see which input causes your function to fail - now try actually debugging it.

  • Custom User Avatar

    Make them local inside pick_peaks and pass them as arguments to the other function, in theory, that would work.

  • Custom User Avatar

    Make your global vars local.

  • Custom User Avatar

    If you need help improving your solution, you can post your code here so others could see it and share some hints. You can also go to Codewars Discord and ask for help at #help-solve channel.

  • Custom User Avatar

    You seem to confuse primes generator with primarily test. Sieves are not tests, they are prime generators. To test for a prime you do not need prime generators. You could use one, but not in the most trivial way of generating all primes up to N.

  • Custom User Avatar

    2000000000 is the maximum value tested in random tests in Python. On your computer you can only do the basic tests, which are easy and not numerous ones.

  • Custom User Avatar

    This is a very classic mathematical problem, and an easy 6 kyu kata. You need to use another method, make an online search and you'll find easily. Any hint we could give you would spoil the solution.

    Just one thing: to find out if a number is prime, you don't need all the primes below it. Actually you don't need any of them, you just need to check... it's prime.

  • Custom User Avatar

    Try a few tests with n = 2000000000 or similar.

  • Custom User Avatar

    Your approach is very inefficient. This is not a kata issue. See there: https://docs.codewars.com/training/troubleshooting/

  • Custom User Avatar

    letters_count has keys only for the letters of the given word and not for other letters (e.g., for word='abba', letters_count = {'a':2, 'b':2})

    you need to rethink your algo, or use another tool to handle key errors

    try to use markdown syntax to make the solution more readable in discourse https://docs.codewars.com/references/markdown/