The title says it all; Given a number in the binary (base-2) number system, output the same number expressed in unary (base-1).
You may use any reasonable input and output format, i.e. stringsshould take the binary number as a string (optionally with a separator), list, or equivalent structure of characters / digits, etc. You can useusing any digitsnumber or digit you like to representfor the binary anddigits. The unary numbersoutput can use any aforementioned format, and it should use a single-digit throughout the number but does not have to be consistent for different input values. You may choose to assume that the binary number will have no more than 8 bits, and/or that it will always be left-padded with zeroeszero bits to a certain length.
One method you may use to achieve this task is documented at this esolangs.org article:
- Replace all
1s with0*(Using*as the unary digit; you may use any character.) - Replace all
*0s with0**. - Remove all
0s.
ExamplesHere are some examples, using 0 and 1 for the binary digits and * for the unary digit:
1001→*********1010→**********00111111→***************************************************************00000→ (empty output)
This is code-golf, so the shortest answer in each language wins.