1
\$\begingroup\$

The input message consists of ASCII characters

The encoded output message consists of blocks of 0

A block is separated from another block by a space

Two consecutive blocks are used to produce a series of same value bits (only 1s or 0s):

After the ACSII character(s) have been converted to binary, go through the string:

If its a 1: add 0 0 *The last character multiplied by how many "1"s in the string consecutively after the first 1 found

Else If its a 0: add 00 0 *The last character multiplied by how many "0"s in the string consecutively after the first 0 found

Input:

The message consisting of N ASCII characters (without carriage return)

Output:

The encoded message

Example

Input

C

Output

0 0 00 0000 0 00

More details and a better explanation can be found here: https://github.com/GlenDC/Codingame/blob/master/descriptions/chuck_norris.md

Remember! This is code-golf, shortest code wins!

\$\endgroup\$
3
  • 3
    \$\begingroup\$ Welcome to Code Golf! According to the provided link, I think this should be processed as a continuous stream of bits, with exactly 7 bits per character (including leading 0's) and no separator between characters. This should be clarified within the challenge body. \$\endgroup\$
    – Arnauld
    Commented Dec 18, 2021 at 12:22
  • 7
    \$\begingroup\$ Are you the originator of this challenge? If not, you should ensure you have permission to post it here, and give proper credit to that person. \$\endgroup\$
    – Giuseppe
    Commented Dec 18, 2021 at 12:28
  • 1
    \$\begingroup\$ The description here is rather confusing. It seems like this is a run length encoding. But I had to read the linked explanation before I could figure that out. \$\endgroup\$
    – Wheat Wizard
    Commented Dec 18, 2021 at 13:34

0

Browse other questions tagged or ask your own question.