Ad
  • Default User Avatar

    Both patterns are valid cases of identifiers in Python or C++.
    https://www.w3schools.com/python/gloss_python_variable_names.asp
    https://www.w3schools.com/cpp/cpp_variables_identifiers.asp

    It is ok for the problem to choose to make a pattern be valid or choose to explicitly make something out of scope.....

    I tested some of the other already accepted solutions. When I tested, they would return different results for the ambigious cases. I would advocate updating the decription to say these patterns are out of scope. That would remove the ambiguity and leave accepted solutions intact.

  • Custom User Avatar

    None of those cases you mentioned are tested because they aren't valid. Unless some translation has them, please, mention which language you're talking about.

  • Default User Avatar

    I felt the problem description was ambgious on some inputs. I see that for different accepted answers which I tested locally, the accepted answers return different output when given the below ambigous input.
    It would improve the problem if the specification had a single well defined output for all valid inputs and the test cases should cover them.

    1. how are leading and trailing delimeters to be handled? "__ aaa_bbb __"
    2. how are repeated delimeters to be handled? What is the expected output of "aaa____bbbb"
  • Default User Avatar

    well since you must have a way to determine the start and the end of each word, you usually use the String.Split Method anyway to split on the whitespaces. That method returns an array of strings, so you can access every word seperated. Since every string is a CharArray in c#, you can then access an index of each word. That should solve your problems

  • Default User Avatar

    Yeah I had a problem with that

  • Custom User Avatar

    Not anymore. Thanks for reporting it.

  • Default User Avatar

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

  • Default User Avatar

    if you've spent 30mins trying to figure out why your code isn't working (like me) while everything seems ok, check for not adding any null characters!!(if you did it in a similar way i did)

  • Default User Avatar

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