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

47 => 46
Source Link
noodle person
  • 12.6k
  • 1
  • 31
  • 90

GolfScript, (削除) 54 (削除ここまで) (削除) 53 (削除ここまで) 47(削除) 47 (削除ここまで) 46 bytes

~:a;{256|{2base}:b~1>}%[]*a%[]*\:a,b,/{b.{(a=}and}%""+

Try it online! Try it online!

~ # Evaluate the input
:a;  input; #the Storecodepoint thelist encoderis alphabeton (top of stack) as variablethe astack.
{ # 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 variable 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 # Swap and assign the second input, # the encoder alphabet, to variable 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 athe stringlist.

GolfScript, (削除) 54 (削除ここまで) (削除) 53 (削除ここまで) 47 bytes

~:a;{256|{2base}:b~1>}%[]*a,b,/{b.{(a=}and}%""+

Try it online!

~ # 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.

GolfScript, (削除) 54 (削除ここまで) (削除) 53 (削除ここまで) (削除) 47 (削除ここまで) 46 bytes

~{256|{2base}:b~1>}%[]*\:a,b,/{b.{(a=}and}%""+

Try it online!

~ # Evaluate the input; the codepoint list is on top of the stack.
{ # 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 variable 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 # Swap and assign the second input, # the encoder alphabet, to variable 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 the list.
53 => 47
Source Link
noodle person
  • 12.6k
  • 1
  • 31
  • 90

GolfScript, (削除) 54 (削除ここまで)(削除) 53 (削除ここまで) 5247 bytes

~:a;{256|{2base}:b~.,8\-[0]*\+b~1>}%[]*a,b,/{b.{(a=}and}%""+

Try it online! Try it online!

~ # 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.
 ., # Push the binary digit list and its length.
 1> 8\- # Subtract that lengthSlice from 8.
 [0]* # Push a list of that many zeroes.
 \+ index 1 #to Prependthe itend, toremoving the binaryextra codepoint9 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.

GolfScript, (削除) 53 (削除ここまで) 52 bytes

~:a;{{2base}:b~.,8\-[0]*\+}%[]*a,b,/{b.{(a=}and}%""+

Try it online!

~ # 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 binary digit list and its length.
  8\- # Subtract that length 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 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.

GolfScript, (削除) 54 (削除ここまで)(削除) 53 (削除ここまで) 47 bytes

~:a;{256|{2base}:b~1>}%[]*a,b,/{b.{(a=}and}%""+

Try it online!

~ # 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.
Add python syntax highlighting to highlight numbers
Source Link
noodle person
  • 12.6k
  • 1
  • 31
  • 90
~:a;{{2base}:b~.,8\-[0]*\+}%[]*a,b,/{b.{(a=}and}%""+
~:a;{{2base}:b~.,8\-[0]*\+}%[]*a,b,/{b.{(a=}and}%""+
~ # 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 taking a 1-based index
 (a= # Decrement and 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.
~ # 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 binary digit list and its length.
 8\- # Subtract that length 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 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.
~:a;{{2base}:b~.,8\-[0]*\+}%[]*a,b,/{b.{(a=}and}%""+
~ # 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 taking a 1-based index
 (a= # Decrement and 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.
~:a;{{2base}:b~.,8\-[0]*\+}%[]*a,b,/{b.{(a=}and}%""+
~ # 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 binary digit list and its length.
 8\- # Subtract that length 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 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.
53 => 52
Source Link
noodle person
  • 12.6k
  • 1
  • 31
  • 90
Loading
Explain
Source Link
noodle person
  • 12.6k
  • 1
  • 31
  • 90
Loading
Explain
Source Link
noodle person
  • 12.6k
  • 1
  • 31
  • 90
Loading
Source Link
noodle person
  • 12.6k
  • 1
  • 31
  • 90
Loading

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