My solution which is the same as this failed one of the random tests the first time I submitted it. I have no idea why.
Hi guys,
When I run this code, I get a TypeError exception:bad operand type for abs(): 'generator' Is this to do with Python 3+?
I'm surpised this isn't the top result, it's the fastest solution I've found:
1.58 µs ± 13.9 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
vs the top solution (in best practices):
1.83 µs ± 23.9 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
This comment is hidden because it contains spoiler information about the solution
+1 for teaching me about pack!
This would crash if the logins is provided empty such as the following test case:
a = [[ "foo", "foo@foo.com" ], [ ] ] b = [ ] test.assert_equals(search_names(a), b) test.assert_equals(filter_used, True, 'Use filter function' )
What is the mathematical relation behind this ? Couldn't find any reference or theorem !
Thanks
isn't the list method unnecessary?
This deserves more best practices upvote. It is really better than the set solution, which does not handle duplicated characters.
It's a python 3 way. Python 3 filter returns iterator.
'in' is wrong in this case, you only want to check the last character. And yes, endswith should be faster, it only checks the end of the string ('in' will check the whole string).
This is an interesting approach. Is the endswith(var) method faster that stating: '_' in logins?
Loading collection data...
My solution which is the same as this failed one of the random tests the first time I submitted it. I have no idea why.
Hi guys,
When I run this code, I get a TypeError exception:bad operand type for abs(): 'generator'
Is this to do with Python 3+?
I'm surpised this isn't the top result, it's the fastest solution I've found:
1.58 µs ± 13.9 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
vs the top solution (in best practices):
1.83 µs ± 23.9 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
SPOILER FLAG!!! X(
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
+1 for teaching me about pack!
This would crash if the logins is provided empty such as the following test case:
a = [[ "foo", "foo@foo.com" ], [ ] ]
b = [ ]
test.assert_equals(search_names(a), b)
test.assert_equals(filter_used, True, 'Use filter function' )
What is the mathematical relation behind this ?
Couldn't find any reference or theorem !
Thanks
isn't the list method unnecessary?
This deserves more best practices upvote. It is really better than the set solution, which does not handle duplicated characters.
It's a python 3 way. Python 3 filter returns iterator.
'in' is wrong in this case, you only want to check the last character. And yes, endswith should be faster, it only checks the end of the string ('in' will check the whole string).
This is an interesting approach. Is the endswith(var) method
faster that stating: '_' in logins?
Loading more items...