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.
This comment is hidden because it contains spoiler information about the solution
That's even shorter than the best of
Best Practices
! Neat!duplicate issue above
That's an implementation detail I was relying on. Since that string's reference counter is 1, the add-assign operator could try to add to the existing string (while the add operator cannot do that, as the assignment comes later).
Well, it used to be more efficient.
I just did a
timeit.timeit
on Python 3.8.5 (on very long strings, a billion characters), and the add first then assign version was same for short strings, about twice as fast for longer strings. Which is the opposite of what I expected.Maybe I did my previous tests on Python 2.7, quite possible. Interesting, I never thought that part would change. Or my tests back then were wrong (I was still relatively new to Python).
(My own solution does use a generator expression instead of a list, but pretty much agree on the overall design)
result += "0" still creates a new string.
Strings in Python are immutable. You can't change them.
If you change the, you will always create a new string - doesn't matter what operator you use.
Use lists if you want to avoid recreating strings for each iteration.
See my solution if needed.
This comment is hidden because it contains spoiler information about the solution
Not sure what you mean, if 111 represents a dot rather than dash, how do you explain the seven zeroes?
No. According to the problem statement there needs to be at least one zero between each encoded dot and dash in the bit string. So '1110001110000000111' should be decoded as '...' because the number of bit samples for a dot seems to 3 so this bit string should be decoded as 'S'.
Insufficient tests, obviously, this code should not pass. Fails on
d01(0, 0)
and ond01(1, 3)
, for example.Oh, if I were more attentive, it would save me a lot of time:)
Read the Note in the description, such test case is not allowed:
Incorrect result for find([4, 6, 3, 5, 2]). Expected 1 or 7, but actual result is 4
Nice
Thanks.
Congratulations My Friend For the First Kata .... Waiting For Mooooooooooooooore ... Challanging Yet easy to translate hahhahahaha ... wish you the best bro ..
Loading more items...