Ad
  • Custom User Avatar

    Hi seraph776! Your solution appears to be quite creative, but regrettably, it is SLOWER and INEFFICIENT.

    The time complexity of your function is O(n^2), while mine is O(n). With that being said, yours is SLOWER.

    Let's see if is WAY SLOWER. Don't believe me, just watch, come on!

    len(text) Mine Yours
    100 0.0069141387939453125 ms 0.03218650817871094 ms
    500 0.008821487426757812 ms 0.24199485778808594 ms
    1000 0.013113021850585938 ms RecursionError: maximum recursion depth exceeded while calling a Python object

    Both functions used the same text for the tests, and the text was generated randomly using:

    def generate_random_string():
        return ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(1000))
    

    Besides, as you can see, YOUR FUNCTION DOES NOT SUPPORT LONG STRING CHAINS.

    Why?

    Python has a limit on the depth of recursion to prevent a stack overflow. Since the size of the call stack is finite, a program or a function that recurses too deeply can exhaust the stack. In Python, the maximum depth of recursion is about 1000 layers for most systems.

    Happy to help you, nice try! 😁

  • Custom User Avatar

    Thx snoopythekid! Glad you liked it! This is an old debate; I simply used acquired knowledge.

    For a comparatively large list, under time constraints, it seems that the reversed() function performs faster than the slicing method. This is because reversed() just returns an iterator that iterates the original list in reverse order, without copying anything whereas slicing creates an entirely new list, copying every element from the original list. For a list with 10^6 Values, the reversed() performs almost 20,000 better than the slicing method. If there is a need to store the reverse copy of data then slicing can be used but if one only wants to iterate the list in reverse manner, reversed() is definitely the better option.

  • Custom User Avatar
  • Custom User Avatar

    Got it, you're right! Thx! 🙏🏻

    However, test cases do not test Unicode, only ASCII.

    "Never do that!" sounds extreme. The intention of Kumite is to challenge and not repeat past solutions.

    This was to similar to the previous 🤷🏻

        public static int SameCase(char a, char b)
        {
            if (!char.IsLetter(a) || !char.IsLetter(b)) return -1;
            return char.ToUpper(a) == char.ToUpper(b) ? 1 : 0;
        }
    
  • Custom User Avatar

    TRUE! I've seen it on a map. 🔭😏

  • Custom User Avatar

    I don't get it! What's wrong with the code? 🤔

  • Custom User Avatar
  • Custom User Avatar

    Hello! I made this translation 2 months ago and I guess it should be approved by an administrator or the author of the Kata.

    • Can anybody help me?
    • Who should review this translation?

    Thanks in advance

  • Custom User Avatar

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