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.
Don't worry. There is only a little chance to come up with this yourself. Either you know it from somewhere or you don't.
I have been shamed
And a perfect example of ChatGPT answering the prompt correctly and you misreading it. He specifically wrote "I asked ChatGPT to explain this code ... and got exactly what he asked for.
is there a reason to not leaving a space? like why cramp them together instead of
return position + roll /* 2
why?
genius
.
7 lines is not bad. Honestly I'll defend my 4 line solution as being a better practice because it's more legible to other people, even if it isn't as clever as this one. And this one is clever! I'm not here to be a hater. I just get frustrated when people mistake "shortest" for "best." Imagine if one of your coworkers wrote this code, went on vacation, the code broke, and then you had to debug it. I don't think it would result in great professional cohesion.
Totally agree. I love when solutions are short and clever, and if I could FOR THE LIFE OF ME figure out what the heck is going on here, I might use it for personal things. But professionally, your code is going to be passed along to other people. It just is. Being a smirking know-it-all about how you're better at math than everyone else (which is not what I think the person who posted the solution is doing, but certain other people in the vicinity sure are!) is only going to make your coworkers hate you and the work more cumbersome. If the micromilliseconds that a solution like this shaves off actually matter, then that will be part of the stated requirements. Otherwise, it's counterproductive to do something confusing.
Imagine this: you write some indecipherable code and then go on vacation. Something else in the project changes, causing your code to no longer work*, but no one except you understands what you wrote well enough to debug it. When you get back from vacation, they're not going to think you're a genius. They're going to think you're a jerk. (Which is to say nothing of the probability that you also won't understand it once you haven't looked at it in a while!)
* I find it really interesting how many people think that "shave off imperceptible amounts of time" is a omnipresent, implicit requirement, but "harden your code against foreseeable weak spots" is a low priority that can be handled later. When they also think that "make it legible to other people" is a low priority, I really have to wonder what it is we're actually even doing here.
(All that said, the solution is, best I can tell, really clever! There's nothing wrong with someone having created or posted it - the opposite of wrong, that's fantastic! I am about to spend a lot of time on google and probably learn something! It's amazing how the human mind can weave different concepts and understandings together to come up with something really elegant! For the actual purpose of this website - practice - this is a great answer. But you are completely correct that it would not be best practice in a professional setting, and it makes me nuts when people just say "well maybe other people should just know all the things I know!" rather than engaging with practical limitations and basic interpersonal realities.
geniuses admire simplicity
Bro cooked
cool! took me a while to understand tho
genius
Oh I should have thought of this.
My inner math teacher is screaming.
Well played.
I see stuff like this and think that maybe this is not for me :*)
Loading more items...