• Custom User Avatar
  • Custom User Avatar

    Solution so tiny I could tatoo it anywhere on my body. It wouldn't be readable when it's cold though.

  • Custom User Avatar

    There is a rule, "simple is better than complex".
    It's due to is more simple do code inside of def function
    rather than do a lambda function.

    But it's definetly very clever solution :)

  • Custom User Avatar

    fixed

  • Custom User Avatar

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

  • Custom User Avatar

    Now can you do it in one line WITHOUT recursion? :)

  • Custom User Avatar
  • Custom User Avatar

    No, on that line, a and b are not yet defined, so it barfs. Also: misses the point that constants are better than string concatenation.

  • Custom User Avatar

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

  • Custom User Avatar

    Arguing "intent" outside of kata description and tests is a fool's errand. Maybe the kata author believed one of the problems with the code was that it needlessly concatenated two constant strings? We have just as much evidence for that as anything else, which is to say: none.

    I solved the kata in this way to avoid concatenating constant strings. It's a waste of CPU, there's no compelling reason to accept that waste, no requirement asking me to, and no test that fails if I do things my way. So I did things my way.

    Anyone who says this code is "cheating" or "wrong" is barking up the wrong tree. An accepted solution is never wrong or cheating; it is the tests that are wrong. It is up to them to work with the kata author to improve the kata, or fork it and do it themselves. It is not a coder's responsibility to intuit beyond the requirements what the author "intented", and further, doing so is a fool's errand, more likely to be wrong than not.

    Finally, in general finding unintended solutions is a huge benefit to the Codewars community. It illustrates non-conventional thinking (which often results in better solutions, especially in the higher kyus) and forces kata authors to improve their katas and tests.

    While I understand if someone's cheating to get to their rank, that can feel like it diminishes the "value" of your rank, but:

    1. Finding non-conventional solutions is usually more work than finding conventional solutions.
    2. Finding non-conventional solutions provides a valuable service to the community.
    3. The actual cheaters have alt accounts that they use to view solutions and copy+paste the solutions into their "prime" account. They aren't finding edgecases and alt solutions.
    4. Like the points on Whose Line Is It Anyway? your rank already doesn't matter. Yes, your rank is like hair products in Colin Mochrie's apartment.
  • Custom User Avatar

    I'm curious as a beginner if your approach, which seems to ignore the intent (as the given code includes concatenation), is based on industry best practices, or simply to stick it to kata creators who write ambiguous instructions (or are these one in the same?)? Either way, it's fun to see solutions that think outside the box.

  • Custom User Avatar

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

  • Custom User Avatar

    it's classic oneliner.
    def is ugly, lambda is beautiful in oneliner

    zen of python, 1st line:
    Beautiful is better than ugly.

  • Custom User Avatar

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

  • Custom User Avatar

    In python, if the user redefines the Node class, the build_one_two_three function does not use the redefined Node. Rather it uses the orignal definition, and therefore causes unexpected behavior with the different types. (E.g. source is of type <class 'setup.Node'> and dest is of type <class 'solution.Node'>). If the user adds or changes methods, they will likely end up with a confusing error for those tests.