Skip to main content
added 255 characters in body
Source Link
Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394

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:

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) 

05AB1E, 2 (or 3) bytes

C∍ 

Outputs a mixture of 1s and 0s (depending on the input) for its unary output.

Try it online or verify all test cases.

If a single distinct character for the unary output is mandatory, it's 1 byte longer with multiple options:

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) 

05AB1E, 3 bytes

Since outputting the unary as a single character is required, there are a couple of 3 bytes alternatives:

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 ð× # 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) 
Source Link
Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394

05AB1E, 2 (or 3) bytes

C∍ 

Outputs a mixture of 1s and 0s (depending on the input) for its unary output.

Try it online or verify all test cases.

If a single distinct character for the unary output is mandatory, it's 1 byte longer with multiple options:

Explanation:

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)