05AB1E, 2 (or 3) bytes
C∍ Outputs a mixture of 1s and 0s (depending onSince outputting the input) for its unary output.
Try it online or verify all test cases.
Ifas a single distinct character for the unary output is mandatoryrequired, it's 1 byte longer with multiple optionsthere are a couple of 3 bytes alternatives:
- Output as spaces:
Cð×- Try it online or verify all test cases; - Output as 1s:
$C×- Try it online or verify all test cases; - Output as 0s:
ÎC×- Try it online or verify all test cases; - Output as any digit (outputs asas a list of characters):
CÅ9(where the9could be any other digit) - Try it online or verify all test cases;.
If a mixture of multiple characters for the unary output would have been allowed, since only the length matters in unary, it could have been 2 bytes with:
C∍ Outputs a mixture of 1s and 0s (depending on the input) for its unary output.
Try it online or verify all test cases.
C # Convert the (implicit) input binary-string to a base-10 integer ∍ # Extend/shorten the (implicit) binary-string to that length # (after which the result is output implicitly) C # Convert the (implicit) input binary-string to a base-10 integer ð× # Pop and push a string with that many spaces # (after which the result is output implicitly) $ # Push 1 and the input binary-stringC× Î # Or alternatively, push 0 and the input binary-string C # Convert the binary-string to a base-10 integer × # Repeat the 1 or 0 that many times as string # (after which the result is output implicitly) C # Convert the (implicit) input binary-string to a base-10 integer Å9 # Pop and push a list with that many 9s (or any other digit) # (after which the result is output implicitly) C # Convert the (implicit) input binary-string to a base-10 integer ∍ # Extend/shorten the (implicit) input binary-string to that length # (after which the result is output implicitly)