Ad
  • Default User Avatar

    Got it. Thank you very much!

    Josh

  • Custom User Avatar

    Because there is a test with no argument and without it, it'll throw an error.

  • Default User Avatar

    I understand defaults (kindof). By why do we need a default (n=0) in this case?

    Thank you very much!

    Josh

  • Default User Avatar
  • Default User Avatar
  • Custom User Avatar

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

  • Default User Avatar

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

  • Custom User Avatar

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

  • Default User Avatar

    Didn't even think of using that function for this...

  • Default User Avatar

    So easy yet frustrating. Pissed. The fury of a thousand suns rains upon me

  • Default User Avatar

    Ok. I get what you mean. I didn't actually think about the fact that this explanation is basically the answer to the kata and other people would be able to read it too. I just went from the angle that he apparently solved it already and didn't really understand why the solution works. Just in that case it strikes me as rude to not give him an answer and instead refer him (not even to a specific website but) to a term that he'd have to look up himself. There is a reason why on SO the top voted answer never is 'Go look up "List Concatenation in for loops". Because it is not a good answer.

    I don't mean to make any enemies here. It just struck me as pretty rude when I saw it. Thanks for the spoiler flag, I guess that was necessary. Take care

  • Default User Avatar

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

  • Default User Avatar

    Probably what they did was to print out all of the validation cases to make sure they are within constraints.

  • Default User Avatar

    To anyone solving this puzzle after me:
    I started out as a noob on this platform not so long ago. Looking up the solutions of others and seeing how they rank is a good way to learn and I used that extensively. But sometimes, as in this case, the ratings are absolute bs. By delving more and more into coding I learned that 'concatenating' lists via addition when you could just extend one of them into the other is a major crime. Why? Complexity.
    Minimizing complexity is a fundamental pillar of writing code. When you 'add' lists like this, what happens is that Python creates a new empty list and then adds every single element of a and b into it, respectively. This boils down to len(a) + len(b) operations. Let's say your lists both contain 10 elements, then the number of operations is 20.
    It is far superior to use the built-in extend method of lists, i.e. a.extend(b). In that case, all elements of b get added to the list a which equates to len(b) operations for the same result. Again, if your lists both have 10 elements, now you only have to do 10 steps to have the new combined list. This matters hugely when confronted with larger input sizes.

    Nothing against the users who did it that way. After all, it's just a simple puzzle. Maybe they didn't know better or they just didn't care - either way the code gets the job done. That doesn't matter to me. What really upsets me is that this is the by far most upvoted 'Best Practices' solution, when in fact it's garbage. I just want to tell people who are inexperienced to not take 'Best Practices' as an indicator for an actual good solution.

  • Default User Avatar

    I'm sure I wrote it some years ago, so thank you ;-)

  • Loading more items...