Given an input string of one or more ASCII characters which codepoints are between 0 and 128 (exclusive), do the following:
- Convert each character into its 7-bit ASCII code (if the ASCII code is less than 7 bits, put leading zero bits)
- Concatenate all bits (this results in
nis the number of characters)
- For each bit in this bitstream, print 1 if it is different from the previous bit, and print 0 otherwise. The first output bit is always 1.
The string "Hi" has the ASCII codes
which in bits are:
And the transition bits indicators:
This is code golf. Lowest byte count wins.
Test case 1:
Hello World! 110110010101110011010101101010110001110000111110000110000001011101101010101100110001
Test case 2:
%% COMMENT %% 1110111111011111100001100010010100001010110101011010011101010011111110011000001101111110111
Test case 3 (credit to Luis Mendo):
Congrats to Luis Mendo for the shortest solution with 9 bytes in MATL!