Perl 5 <= 5.18.2, 86 bytes
85 bytes code + 1 for -p.
This uses a feature that has been deprecated, but works locally in my terminal (which is version 5.18.2 as noted). In older versions of Perl ?0? is a synonym for /0/ which means I can extract the 6 from $= by matching against 0 and using $` to access the preceding string (6). I've also added more of the string into the call to the shell's printf to make the match shorter as well. &ing with \xFF still yields the desired character (o), but I'm sure there must be a way to get that shorter... I need to remove some of those slashes, it's insane!
${$_=?0?&&qq{Lg\LLL\xFF= w\xFFRLD=}&qx=\LPRINTF y}LL\\\\x$`FL\\ _\\\\x$`FRLDA=}=$_=$=
Try it online! (Note: the version of Perl is too new on TIO, so the call to ?0? has been replaced with /0/.)
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?}=$_=$=
###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!
- 24.6k
- 4
- 58
- 94