Ad
  • Default User Avatar

    Dude , thanks for writing this comment. I'm more silly because I had in the instructions "If the score < 0, return 0" but still came here to check if something is wrong when I get -3

  • Custom User Avatar

    If the score < 0, return 0

  • Custom User Avatar

    Not once you've been answered.

  • Default User Avatar

    I'm stiupid XD omg thank you
    Can i delate my comments?

  • Custom User Avatar

    If the score < 0, return 0

  • Default User Avatar

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

  • Custom User Avatar

    If the score < 0, return 0

  • Default User Avatar

    I think some test cases are wrong.

    test.assert_equals(check_exam(["b", "c", "b", "a"], ["", "a", "a", "c"]), 0)

    it should equal -3 not 0.

    Tell me if i'm wrong

  • Default User Avatar

    Well, if your goal was to do it in one line, you definitely got it. I often try for one-line solutions, personally, even though those solutions usually aren't best practice.

    "Best practices" doesn't usually mean do the task in as little code as possible, it generally means do the task in a way that is easy for someone else to figure out what you're doing and also to make the code easy to maintain if you have to change it in the future. It's also a best practice to pay attention to performance, and you usually have to balance maintainability with performance.

    Your solution could be easier to read. You also end up doing the same work twice by generating the same exact list two separate times. You could just generate one list and pull both the max and min numbers out of it. Having to generate one list would also save you time in the future should you need to change this code. For example, if this were part of a larger project, and your team decided that this method would be passed a list of ints instead of a string, right now you've got two changes to make in your code, but if you'd done it the other way, you'd only have to make one change.

    I wouldn't put TOO much stock in the answers that are the highest upvoted for "best practices". People often upvote solutions that work, but are not "best practices", either because the solution was funny, or clever(even though there's a separate upvote for that), or the solution is very short, or any number of other reasons. I've seen incredibly inefficient code get the top spot for "best practices" before (like n^2 time complexity where an n or even a 1 time complexity could be achieved).

  • Default User Avatar

    I'm using Python

  • Custom User Avatar

    You'll have tell us which programming language you are using, or else we can't see your solution.

    Otherwise if you just want to see other peoples solutions to the kata, you can check the Solutions tab. There you will find all user submitted solutions and rate or comment on them.
    The most voted best practice and clever solutions will be listed at the top.

  • Default User Avatar

    Hello!
    I'm very new to programing but i want to learn as much as I can c:.
    It's my first time ever using list comprehension! Can someone more experienced tell if my answer is good practices?
    Or maybe i can improve something, read about usefull methods?

  • Default User Avatar

    I did some reading and thank you! I know understand that it is correct

  • Custom User Avatar
  • Custom User Avatar

    No, it doesn't, the reason is it returns either way, so only the first letter is checked.

  • Loading more items...