GolfScript, (削除) 54 (削除ここまで) (削除) 53 (削除ここまで) 47 bytes
~:a;{256|{2base}:b~1>}%[]*a,b,/{b.{(a=}and}%""+
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:
256| # Bitwise or with 256 to set the ninth bit
{2base} # A block which calls `2 base` (convert to/from base 2).
:b # Assign the block to b
~ # and call it on the codepoint.
1> # Slice from index 1 to the end, removing the extra 9 bit.
}% # 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 taking a 1-based index:
(a= # Decrement and 0-based index into a.
} # This returns a number, so we have to coerce to string later.
and # If the number isn't zero, 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