Calculate the binary split sum of a word Take a string, s containing printable ASCII-characters as input, and output its "binary split sum". Need an explanation?

How do you get the binary split sum?

We'll use the string A4 as an example in the following explanation.


Convert the characters to binary, treating each letters as a 7-bit ASCII character

A -&gt; ASCII 65 -&gt; 1000001
4 -&gt; ASCII 52 -&gt; 0110100

Concatenate the binary numbers into a new binary number

A4 -&gt; 1000001 &amp; 0110100 -&gt; 10000010110100

Split the new binary number into chunks, where no 1 can have a 0 to its left. You should not split consecutive 1s.

10000010110100 -&gt; 100000, 10, 110, 100

Convert these binary numbers to decimal

100000, 10, 110, 100 -&gt; 32, 2, 6, 4

Take the sum of these numbers:

32 + 2 + 6 + 4 = 44



So, the output for the string A4 should be 44.



Test cases:

a
49

A4
44

codegolf
570

Hello, World!
795
Python 2, 86 81 76 bytes

-5 bytes thanks Adnan
-5 bytes thanks xnor


s=0
for c in input():s=s*128+ord(c)
print eval(bin(s).replace('01','0+0b1'))


Try it online!

for c in input():s=s*128+ord(c) to do the ASCII conversion numerically, where *128 is used to left shift s 7 times (steps 1 and 2)
eval(('0'+new_bin).replace('01','0+0b1')) to split and sum (steps 3, 4 and 5)