Ad
  • Custom User Avatar

    Finally a consolation.

  • Custom User Avatar

    [...] if this is something you should strive to be able to do in your own coding or not. and this is 100% a not.
    [...]
    If you ever want to work in a team, this is not the type of code that they will want to see.

    This is exactly the type of code I would like to see in my team's code repository. This code is O(n) time and O(1) space. Could you show me any other, more readable solution, with similar characteristics?
    What I would eventually add would be some comments explaining the algorithm, to account for newbies not really familiar with how binary operator work. But the alrgorithm itself is spot on for the stated problem. It does not waste time, it does not waste space, and XOR operation is one of the most basic ones, on par with arithmetic addition and logical OR.

    If you were to propose a more readable solution, would it be something using the same algorithm as this one? Or some other algorithm with similarly good performance characteristics? Or some totally inferior (performance wise) algorithm which would eat up significantly more memory and/or time?

  • Default User Avatar

    @vinceAggrippino

    There's no such thing as production code vs creative code. there's either good code or there's bad code. There's many ways to get code to do the same thing but there's often one solution that achieves all goals better than any other.I'm glad you learned how the bitwise XOR operator works, but you should also be knowing how to look at code and determine if this is something you should strive to be able to do in your own coding or not. and this is 100% a not.

    If you ever want to work in a team, this is not the type of code that they will want to see. and if your coworkers need to debug this code, it will take them a long time to figure out, just like it took you a long time to figure out. The difference is that programmers want a lot of $$ for their work and it will cost the company a lot to have a programmer scratching their head for 2 hours trying to figure out what you wrote. so to become a better programmer is also about learning how to write code in a readable way.

  • Custom User Avatar

    That's right. People are fucking idiots. Code should be short AND understandable, not just short.

  • Default User Avatar

    had to find the explanation of the code

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

  • Custom User Avatar

    I think I agree with u, I tried this solution and I couldnt even make it work, how I am susposed to know what this is about

  • Custom User Avatar

    enought internet for today.

  • Default User Avatar

    Everyone's posts are super positive, and they're amazed at his coding skills, but let's be honest the next developer is going to have a hell of a hard time understanding this code. even if it works besides for the function name I would have absolutely no clue what this code was accomplishing. I'll give you kudos for creativity but I'm not going to pretend like this is a great coding practice to write code like this. code is meant not just for running but also for reading.

  • Default User Avatar

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

  • Default User Avatar

    I find it kinda challenging to understand how the solution works. I wouldn't be happy if I saw that in my code base and needed to debug it