Ad
  • Custom User Avatar

    I'm going to be very blunt because I'm growing very sick of comments like these. If this solution is bad practice or hardcore to you, then you shouldn't be doing Python. Plain and simple. There are many scenarios where one liners are bad, and this is not one of them. Under most style guides, this is the way to solve this problem. This is how it is done in production. Your solution has poor performance and looks like spaghetti - the gall to try and knock on the doors of better solutions talking about "not smart, but abstruse and overcomplicated." It is not the job of others to use simple language constructs to appease you. Look inwards and try to explore the language better.

  • Custom User Avatar

    Some people like to write one-liners as a challenge, not everyone is setting out to write perfectly readable enterprise-level code. It's not their fault other people upvote them. Let people have their fun without the lecture.

    Not to mention, as far as python goes, this really isn't unreadable, it's pretty clear what this does.

  • Custom User Avatar

    Buddy, what is the overcomplication of this solution? Everything is simple and clear

  • Custom User Avatar

    Thank you for the helpful advice. This will be very useful for me in the following exercises.

  • Custom User Avatar
  • Custom User Avatar

    My code passed "TEST" but failed "ATTEMPT". Some of the tests in "ATTEMPT" returned an error:

    {'pos': [2, 5, 8], 'peaks': [20, 12, 20]} should equal {'pos': [2, 5, 8, 11], 'peaks': [20, 12, 20, 12]}

    The problem is that in "ATTEMPT", the error messages do not contain the input data. Which makes it very difficult to understand what exactly is not working correctly in my code. Please improve the error message in "ATTEMPT". So that the student can see exactly which input data was passed to the code.

  • Custom User Avatar

    A good solution is to insert letters from the alphabet. It's easier than messing with sorting and other stuff. A simple and effective solution.👍

  • Custom User Avatar

    Writing everything in one line is a bad practice. It's just bragging about its tricky hardcore solution. It's too bad that many people called this solution "best practice" and "clever". This is a bad practice. And the solution is not smart, but abstruse and overcomplicated.

    The solution from fortlasagna is much better. He generally does the same thing. But his code is much better structured and much better readable. Here he really shows the best practice.