Ad
  • Default User Avatar

    i have similar problem on python

  • Custom User Avatar

    so I have to try to figure out how to avoid all best practices and intentionally mutate something outside the function? this is not a lesson one should bother learning

  • Default User Avatar

    If you obtain all words from "", you will have an empty list, "" is not included.
    Otherwise, the most frequent word in any string would be "" (or would you suddenly change your logic for that? be consistent.)
    Looking through Haskell solutions, every single one includes a literal empty-list literal because that is nowhere to be found in the input itself.

    It isn't possible to return the maximum word out of zero words. This is undefined. Don't test for it.

    Attempting to obtain the maximum word out of no words is a bug.

    This is some kind of javaism of pretending null is acceptable. It's not. Not in java either.

    At most I would accept that, yes, the input is valid, but the output is undefined, so any response, including crashing, is valid.
    (But I'd rather stick to that if the input has no defined output then the input is therefore not valid, it's wrong to expect a result for it)

    What is the average word length of ""?
    If there's a word in that, how many words are there then in "tree"? 1? 2? infinite?

    Or are we going for that words are separated by space, that the number of words in a string is the number of spaces plus one? ie that " " is two words and

    "  "
    

    is three words

    But now we run into the issue of not being able to represent an empty string, because there's always at least one word in it. It's like removing 0 from our counting system.
    Adding a word to "" now means that there are two words, and that it has to have a leading space: "" + "tree" -> " tree", or rather, it doesn't have a leading space at all because there's a word first which takes zero space (should we really recognize something that takes zero space as counting as a word? I think that sounds wrong. If something takes zero space then it is not there)

    Also, if I slice an empty string, and don't include anything, then just the same I would have a word in my result.

  • Custom User Avatar

    No, you're right it's not obvious. I tried to defend this point of view because it's not explicitely stated in the rules that you must have at least one word, but it's definitely not obvious.

  • Custom User Avatar

    was in javascript. I don't necessarily agree that it is obvious the best scoring word is '', since there is no word so an argument could be made for null or an empty array or etc, and I perhaps think the statement that all inputs are valid tends to imply there will be inputs (which, technically there are, with spaces, so I do see your point there as well as mine). Typically, I see katas that have something in the instructions about "if there is no answer: return 'something'" but there's no reason an instruction like that has to be in there, I suppose, so I certainly can see it your way as well. Anyhow, enjoyed the challenge, thanks for a good kata

  • Custom User Avatar

    1 - Which language? Most don't check that case, but the answer is that you should obviously answer the best scoring word, which is ""
    2 - The description says All inputs are valid, namely a string containing only spaces and lowercase letters. There is no explicit specification on the number of words, so "", " " and such are edge cases, not invalid inputs (It indeed contains only spaces and letters)

  • Custom User Avatar

    it says all inputs are valid but I'm failing tests where x is blank. This means I SHOULD have been checking if inputs were valid after all. Also, this means it doesn't tell me what it wants returned in the case of invalid inputs, so I'm just going to have to guess what will make it pass.

  • Custom User Avatar

    Codewars Forums - Kata Best Practices - Follow Conventions

    JavaScript Version: Identifier names (i.e. variable/function names) should always be in camelCase (except for constructors, but that is something else entirely) and not snake_case (source: W3Schools) - please change the name of the user function from clean_string to cleanString.

  • Custom User Avatar

    ah, sorry, didn't realize these discussion pages weren't language-specific. I'm doing it in javascript.

    and yeah, I'd love to see what argument was actually glitching it. I take it there's no way on here to see what random ones it selects?

  • Custom User Avatar

    It would help if you mentioned which language has this problem.

    It would also help if you could determine what the actual argument was that's giving you trouble - but the problem might be in the generating of the random argument or the processing of it; in the first case you'll never getit of course.

  • Custom User Avatar

    (JS) Test.assertEquals(actual,expected), not the other way around. I'd edit it for you, but I can't.

  • Custom User Avatar

    my code passes all sample tests, and passes all fixed tests on hitting "attempt", but my attempts still fail because it times out after that. I'm guessing something in one of the random tests is causing it to loop infinitely, I guess? I don't want to get into spoilers, but the only thing I could think of that might cause a loop was a random string starting with too many # symbols before it got to letters. I wrote several different possible lines to account for that, though, and none of them prevent the timeout. not sure where to go from there, since I can't see what test is causing the problem?