Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
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.
Not sure if it was on purpose, but I believe making "L" a list is less efficient than making it a string.
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.
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.
It should output
False
because "nodwvdwdddw nmldw bdwi fobdwodw vdwfdww ldwudwjsdwm" - the string contains bothdd
anddw
, which meansd
'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 thetxt
string? what isa
? what isb
? 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 outputtedFalse
, but that you outputtedTrue
when it expectedFalse
.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.
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.
Got it! Thanks.
This comment is hidden because it contains spoiler information about the solution