Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

deleted 422 characters in body
Source Link
Giuseppe
  • 29.4k
  • 3
  • 33
  • 106

MATL, 917 bytes

&mB&m2Gt&mBwY)!8e!XB

Try it online!

Takes input as string, then encoderTry it online!

&m % 1-based index of first input in second
B % convert from decimal to binary. Produces a logical vector
! % transpose
8e % reshape into matrix of columns of length 8, padding end with zeros.
! % transpose
XB % convert from binary to decimal
 % (implicit) convert to string and display

Of note, B returns a matrix with the binary strings as rows, so they are automatically padded to the same length.

MATL, 9 bytes

&mB!8e!XB

Try it online!

Takes input as string, then encoder

&m % 1-based index of first input in second
B % convert from decimal to binary. Produces a logical vector
! % transpose
8e % reshape into matrix of columns of length 8, padding end with zeros.
! % transpose
XB % convert from binary to decimal
 % (implicit) convert to string and display

Of note, B returns a matrix with the binary strings as rows, so they are automatically padded to the same length.

MATL, 17 bytes

&m2Gt&mBwY)!8e!XB

Try it online!

Of note, B returns a matrix with the binary strings as rows, so they are automatically padded to the same length.

added 119 characters in body
Source Link
Giuseppe
  • 29.4k
  • 3
  • 33
  • 106

MATL, 9 bytes

&mB!8e!XB

Try it online!

Takes input as string, then encoder

&m % 1-based index of first input in second
B % convert from decimal to binary. Produces a logical vector
! % transpose
8e % reshape into matrix of columns of length 8, padding end with zeros.
! % transpose
XB % convert from binary to decimal
 % (implicit) convert to string and display

Of note, B returns a matrix with the binary strings as rows, so they are automatically padded to the same length.

MATL, 9 bytes

&mB!8e!XB

Try it online!

Takes input as string, then encoder

&m % 1-based index of first input in second
B % convert from decimal to binary. Produces a logical vector
! % transpose
8e % reshape into matrix of columns of length 8, padding end with zeros.
! % transpose
XB % convert from binary to decimal
 % (implicit) convert to string and display

MATL, 9 bytes

&mB!8e!XB

Try it online!

Takes input as string, then encoder

&m % 1-based index of first input in second
B % convert from decimal to binary. Produces a logical vector
! % transpose
8e % reshape into matrix of columns of length 8, padding end with zeros.
! % transpose
XB % convert from binary to decimal
 % (implicit) convert to string and display

Of note, B returns a matrix with the binary strings as rows, so they are automatically padded to the same length.

Source Link
Giuseppe
  • 29.4k
  • 3
  • 33
  • 106

MATL, 9 bytes

&mB!8e!XB

Try it online!

Takes input as string, then encoder

&m % 1-based index of first input in second
B % convert from decimal to binary. Produces a logical vector
! % transpose
8e % reshape into matrix of columns of length 8, padding end with zeros.
! % transpose
XB % convert from binary to decimal
 % (implicit) convert to string and display

AltStyle によって変換されたページ (->オリジナル) /