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.
I think this version is clever, but it strikes me that all four operations are completed to fill the dictionary before the key is checked, which doesn't seem very performant. A version that checks the value of 'operator' using either if-then or match-case and only then does the required calculation would seem to be more optimal.
It still throws an error on the kata running python 3.11, and in my IDE (also running python 3.11). I checked in idle, and it throws the division by 0 error there as well, so I wonder what's different about your setup that it doesn't throw this error.
This comment is hidden because it contains spoiler information about the solution
looks like something has changed. the OP code runs fine in idle. add works fine. it throws divide by 0 error only on divide.
what does that mean?
Is is amazing I wouldn't have thought of that.
I did the same thing. However I am not sure if its faster than the hardcoded solution
very clever!
This comment is hidden because it contains spoiler information about the solution
Every thing that is hard coded or using simple functions should be faster
No, it's not. In fact, over a high number of invocations of the function, it probably actually be slower (allocation + hashing + lookup vs string comparison) The point of this isn't performance, it's convenience.
This looks very nice. But could anyone tell if this is really faster than the mundane if else control flow method?
Thanks.
Smart!
I love you
This is so smart
Loading more items...