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.
Just as I clicked submit, I envivisioned (as I usually do) what the one line solution would look like and just as I thought of abs(), here it is. Dammit.
Poor guy, lol
I submitted the solution above and one slightly refactored variation 9 years ago. I definitely did not copy from StackOverflow and I claim my solution original. I have no idea how a number of people came up with the exact solution of mine. Note that you can see other solutions once you solved a kata. Interestingly many of the accounts above where suspended.
I mean runtime because of an additional function call.
solutions were copy pasted from the internet (stackoverflow) probably.
What do you mean by expensive? As in it takes a lot of system resources compared to over operations?
-0 == 0 == +0, try it in the interpreter
Nice!
Just stop.
This comment has been reported as abusive
wow!
How to do formatting
It does not matter. Any modern C compiler can optimize abs(x) and x < 0 ? -x : x equally. gcc 12 compiles both into the exact same code sequence.
No expensive at all in the grand scheme of things. This is Python, it is slow to begin with.
expensive operation but clever answer!
Loading more items...