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 Revisions

2 of 9
deleted 80 characters in body
Dom Hastings
  • 24.6k
  • 4
  • 58
  • 94

Perl 5, 92 bytes

91 bytes code + 1 for -p.

This will probably only work on *nix machines and also relies on the details in this meta post for empty input (which TIO doesn't support, so a newline is provided - and never used).

${$_=qq{Lg\LLL$*= w$*RLD=}&qq=y}\LLL$*L _$*RLDA=}=${$*=`\LPRINTF \\\\X$_`}=$A{y?0?F?}=$_=$=

Try it online!

###Explanation

The basis for this script is utilising the & operator on strings, I was able to get Hell0, W0rld! just using:

$_=qq{Lg\LLL0= w0RLD=}&qq=y}\LLL0L _0RLDA=
# qq{} is a a synonym for ""
# \L converts the remainder of the string to lowercase
# I found these chars lazily by brute forcing all combinations and grepping for the desired char

Getting the o was a little more tricky however. Fortunately, the hex char code for o is 6F and $= is pre-initialised to 60, knowing this meant I could utilise the y{}{} operator to change 0 to F with some trickery:

$_=$=; # $_ is now 60 both valid variable names!
y?0?F?; # y (alias for tr///, you can use any delimiter) works on $_ by default, $_ is now 6F
$*=`\LPRINTF \\\\X$_`; # $* is now o
# I used $* instead of $A or something so I don't need to do ${A} when it's followed by another letter, a warning is displayed in the console, but these are ignored by default.

Chaining this all up without ; or , was a little tricky as well, but I was able to chain assign to variables and hashes in the reverse order of how I needed things to happen, which gives the desired result.

This was a lot of fun and I've been tinkering on and off for about a day. Great idea for a challenge!

Dom Hastings
  • 24.6k
  • 4
  • 58
  • 94

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