• Thanks! Have a better grasp now. The figure in the description helped also.

  • The figure is the union of unit squares, there aren't triangles.

    Imagine a plane divided in unit squares, each square has (x,y) coordinates.

    Added an image with examples in description.

  • Python: I feel lost..can someone explain this kata please. Thank you! I dont understand the coordinates and how they create a square vs a triangle and its relation with width and weight. I'm imagining a chart for x and y, maybe this is where I'm wrong and just not understanging how the coordinates relate to the figure

  • @jacosta66, if you're asking about what O(n) means (or the "O(...)" notation in general is), its basically a way to estimate what the upper bound of execution time a certain piece of code would take to complete.

    An example of O(n) means that a function will complete in the worst case by parsing a given list a constant number of times. So with a list of 100 elements, we can expect the upper time complexity limit to be a multiple of the time it takes to process all 100 elements.

    Conversely, O(n^2) means that for every element in the list, we have to parse the entire rest of the list elements. So for 100 elements, we can parse somewhere around 100^2 or 10000 elements total. That difference in time taken is what makes the 10 million element case impossible to solve within a reasonable timeframe.

  • I'm afraid there is no link as you wanted, just think simple, code simple. Other authors and I just use basic datatypes to solve this one

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

  • you passed the simple test, not ALL
    NOTE: There will also be lists tested of lengths upwards of 10,000,000 elements. Be sure your code doesn't time out.
    this kata requires O(n) solution, try to use a better way.
    Hint for python guys, if you are already use for each, don't use operator "in" or "not in" inside
    good luck

  • i have the same conclusion, and i dont know how to fix it
    i have 2 "for ..." in my code, but i've used time library for python and it is OK
    i'm from russia, sorry if i have mistakes

  • How about adding some print statements to debug exactly what elements and indices you're looking at for a simple case?

  • Python: I pass all the test, but when choosing 'attempt' the execution times out. What could be the reason?

  • All test passed but can't submit due to this message:

    Traceback (most recent call last):
    File "main.py", line 14, in
    Test.assert_equals( digital_root(0), 0 )
    File "/home/codewarrior/solution.py", line 9, in digital_root
    return sum(l)
    UnboundLocalError: local variable 'l' referenced before assignment

    What does this mean?

  • Thank you very much!

  • '1go litt2le pa3rt that4 5in 6case ' # your returned string has a trailing space
    '1go litt2le pa3rt that4 5in 6case'  # the expected value hasn't

    Read this: https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution

  • Testing: "that4 pa3rt 1go 5in 6case litt2le"
    '1go litt2le pa3rt that4 5in 6case ' should equal '1go litt2le pa3rt that4 5in 6case'

    When I try this on a diffrent IDE(repl.it), I get the desired output. But when running here lots of fails occur. There most be something I'm not understanding. I'm very new to the website.

    I figured it out incase anyone comes accross this issue. I had whitespaces on the string. Utilized strip() on the final string to eliminate any whitespaces from the begging and end of the string.