simply, 88 bytes
It's a long mess, but works!
(I've used \n
for style, but an actual newline works as well, and that is reflected in the size of the answer.)
fn($L){$T=" X\n"&array_map($L,fn($V)each$x in run&format("%'08s2"&cb($V,16,2))out$T[$x])}
Creates an anonymous function that outputs the result.
This works by left-padding all binary values to 8 characters, then ends with "2".
For each character of the binary string, it outputs the n character in the string " X\n"
.
For 0 outputs " "
, for 1 outputs "X"
and for 2 outputs "\n"
.
Example
$fn=fn($L){$T=" X
"&array_mapX\n"&array_map($L,fn($V)each$x in run&format("%'08s2"&cb($V,16,2))out$T[$x])};
run $F(["FF", "81", "47", "99"]);
Should output the expected result.
Slightly more readable
Both versions do exactly the same.
fn($list) => {
&array_map(
$list, fn($line) => {
$translation = " X\n";
$temp = call &format("%'08s2", &convert_base($line, 16, 2));
each $char in $temp {
echo $translation[$char];
}
}
);
}
For some reason, JavaScript doesn't like the original order, when I untangle the code.