Ad
  • Custom User Avatar

    It was likely intentional. Appending to a list is O(1), so they create the string only once at the end using 'join'. However, concatenating two strings creates a new string each time, which can be a costly operation.

  • Custom User Avatar

    Not sure if it was on purpose, but I believe making "L" a list is less efficient than making it a string.

  • Custom User Avatar

    Vacuous Truth. Since there is no 'x', then there is no instance of 'x' followed by anything other than 'y', therefore the condition still holds. Generally, most Katas assume a vacuous truth.

  • Custom User Avatar

    assertTrue(Kata.bestFriend("", 'x', 'y'), "for input: "", 'x', 'y'");

    How this is returning True? in that case String txt is empty and there are no chars "x" followed by "y". Thus it should be False.
    Explanation:
    Since we are checking if "x" is followed by "y", if there is no "x", it can't return True.

  • Custom User Avatar

    It should output False because "nodwvdwdddw nmldw bdwi fobdwodw vdwfdww ldwudwjsdwm" - the string contains both dd and dw, which means d's best friend is inconsistent. I think in the later part of the comment you're referencing random tests - since these tests are generated randomly and not pre-programmed, it's important you provide as much information as you can when reporting them (what is the txt string? what is a? what is b? what leads you to believe it is blatantly wrong?). Lastly, based on your first sentence, please ensure that you're reading the error logs correctly - your_answer should equal expected_answer should be read in that order for Python. So the program is not telling you that you outputted False, but that you outputted True when it expected False.

  • Custom User Avatar

    test case that checked "nodwvdwddw nmldw bdwi fobdwodw vdwfdww ldwudwjsdwm" said the program outputed False, however when checking with my own IDE it ouputs True. In additon, I found another test case which was blatanly wrong where one "e" was not followed by "y" always.

  • Custom User Avatar

    I'm having the same problem, perhaps you could make a specific statement that checks if it is this string and return false? But for real, not sure why this is happening.

  • Custom User Avatar

    Got it! Thanks.

  • Custom User Avatar

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