cool solution. wish i had a brain too
if anyone reading this can you tell what's the difference between [+-] and [+\-]?
The only thing wrong is that the minimum tick does not occur in corner-case messages where every word is a 'T' (-), since 'T T T' --> '- - -' --> '11100000001110000000111'; but the tick (1 in this case) is recoverable.
I need emoji to show my reaction. !Facepalm
For all discussing performance over readability... Usually, the piece of highly optimized code is never read nor changed after it works. One may hide it somewhere in a helpers folder and you ain't gonna see it. So it depends on what you need.
Agreed. If there's an integer that's four digits long it would consider it a valid name. In my solution I added a try block to check that the string was not a four digit long integer.
When I run this code, I get a TypeError exception:bad operand type for abs(): 'generator'
Is this to do with Python 3+?
5 replace() calls + an initial regex pass makes this not that elegant, the solution should only need to iterate through bits twice at most
It's curious how 14 people all have this exact same solution, down to the whitespace and the wording of the comments.
what about integers?
This is exactly what I had in mind but you made it look a lot better than I did with my 2 months of coding experience...