GolfScript, 53 bytes
~:a;{{2base}:b~.,8\-[0]*\+}%[]*a,b,/{b.{(a=}""if}%""+
This is my second GolfScript submission, so I might be able to improve it. I haven't decided on the best way to write explanations for these so this time I'll leave a commented version:
~ # Evaluate the input
:a; # Store the encoder alphabet (top of stack) as variable a
{ # Open a block (like anonymous function) to run on each codepoint:
{2base} # A block which calls `2 base` (convert to/from base 2).
:b # Assign the block to b
~ # and call it on the codepoint.
., # Push the length of the binary digit list.
8\- # Subtract it from 8.
[0]* # Push a list of that many zeroes.
\+ # Prepend it to the binary codepoint.
}% # Close this block and call it on each codepoint (map).
[]* # Flatten the list by joining it on nothing.
a, # Push the length of a.
b # Convert it to binary.
, # The length of the digit list.
/ # Split the codepoint list into chunks of this size.
{ # Open a block to run on each chunk:
b. # Convert the chunk from binary to decimal.
{ # A block that takes a 1-based index
(a= # decrements and indexes into a.
} # This returns a number, so we have to coerce to string later.
"" # The empty string.
if # If the number is zero, return the empty string,
# and otherwise run the block.
}% # Run this block on each chunk (map).
""+ # Append an empty string to coerce to a string.
noodle person
- 12.6k
- 1
- 31
- 90