q/k4 (3? 5? 8?)
if it's sufficient to enter the code and the input directly into the REPL, it's just asc
:
q)asc"Johnny walked the dog to the park."
`s#" .Jaaddeeeghhhkklnnoooprtttwy"
the `s#
is bit of q notation that indicates that the string is in sorted order (can be binary searched, etc.). if it has to go, that costs two characters, making five:
q)`#asc"Johnny walked the dog to the park."
" .Jaaddeeeghhhkklnnoooprtttwy"
if you want it provided on stdin, it's time to switch to k4 (and we get rid of the `s#
for free), and it's an eight-character solution:
x@<x:0:0
Johnny walked the dog to the park.
" .Jaaddeeeghhhkklnnoooprtttwy"
that one, btw, will work as a code file exactly as is (still eight characters, since q is fine with not having the final newline in a code file). normally there would be issues with a welcome banner and with the REPL staying open, but if you pass the input as a herestring, all that goes away:
$ cat asc.k
x@<x:0:0
$ q asc.k<<<'Johnny walked the dog to the park.'
"\n .Jaaddeeeghhhkklnnoooprtttwy"
$
not actually sure where that extra newline in the output is coming from....
Spaces and symbols can be ignored or deleted
, does that mean must be ignored; or is output such as, .aaddeeeff
allowed? \$\endgroup\$k
s in the output? \$\endgroup\$