Ad
  • Default User Avatar

    No, this works with all the numbers! Just think about it a lot

  • Default User Avatar

    Very interesting solution. I like it

  • Custom User Avatar
  • Custom User Avatar

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

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

  • Custom User Avatar

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

  • Default User Avatar

    That´s quite a workaroud. Liked it. Very creative.

  • Custom User Avatar