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's also a game/challenge, and these are all good opportunities to learn different methods to do things. And in a production environment might not have the option to change language but can still make the code run faster where and how we can.
Ok, but this kumite uses python in tests and I'm too lazy to write a translation to C.
If I was worrying about the cost of operations like division, I wouldn't be using Python.
If you know what format the temperature is coming in already, you can just check it against the type to convert to. There is no such thing as
"both"
. It is one or the other. Whenever you use both, the calculation for the same type of temperature will always be wrong (input fahrenheit, convert with"both"
, output fahrenheit will be different because it was treated as celcius).EDIT: Ok, I see - it is tested upon and expected to work that way. Still a dumb idea. One will always be wrong, why bother.
I'm with you, this wasn't useful.
It's good, but it won't work properly if you changed
temp
in an instance. Maybe it should be immutable, you could use a frozen dataclass.Division is a slow operation, it's a way to reduce its usage.
You are right. I couldn't think of a way to make the previous any faster or more concise :-(
This function does a lot of unnecessary calculations including division. If you have to do one conversion - do exactly one instead of 2.
why would you just post the exact previous kumite? you have done not one new thing with the code