Skip to content

Instantly share code, notes, and snippets.

@ParadoxV5
Last active October 31, 2023 22:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ParadoxV5/77cab0e2b47004712deba623fe5ea816 to your computer and use it in GitHub Desktop.
Save ParadoxV5/77cab0e2b47004712deba623fe5ea816 to your computer and use it in GitHub Desktop.
BOARD = {
nil => %q[SCARY?!],
'🎃' => %q[BDEFGH ],
'👻' => %q[IJKLMN'],
'🍬' => %q[OPQTUV,],
'💀' => %q[WXZ.#$:]
}
row = BOARD[nil]
File.foreach 'input.txt', chomp: true do|line|
line.each_char do|char|
row = BOARD.fetch(char) do # invoked if key not found
print row[char.to_i]
BOARD[nil]
end
end
puts
end
#!ruby -p
gsub(/(\D?)(\d)/){'SCARY?!🎃BDEFGH 👻IJKLMN\'🍬OPQTUV,💀WXZ.#$:'[/#$1.{#$2}(.)/,1]}
# Well whadday know, @UlyssesZh’s algorithm and `⛳1 bytes[3].rb`’s are the only ones that covers the entire original board.
# Though this one too can squeeze some extra chars by simplfying off the the unused chars:
# ``gsub(/(\D?)(\d)/){"SCARY?!🎃BDEFGH 👻IJKLMN'🍬OPQTUV,💀WXZ."[/#$1.{#$2}(.)/,1]}``
#!ruby -p
gsub(/(\D?)(\d)/){"WXZ.IJKLMN'__BDEFGH ____OPQTUV,_SCARY?!_"[$2.hex-($1+?^).ord%77/2]}
puts$<.read.gsub(/(\S??)(\d)/){'SCARY?!🎃BDEFGH 👻IJKLMN\'🍬OPQTUV,💀WXZ.#$:'[/#$1.{#$2}(.)/,1]}
# ``puts$<.read.gsub(/(\S??)(\d)/){"SCARY?!🎃BDEFGH 👻IJKLMN'🍬OPQTUV,💀WXZ."[/#$1.{#$2}(.)/,1]}``
puts$<.read.gsub(/(\S??)(\d)/){'BDEFGH OPQTUV,WXZ.#$:SCARY?!IJKLMN\''[$2.hex-($1+?👼).bytes[3]%6*7]}
puts$<.read.gsub(/(\S??)(\d)/){"WXZ.IJKLMN'__BDEFGH ____OPQTUV,_SCARY?!_"[$2.hex-($1+?^).ord%77/2]}
puts~/\d/&&"SCARY?!BDEFGH IJKLMN'OPQTUV,"[($`.bytes[3]||0)/3%6*7+$&.hex]while gets
# @sampersand’s originally-shared non-acrostic edition:
# ``print~/\d/?"SCARY?!BDEFGH IJKLMN'OPQTUV,"[($`.bytes[3]||0)/3%6*7+$&.hex]:" "while gets``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment