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 -> ASCII 65 -> 1000001 4 -> ASCII 52 -> 0110100
Concatenate the binary numbers into a new binary number
A4 -> 1000001 & 0110100 -> 10000010110100
Split the new binary number into chunks, where no
1
can have a0
to its left. You should not split consecutive1
s.10000010110100 -> 100000, 10, 110, 100
Convert these binary numbers to decimal
100000, 10, 110, 100 -> 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
8372
actually. \$\endgroup\$