Here's a profile of running this problem 10 million times with an if/if/if solution versus an if/elif/else solution:
if_if_if completed 10000000 iterations
Sum time: 5684.13ms
Mean time: 568.41ns
Standard deviation: 1684.53ns
if_elif_else completed 10000000 iterations
Sum time: 5685.18ms
Mean time: 568.52ns
Standard deviation: 1642.49ns
Even if it did, if you care about nanoseconds you shouldn't be choosing different flow control syntax in Python, you should be choosing a different language.
This comment is hidden because it contains spoiler information about the solution
good task, the level corresponds to 7 kyu and the description is sufficient, gj
I know this can be done with int. Still this is great one-liner.
💪
loved it.
fixed
Scala tests:
Approved!
Scala translation
No, it doesn't.
Here's a profile of running this problem 10 million times with an if/if/if solution versus an if/elif/else solution:
Even if it did, if you care about nanoseconds you shouldn't be choosing different flow control syntax in Python, you should be choosing a different language.
if elif else statement works faster than if if if
For learning/reminder this is a good solution.
Yeah I fell into that trap too.
Please check my Java translation
Post your non working code: https://docs.codewars.com/training/troubleshooting#post-discourse so we can check what was wrong with it.
match
returnsnull
when there is no match.Loading more items...