7 kyu

A Letter's Best Friend

2,454 of 3,827saudiGuy
Description
Loading description...
Fundamentals
Strings
  • Please sign in or sign up to leave a comment.
  • Fex329 Avatar

    I think that it should be clearly stated that an empty string should return true. If x is not present it cannot be followed by y, there fore is cannot be true

  • PetitLu117 Avatar

    Lua translation ! Can someone review it pls ? Thanks

  • stellartux Avatar
  • trashy_incel Avatar
  • Obluchatel 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.

  • ACodingHobby 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.

  • rowcased Avatar

    It is possible for an incorrect solution to intermittently pass the kata on the chance of a test run where no random tests are produced that have a == b and neither a nor b appear in txt.

    JavaScript passes fairly often
    Python rarely passes
    TypeScript passes every time

    (not tested for other languages)

  • allprod Avatar

    This kata has an issue. the test cases are wron so valid responses always mark wrong. it is impossible to complete in python

  • JohanWiltink Avatar

    Haskell translation

    this translation modifies the description

    the current description has the logic backwards, and does not actually specify what is being tested. if I weren't suggesting a fixed description with this translation, I'd actually have raised this as an Issue.

    the proposed description also makes more explicit that characters are not necessarily in the string, though it still doesn't fully spell it out, and I expect people are still going to be stumped by that. they can go find "vacuous truth" in the comments ( it's in there now four times ).

  • o2001 Avatar
  • o2001 Avatar
  • hannachung01 Avatar

    Why do your random test cases say that it should return True if the letter never appears in the first place? (I would have intuitively thought that in such a case, the function should return false.) The problem description doesn't explain what we should do when a letter never appears.

  • luizfelipers19 Avatar

    It really is a funny problem to try to solve, but the descrition should mention the desired behaviour to the "random inputs" when it is tested against inputs that are not inside the given sentence

  • NxBlaze Avatar

    Description should mention what should be returned if txt doesn't contain a or either of the letters. Some solutions can pass all the basic tests but fail on radom ones when a is not present.

  • KATA.exe Avatar

    Definetly not an 8kyu, but funny to solve :)

  • Nikolai_spb Avatar

    This comment has been hidden.

  • KayleighWasTaken Avatar
  • KayleighWasTaken Avatar
  • Discordanian Avatar

    This comment has been hidden.

  • mvrlxc Avatar

    This comment has been hidden.

  • asbeforee Avatar

    this is very educative kata i think but it would be nice if i could solve it

  • Ruben Centeno Roman Avatar

    I personally would rewrite it to something down the lines of: "Everytime the first letter appears in the string, the second letter has to come alongside it. If not, then return 'False'."

  • armM00 Avatar

    The worst piece of trash I ever solved on Kata. It's a shame CodeWars that you allow garbage like this to be published! Delete it!

  • monadius Avatar

    There should be tests where the first letter appears at the end of a string. For example:

    ("a test", "t", "e")
    

    Some solutions return True for this test case. But the expected result is False.

  • aNDREWporgrammer Avatar

    i used 11 strings to solve it, and the random guy it in 1, uhhh

  • ejini战神 Avatar

    For the record, this is not 8kyu and should be sent back to beta if possible...

  • Mednoob Avatar

    Add a condition where a and b is the same letter and put on the end of string.

    Example:

    txt = "abcdee", a = "e", b = "e" -> False
    txt = "abcde", a = "e", b = "e" -> False

  • Voile Avatar

    The description is unneccessarily convoluted. It really just means "if a given letter always appears immediately before another given letter in a word" (therefore whitespace is a boundary).