Ad
  • Custom User Avatar

    man, I'm speechless, what a clever solution

  • Custom User Avatar

    I mean, come on... look at my solution and how I sweat with it, and you just did a^b – it feels like cheating, haha ^^'

  • Custom User Avatar

    Gotta say, I don't really understand why this works the way it works intuitively, but people complaining that this isn't "best practice" or "uh muh readability", "maintainability", or "what about junior devs":

    This is a code exercise, not production code.
    Yes, in production you'd want better guard rails and input validation, and yes, you would want this documented to explain what it does. And yes, you'd need to validate that the ouput is sane since multiple odd occurances throws the math out the window lol (so maybe that would make this solution invalid for production as extra compute might outweigh the space benefits).

    However, as a general point you shouldn't sacrafice performance of something so simple with a very clear objective to write more convoluted looping code that will take a junior some time to parse anyway.

    If you know a clever way to do something that's performant, is little code, and achieves a clear focused objectives, you shouldn't dumb it down because someone might not get it. Let them figure it out, and learn, and make sure the rest of the codebase isn't impacted by someone not understanding a bit of code in it.

  • Custom User Avatar

    I'm shocked, never knew it could be done in 1 line! Very smart, kudos from me

  • Custom User Avatar

    Are you human? 🤣🤣🤣

  • Custom User Avatar

    Maybe I haven't understood the task correctly, but I still can't understand how this works 🤔

  • Custom User Avatar

    I apologize, I was pissed off about things that didn't even have to do with software or computers.

  • Custom User Avatar

    You are clever but those 95 are not.

    People that insult other people because their assessment/judgement is not aligned with their own, are people I would NEVER like to work with in a production environment.

  • Custom User Avatar

    So what? XOR is elementary logic. Using bitwise operators is normal e.g. in system or embedded programming. Not everyone is a frontend developer. Last but not least, this site is not about writing production code.

  • Custom User Avatar

    JS is used mostly for frontend where you have to deal with css, designs and high level of abstraction. I don't expect to find something like this. Frontend devs spend most of the time dealing with the dom, frameworks and sending/receinving data toward/from the backend. But fine, you can do it. In the end this is just an opinion of mine.

  • Custom User Avatar

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

  • Custom User Avatar

    It is not human readable, it is short and works and probably efficient but not easily understandable at first sight by people that usually don't need to use bitwise operators: 99,99% of js users. Clever but very bad practice.I am very curious to know the thoughts of the 95 individuals who clicked on 'best practice'. You are clever but those 95 are not.

  • Custom User Avatar

    it looks ridiculously short

  • Custom User Avatar

    Please use spoiler flag next time.

  • Custom User Avatar

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

  • Loading more items...