Ad
  • Custom User Avatar

    so true, i'am also so confused

  • Custom User Avatar

    I have to say that the order of two substrings with the same length is so unclear.
    I failed in the test only because of the order.
    There must be much more explaination about it.

  • Custom User Avatar

    unpublished (see issue below)

  • Custom User Avatar

    Don't let wikipedia describe the kata for you.

  • Custom User Avatar

    In a case of having "2 11", I'd prefer the output to be sorted by stable sort, but it's your choice.

  • Custom User Avatar

    Good idea, I did it.

  • Custom User Avatar

    So the items between the bounds are taken from the sorted array... Then the description is ambiguous.

    Or even between the bounds numerically, not in the array...

  • Custom User Avatar

    yeah...

  • Custom User Avatar

    As mentioned above, find both bounds in the sorted array, then as an independant operation, filter all values from the original array between those two bounds.

  • Custom User Avatar

    Now it looks more like an issue. Changed Suggestion to Issue.

  • Custom User Avatar

    If there are duplicates on the bounds, you have to include all of the duplicated numbers in the sum. So in your example, 2 is the second and third smallest number, you have to include both 2's in the sum. I guess if you had a list that was just [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] with i = 1 and j = 5, you would have to sum the entire list.

  • Custom User Avatar

    Ah yeah, I had not seen ^^

  • Custom User Avatar

    Already wrote a suggestion below ;)

  • Custom User Avatar

    Also with

    def partial_sum(array, i, j):
        array.sort()
        return 0
    

    it throws

    Unexpected exception raised
    
    Traceback (most recent call last):
      File "/workspace/default/.venv/lib/python3.10/site-packages/codewars_test/test_framework.py", line 112, in wrapper
        func()
      File "/workspace/default/tests.py", line 54, in test_case
        test.assert_equals(solution.partial_sum(lst, a, b), solver(lst,a, b))
      File "/workspace/default/tests.py", line 27, in solver
        a_element = select(array, 0, len(array)-1, a)
      File "/workspace/default/tests.py", line 22, in select
        return select(array, p, q-1, i)
      File "/workspace/default/tests.py", line 22, in select
        return select(array, p, q-1, i)
      File "/workspace/default/tests.py", line 22, in select
        return select(array, p, q-1, i)
      [Previous line repeated 991 more times]
      File "/workspace/default/tests.py", line 17, in select
        q = partition(array, p, r)
      File "/workspace/default/tests.py", line 7, in partition
        for j in range(p, r):
    RecursionError: maximum recursion depth exceeded in comparison
    
  • Custom User Avatar

    I know this has to be a duplicate to one kata that I cannot recall AGN.... (Might be myjinxin's... which is 6kyu with a much more storyline-related description !

    (Will modify my comment to be an issue once I found it!

  • Loading more items...