Move to the printable ASCII front
Ostrich, 46 45 chars
Don't have a version number in the header because this is actually just the latest commit. I added the O
(ascii code to string) operator after releasing the latest version (but still before this challenge was posted).
{a95,{32+O}%:d3@{:x\.3@?3@\+\x-x\+}/;{d=}%s*}
Explanation:
a this is the "r" array (a is short for [], empty array)
95,{32+O}%:d this is the "d" array
3@{...}/ for each character in the input (as an "argument")...
:x store in variable x (stack is now [r d c])
\.3@? find index in d (stack is now [r d idx])
3@\+ append index to r (stack is now [d modified_r])
\x- remove char from d, and then...
x\+ prepend char to d (stack is now [modified_r modified_d])
; throw away modified_d
{d=}% map r to indices of (original) d
s* join (s is short for ``, empty string)
CJam, 20
'¡,q{_C#c' ,C+@|}fC;
Try it online
Explanation:
'¡, make a string of characters with codes from 0 to 160 (a modified "d")
could have been to 126 but stackexchange doesn't like the DEL character
q read the input (s)
{…}fC for each character C in s
_ duplicate the d string
C# find the index of C in d
c convert to character (this is the result)
' , make a string of characters from 0 to 31
C+ append C to the string
@ bring d to the top
| set union, preserving order; effectively, C is moved to position 32
this is the updated d string
; pop the last d
SWI-Prolog, 239 197 189 bytes
a(S):-l([126],X),a(S,X,[],R),b(R,X).
a([A|T],X,S,R):-nth0(I,X,A,Z),(a(T,[A|Z],[I|S],R);R=[I|S]).
b([A|T],X):-(b(T,X);!),nth0(A,X,E),put(E).
l([B|R],Z):-A is B-1,X=[A,B|R],(A=32,Z=X;l(X,Z)).
Example: a(`Two more questions and I have bzip2 in less than 100 bytes!`).
outputs:
Twp#o"si$sv#uvq(u$(l#o#W!r%w+$pz,xF%#,"x(. #0--'$GG ".z(**:
(and true .
after it, obviously)
Note: your SWI-Prolog version has to be one of the newer ones in which the backquote `
represents codes strings. Code strings used to be represented with double-quotes "
in older versions.