Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Finally a consolation.
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?
@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.
That's right. People are fucking idiots. Code should be short AND understandable, not just short.
had to find the explanation of the code
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
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
enought internet for today.
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.
This comment is hidden because it contains spoiler information about the solution
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