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.
It is not great at all. It is basically the same as the top answers except it is poor from a readability perspective.
it's not only messy, it's overall bad practice and straight up doesn't work in some languages.
Am I the only one that finds this sort of one-line code unnecessarily messy?
Like, ok cool, it's in one line, but barely readable...
I think you should feel good. While this solution can beat down the given tests, if you gave it a large interval, it would never finish and use up all of your memory, even though there are ways to make it use very little memory and finish in an instant for arbitrarily large intervals.
it is not really clever, since you iterate over all values, and not just once over intevrals, like in by solution
It's a clean and short solution, that obviously should be considered clever, but as for me people who mark this algo as best practice misunderstand the meaning of these words.
so smart
Although I do agree it's quite "clever", is this really considered "Best Practice"?? O__o
As mentioned by others, something as trivial as "sum_of_intervals([[1,10000000000]])" would take ages to be calculated via this method (assuming it doesn't actually crash), whereas a more "standard" method would -obviously- instantly give the -obvious- result...
EDIT: Oh and note also that this would completely crash for "non-integer coefficients" such as sum_of_intervals([[0,1.5]]), whereas a more "standard" method would work just fine independently of the coefficients being integers or floats...
So "in Sum ( ;p )":
"Clever" ==> Certainly :)
"Best Practice" ==> I don't believe so :/
OMG! I speant all day on my long*&5 answer and this is so simple and clean! great work!
This will fail if test case have some like (-10000000, 1000000). Run to morning tomorrow =))
Thanks for making me feel stupid!
👏
This blew my mind!
wanted to write something like your solution, but got some strange results (half correct half not), so made another solution in the end.
Loading more items...