[Question]
  [
The [infinite monkey theorem](https://en.wikipedia.org/wiki/Infinite_monkey_theorem) states that, given infinite time, a machine sending an endless stream of random characters will always type any given text.
That sounds to me like a great idea for a challenge.
## Process
In order to monkey-ize a string A, the following steps should be taken:
1. Take an empty string. We will call this string B.
2. Pick a uniformly random printable ASCII character (characters in the range `0x20` to `0x7E`) and add that character to B.
3. If A is a substring of B, B is our monkey-ized string. Otherwise, repeat step 2 until A is a substring of B.
This process is only an example, easier methods may exist depending on your language. You do not need to follow this method exactly, as long as the same distribution of outputs is achieved.
## The challenge
Write a program or function that, given a non-empty string in [any reasonable format](https://codegolf.meta.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods), returns a monkey-ized version of that string.
Your program only has to practically work for inputs of length 3 or less. For longer inputs, it is allowed to terminate early with or without outputting anything.
## Example
Unfortunately, it's kind of hard to create examples for this question due to the random nature of it and the large outputs.
However, I can supply [a single example](https://hastebin.com/racimekuti) for the input `hi`, on Hastebin.
## Scoring
Since this is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), the submission with the fewest bytes wins.
  
[Answer]
# C, 192 bytes
```
i;g(s,b,i,n,j)char*s,*b;{for(b[i+1]=0;b[n+j];++n)s[n]-b[n+j]&&(n=-1,++j);return n;}f(char*s){char*b=calloc(strlen(s),1);for(i=0;s[i];)i=(b[i]=putchar(rand()%95+32))-s[i]?i?g(s,b,i,0,0):0:i+1;}
```
[Try it online!](https://tio.run/##NY7BisMwDETv/YpQaJFqB5xdetgK0w8JPsTepFVI1cV2TyHfniYpq4sYoXkzobyFMM9MN0jaa9aiewz3Jp6SPnkau2cEX7OqnDXka1G9I6UEUy2u/OjjEcSWlVaqR4ptfkUphKYOPhgct@1taIbhGSDlOLQCCXWFtOJ5IaeaHSHbNcvZv1dePRAb@QU8/JzV9xdiuT5d@frf1GiDF3NZutE0s@Ti0bAA7sZdsUzazJkfLRhE2m4d7O@8X8Q0vwE)
It's a mess now, but at least it [works even for the corner cases](https://tio.run/##ZZBRa8IwEIDf@ytqGZJrUozsQdasyHBzAx3IHvZSymhjtSc1bk180OJv79IWx8a@e8hdjnw5TgZbKRtZpJW7jhM3cr3BIE2zNiT/SzzHn7xA/g9POKPRb9P5tHqY3b@Fr48vp@f56nz3dTM5fEyKcqneF4vl7OmU421PcU0s1tNZfGMla9Gg2BLNMoZMsR20LV8zPxP15lCRLEY6TiIusljRXSIoVaBjlQR9PRwSFQVjRukORJWbY6VcJS4b0mug7s4skmlZHiTRpipzRTSwMYhWj9asY0wEYNT@lUSfR9O@Ib6hFCBom1OcXifkjEPIQzuTuDSojLtPURFwase16CpVa2JwnxMOILq7DfG6ZXu2vjTf)...
---
# ~~C, ~~63~~ ~~62~~ 61 bytes~~
*Thanks to @Jonathan Frech for saving a byte!*
```
i;f(char*s){for(i=0;s[i=putchar(rand()%95+32)-s[i]?0:i+1];);}
```
[Try it online!](https://tio.run/##S9ZNT07@/z/TOk0jOSOxSKtYszotv0gj09bAujg607agtAQkrFGUmJeioalqaaptbKSpC5SJtTewytQ2jLXWtK79n5lXopCbmJmnoclVzaUABMVg9SWZuakaBpqa1mCxNA2ljEwlIKf2PwA)
[Answer]
# [Python](https://docs.python.org/3/), 79 bytes
```
f=lambda x,s='':x in s and s or f(x,s+chr(randint(32,126)))
from random import*
```
[Try it online!](https://tio.run/##FYo7DoAgEAV7T7EdrNIIiYUJh0EJgUQ@WSjw9IjNvGTelLf5nNQYTj8mXtZAF1UzdnYICSqYZCczgePz2G5PnKYLqXElxS4PRFwc5Qi/nhNiydTWUehvHGeGIY4P "Python 3 – Try It Online")
This is theoretically sound, but will crash early due to python's recursion limits (you can set them further to get longer results)
# Python, 84 bytes
```
from random import*
x,s=input(),''
while x not in s:s+=chr(randint(32,126))
print(s)
```
[Try it online!](https://tio.run/##Fcs9DoAgDEDhnVN0E5RFTRxMOIzxJzSRQkqNeHrU6eUbXnrERxprPTgG4IW2LxhSZGlVsdkhpUu0sU2jbo/nDgUoCiBBnnPnVs/6v5BEj4Pth8kYlfhnNrV6fAE "Python 3 – Try It Online")
This one is ought to work for relatively longer strings, since it doesn't rely on recursion, at the cost of 5 bytes.
[Answer]
# [Ohm v2](https://github.com/MiningPotatoes/Ohm), 10 bytes
```
Ý£D³ε‽α@§↔
```
[Try it online!](https://tio.run/##AR4A4f9vaG0y///DncKjRMKzzrXigL3OsUDCp@KGlP//aGk "Ohm v2 – Try It Online")
Explanation:
```
Ý£D³ε‽α@§↔  Main wire, arguments: a (string)
Ý           Push empty string to top of stack
 £          Start infinite loop
  D³ε‽        If a is a substring of the ToS, break out of the loop
      α@§     If not, select a random printable ASCII character...
         ↔    ...and concatenate it with the ToS
```
[Answer]
# [Funky](https://github.com/TehFlaminTaco/Funky), 64 bytes
```
s=>{S=""whileS::sub((#S)-#s)!=s S+=S.char(math.random(32,126))S}
```
This uses a few tricks I've been wanting to use in Funky, like a variable name after a keyword as in `whileS`, and using the fact that strings implicitly parent to the `string` library.
## Ungolfed
```
function monkey(target){
    monkeyCode = ""
    while (monkeyCode::sub((#monkeyCode)-#target)!=target){
        monkeyCode += string.char(math.random(32,126))
    }
    monkeyCode
}
```
[Try it online!](https://tio.run/##SyvNy678n2b7v9jWrjrYVkmpPCMzJzXYyqq4NElDQzlYU1e5WFPRtlghWNs2WC85I7FIIzexJEOvKDEvJT9Xw9hIx9DITFMzuPZ/QVFmXolGmoZSRqaSpuZ/AA "Funky – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), 100 bytes
```
import System.Random
s#(a:b)|and$zipWith(==)s$a:b=s|1>0=a:s#b
m a=(a#).randomRs(' ','~')<$>newStdGen
```
[Try it online!](https://tio.run/##HcuxCsMgFEDRPV8hMaBCCe0afFm7dIpD5xciKI1GfJbSEvrrNnS8B65Deth1rdWHtOXCzJuKDf2EcdlCQ1ziMKv9qO7j090XJwEUdYcC7ZfxDDgQn5vAECRy1ef/OJEUTJzEVyjdjdG@TFmuNtaAPkJ6FlPyLYLWgbXOt/UH "Haskell – Try It Online")
Basic idea is to generate an infinite list of characters with `randomRs` and stop it once we find the string.
[Answer]
# [C# (.NET Core)](https://www.microsoft.com/net/core/platform), 86 bytes
```
a=>{var b="";for(var r=new Random();!b.Contains(a);b+=(char)r.Next(32,127));return b;}
```
I don't really like how much creating the `Random` instance takes, but I don't think there's a way around it.
[Try it online!](https://tio.run/##PY6xTsMwEIZ3P8WRyRYlUsvA4LoLElOLEAzMZ9dJLSU2Ol9KUZVnD06DmH7d/d/pO5cfXCI/DTnEFj5@MvteC/E12C44cB3mDG@UWsIexFUA/DWZkUucUzjCAUOUCko5AwBnJGCk1jMYqE6h0v/rxkT/DS9DdNvMVJSrJXZyQrO7zog1VaWbRHIe6Ma/YzymXip9Z@vnFLn4skSl7b2R7oSkqH71F5aPm9V686SUJs8DRbB6nNQiL2c5db7@pMB@H6KXjVx@VDdiFOP0Cw "C# (.NET Core) – Try It Online")
[Answer]
## [GNU sed](https://www.gnu.org/software/sed/) + coreutils, 75 + 1(r flag) = 76 bytes
```
h
:
s:.*:shuf -i32-126|dc -e?P:e
H;g
s:\n::2g
/^(.+)\n(.*)\1/{s::\2\1:;q}
b
```
[Try it online!](https://tio.run/##K05N@f8/g8uKq9hKT8uqOKM0TUE309hI19DIrCYlWUE31T7AKpXLwzodqCAmz8rKKJ1LP05DT1szJk9DT0szxlC/utjKKsYoxtDKurCWK@n/fzOdf/kFJZn5ecX/dYsA) (It takes a lot of runs to get an answer for a length 2 input, because most of the time you run out of allowed TIO computation time.)
**Explanation:**
```
h                                # copy input string 'A' to hold space
:                                # start loop
    s:.*:shuf -i32-126|dc -e?P:e # run shell script: shuf outputs a rnd permutation
                                 #of the set of numbers from 32 to 126, and '?P' in
                                 #dc converts the 1st read decimal to an ASCII char
    H;g                          # append char to hold space ('A\n.'), then copy
                                 #result back to pattern space
    s:\n::2g                     # remove all '\n's from pattern space, but first
    /^(.+)\n(.*)\1/{             # if pattern is 'A\n.*A' (A substring of B), then
        s::\2\1:;q               # search previous regex used and leave only '.*A',
                                 #then quit (implicit printing before exit)
    }
b                                # repeat loop
```
**Benchmark:** approximate, for scaling purposes only
* input length: 1, 10 random inputs (runs), average time: < 1 s
* input length: 2, 10 random inputs (runs), average time: 90 s
* input length: 3, 10 random inputs (runs), average time: lots of hours!
[Answer]
# Perl 5, 31 +2 (-pa) bytes
```
}{$_.=chr 32+rand 95until/\Q@F/
```
[Try it online](https://tio.run/##K0gtyjH9/7@2WiVezzY5o0jB2Ei7KDEvRcHStDSvJDNHPybQwU3////Kkn/5BSWZ@XnF/3ULEgE)
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 26 bytes
```
@(PbU >-1}a@P+=(Mq95 +32 d
```
[Try it online!](https://tio.run/##y0osKPn/30EjIClUwU7XsDbRIUDbVsO30NJUQdvYSCHl/3@lCiUA "Japt – Try It Online")
[Answer]
# [R](https://www.r-project.org/), ~~79~~ ~~76~~ 75 bytes
*-3 bytes thanks to [MickyT](https://codegolf.stackexchange.com/users/31347/mickyt) for changing the random sampler*
*-1 byte thanks to [Robin Ryder](https://codegolf.stackexchange.com/users/86301/robin-ryder) for tweaking the random sampler again*
```
function(S){G=""
while(!grepl(S,G))G=paste0(G,intToUtf8(32+95*runif(1)))
G}
```
[Try it online!](https://tio.run/##K/qfpmCj@z@tNC@5JDM/TyNYs9rdVkmJqzwjMydVQzG9KLUgRyNYx11T0922ILG4JNVAw10nM68kJD@0JM1Cw9hI29JUq6g0LzNNw1BTU5PLvfZ/moZSRqaS5n8A "R – Try It Online")
[Answer]
## Charcoal, ~~15~~ ~~14~~ 12 bytes
```
Ｗ¬№ωθ≔⁺ω‽γωω
```
[Try it online!](https://tio.run/##S85ILErOT8z5/788IzMnVUHDL79Ewzm/NK9Eo1xHoVBTU1PBsbg4Mz1PIyCntBgkFpSYl5Kfq5GuqamjUK5pzRVQlAlSrGn9/39G5n/dshwA "Charcoal – Try It Online") Link is to verbose version of code. Edit: Saved 2 bytes due to a subsequent bug fix in Charcoal. Explanation:
```
    θ           Input string
   ω            Predefined variable `w`
  №             Count number of occurrences
 ¬              Logical not
Ｗ               Loop while true
       ω        Predefined variable `w`
      ⁺         Concatenated with
         γ      Predefined printable characters
        ‽       Random element
     ≔    ω     Assign to predefined variable `w`
           ω    Predefined variable `w`
                Implicitly print
```
[Answer]
# [Ruby](https://www.ruby-lang.org/), 42 bytes
```
->w,s=""{s+=[*" "..?~].sample;s[w]?s:redo}
```
[Try it online!](https://tio.run/##DYs5DsIwEEV7TvFlOhYfABRyAQr6KIVJfmSLbJqxFSEEVzdu3yLp@c5Dlc@37aSVMR89Vs3BwFhb/1qrblpHXrXZ2lovwn755j0eI50SL3JFmDGFuUf0LiKGxUqaERQO6l0ZINQlSUeLe5hCaTzLtKYITyHiUoiQ6EruukhRuytWMTTGmzb/AQ "Ruby – Try It Online")
[Answer]
# Pyth - 14 bytes
```
.W!}zH+ZOrd\k
```
[Try it online here](http://pyth.herokuapp.com/?code=.W%21%7DzH%2BZOrd%5C%7Fk&input=a&debug=0).
[Answer]
# Mathematica, 65 bytes
```
""//.x_/;x~StringFreeQ~#:>x<>RandomChoice@CharacterRange[32,126]&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n6Zgq/BfSUlfX68iXt@6oi64pCgzL92tKDU1sE7Zyq7Cxi4oMS8lP9c5Iz8zOdXBOSOxKDG5JLUIKJqeGm1spGNoZBar9j8AqKtEwSEtWikjUyn2PwA "Wolfram Language (Mathematica) – Try It Online")
*-3 bytes from Jonathan Frech*
[Answer]
# [Lua](https://www.lua.org), ~~99~~ 102 bytes
* Saved a bug thanks to [ATaco](https://codegolf.stackexchange.com/users/58375/ataco), which added three bytes.
```
function f(B)s=string S=""while not(s.find(S,B,1,1))do S=S..s.char(math.random(32,126))end print(S)end
```
[Try it online!](https://tio.run/##TcxBCsMgEEDRq4irGZABU@gum1zBE0jUKsSx6ITucnWb7rr7i8c/Tj9nOnmX0lgl2HCsQ3rhl3Kr1p9cjqi4CQxKhQM4sxlrLGJoN3BEg/bsO1Qvmbrn0Co8FmOXJ2LkoN73SsD9ev6ZEWOANkhKjYCYQF@kcX4B "Lua – Try It Online")
[Answer]
# [MATL](https://github.com/lmendo/MATL), ~~17~~ 16 bytes
```
''`6Y2TZrhtGXfn~
```
[Try it online!](https://tio.run/##y00syfn/X109wSzSKCSqKKPEPSItrw4oYmKkrgAA "MATL – Try It Online")
-1 byte thanks to [Giuseppe](https://codegolf.stackexchange.com/users/67312/giuseppe)
[Answer]
# [Octave](https://www.gnu.org/software/octave/), 62 bytes
```
t=input(o="");while(~nnz(regexp(o,t)))o=[o,randi(95)+31];end;o
```
[Try it online!](https://tio.run/##y08uSSxL/f@/xDYzr6C0RCPfVklJ07o8IzMnVaMuL69Koyg1PbWiQCNfp0RTUzPfNjpfpygxLyVTw9JUU9vYMNY6NS/FOv//f/WMTHUA "Octave – Try It Online")
Explanation:
```
t=input(o="");               % get stdin and define output
while(~nnz(regexp(o,t)))     % while no matches
    o=[o,randi(95)+31];      % concatenate string with ascii char
end;                            
o                            % output result
```
Many thanks to Luis Mendo for the edits!
[Answer]
# [Japt](https://github.com/ETHproductions/japt), ~~16~~ ~~14~~ 11 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
;_øU}a@P±Eö
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=O1/4VX1hQFCxRfY&input=Ijgi)
```
;_øU}a@P±Eö     :Implicit input of string U
 _              :Function taking a string as argument
  øU            :  Contains U
    }           :End function
     a@         :Get the first result of the following function that returns true
       P±       :  Append to P (initially the empty string)
;        E      :  ASCII
          ö     :  Random character
```
[Answer]
## [Alice](https://github.com/m-ender/alice), 21 bytes
```
/U!?"$~dr@
\idwz K"o/
```
[Try it online!](https://tio.run/##S8zJTE79/18/VNFeSaUupciBKyYzpbxKwVspX////8QkAA "Alice – Try It Online")
### Explanation
```
/...@
\.../
```
This is framework for mostly linear programs that operate entirely in Ordinal (string-processing) mode. The IP bounces diagonally up and down through the program twice, which means that the actual code is a bit weirdly interleaved. The commands in the order they're actually executed are:
```
i!w" ~"rUd?z$Kdo
```
Let's go through this:
```
i       Read all input.
!       Store the input on the tape for later.
w       Push the current IP address onto the return address stack.
        This marks the beginning of the main loop.
  " ~"    Push this string.
  r       Range expansion. Turns the string into " !...}~", i.e. a string
          with all printable ASCII characters.
  U       Random choice. Picks a uniformly random character from this
          string. This will remain on the stack throughout the rest of
          the program and will form part of the resulting string.
  d       Join stack. This takes all strings on the stack and joins them
          into a single string and pushes that (it does this without actually
          removing any elements from the stack).
  ?       Retrieve the input from the tape.
  z       Drop. If the joined string contains the input, everything up to
          and including the input will be discarded. Otherwise, nothing
          happens to the joined string. This means that the result will be
          an empty string iff the joined string ends with the input.
$K      If the top of the stack is not empty, jump back to the w to continue
        with another iteration of the main loop.
d       Join the stack into a single string once more.
o       Print it.
```
[Answer]
# [Perl 6](http://perl6.org/), 39 bytes
```
{("",*~(" ".."~").pick...*~~/$_/)[*-1]}
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYPu/WkNJSUerTkNJQUlPT6lOSVOvIDM5W09PT6uuTl8lXl8zWkvXMLb2v7VCcWKlQpqGeoS6pvV/AA "Perl 6 – Try It Online")
`(...)[*-1]` returns the last element of the sequence defined by `...`, of which:
* `""` is the first element;
* `* ~ (" " .. "~").pick` generates the next element by appending a random character in the appropriate range to the previous element; and
* `* ~~ /$_/` is the ending condition, which is that the current element matches the main function's input argument `$_` as a literal substring.
[Answer]
# Java 8, ~~81~~ ~~79~~ 78 bytes
```
a->{String b="";for(;!b.contains(a);b+=(char)(32+Math.random()*95));return b;}
```
-1 byte thanks to *@OlivierGrégoire* for pointing me to a (big >.<) mistake I've made..
**Explanation:**
[Try it here.](https://tio.run/##LY7PbsIwDMbvPIXpKRkiB9AOU9S9AVx2RBycNKwB6lSJi4RQn73zRCRb8t/v@13xgds0Brp2t8XfsRQ4YKTXCiASh3xBH@D43wL8cI70C17VArWV@SwpURg5ejgCQQsLbr9f9cq1TWMvKSu7dsYnYpEvSn7dplW@x6zVfrc5IPcmI3VpUPrj61NrmwNPmcDZebFvj3Fyd/GoVo8UOxhErfKczkJUSZ@Fw2DSxGaUFSsyXjV9bHRFnpc/)
```
a->{                    // Method with String as both parameter and return-type
  String b="";          //  Result-String, starting empty
  for(;!b.contains(a);  //  Loop as long as the result does not contain the input
    b+=(char)(32+Math.random()*95)
                        //   Append a random character to `b`
  );                    //  End of loop
  return b;             //  Return the result-String
}                       // End of method
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~10~~ 9 bytes (-1 @ Emigna)
```
[žQΩJD¹å#
```
[Try it online!](https://tio.run/##MzBNTDJM/f8/@ui@QL0gL5dDOw8vVf7/PxEA "05AB1E – Try It Online")
---
[Do the monkey with me.](https://i.stack.imgur.com/ZWh1z.gif)
---
```
[              | Loop forever.
 žQ            | Push 0x20-0x7E as a single string.
   .R          | Pick from it randomly.
     J         | Join stack (B) with new char.
      D        | Duplicate (B).
       ¹å      | Push input (A) and check if input (A) is in (B).
         #     | If the previous statement is true, break loop.
```
[Answer]
# [QBIC](https://drive.google.com/drive/folders/0B0R1Jgqp8Gg4cVJCZkRkdEthZDQ), 33 bytes
```
≈instr(Z,;)<1|Z=Z+chr$(_r32,126|)
```
## Explanation
```
≈instr( , )<1|   WHILE InStr() can't find
         ;        the input (cmd line string argument) as part of
       Z          the output (Z$, which is printed automatically on exit)
Z=Z+             add to the output
chr$(         )  an ASCII character
     _r32,126|   with a random codepoint between 32 and 126 (incl)
```
## Sample run:
```
Command line: hi
`;7L3f$qy )H99tZ@>(-Z1efL|Q-5'BE=P8BdX?Lem/fp|G#~WY[ Q4s9r~Af*T})P4`4d$#ud3AiuTwQPFS@8c7_59C$ GlJ%iJ[FA(rNt<y>Hl=r,wSbBB%q!8&#*CixWbnwE."wrZ:R53iKJkN*@hpQt aMj6Mw<KfT@hkik>_k'_>$~3)jl|J!S`n\Yw|lXi:WAKWp?K"F.cAGI/:~uR8*[;Die{]B*]@;Vhjv,$9]Ys:AIdy!j{aXlr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efPRH(OeRq0{=>Uc[~xcTcV_9|k54Q2*N.3]LlmFasY3"p =$$onbg$M+ReRsnH|9gV~#2?c1-V$35."DZH-O$~,c.gs]%,]p4\OFIW%l:,E,YT8FCeU8hy#lNq1lCpS 0I&q_*q>|=,(-dHuzi~6$GW22*A\w*&R< W`$HPRr,2A}3w\"Y?d%{2^xP:GqI\26A|.e'H2Z[M4=P.H87O~{)9|B*tHAC\j^S,StW!*snsz82R!:eD@uB4x+x&zSIN(3V|.^N_$=i=p}iK4h'v"$:I<t e:Y/XrSOF83=lkVNa0^k@jB@{ARE@r=Bja`(Bw>@?+`Wo,= u5HhXPeRMXS4@H#$-Jwg2"2-]%7p.o2Ar9J6Y1Ra?"3<oee&bpO^O{nw9=%\0brVNXrelWGoJyb/5W%MB0UBaPsc*29K<N~``NriWM$"eY0@xh^<$b:E/J~S%{#ry~6d?4Vv@^&9'=iBA#2U]bj9>UoJ#wQDN~6cB&/_Pu-XF?_hu3><(M7RW\%Ly@rTC9^b`?kVL~w%[{!&{#aS7<mc@J>ZaN7s}Y.c0:Y.\d&_[L{m|>|>%J^@!i9y0_lwejChi
```
[Answer]
# PHP, 55+1 bytes
```
while(!strpos(_.$argn,_.$s.=chr(rand(32,126))));echo$s;
```
Run as pipe with `-nR`. Not suitable for TIO cause of probable timeout.
Insert a space between the quotation marks for PHP older than 7.1.
This **51+1 bytes** version will fail if input is `0`:
```
while(!strstr($argn,$s.=chr(rand(32,126))));echo$s;
```
[Answer]
# Javascript 74 bytes
```
s=(a,b='')=>~b.search(a)?b:s(a,b+String.fromCharCode(32+Math.random()*95))
```
call like this:
```
s('hi')
```
[Answer]
# [Julia 0.6](http://julialang.org/), 53 bytes
```
a->(s="";while !contains(s,a) s*=randstring(1) end;s)
```
[Try it online!](https://tio.run/##DcU7DoAgDADQ3VMgExgdXFwIxqtU@dWQklANx0ff8u43I2w92NNHpA7LrthKaVrC7MV4FXoAiRXPoAVPtgI5fipSVKsWnpxh3f@Gg1NpIiiZUOr@AQ "Julia 0.6 – Try It Online")
[Answer]
# [Pushy](https://github.com/FTcode/Pushy), ~~20~~ 18 bytes
```
LFZ^tCN[,` ~`U'x?i
```
**[Try it online!](https://tio.run/##Kygtzqj8/9/HLSquxNkvWidBoS4hVL3CPvP///9KiUlKAA "Pushy – Try It Online")**
The program keeps a stack `len(input)` characters long, and constantly removes the first and appends a new random char, until the initial input string is reached. Each character is printed as it is added, creating the desired effect.
Explanation:
```
                      \ == SETUP ==
 F                    \ Put input on second stack
L Z^tC                \ On the main stack, make length(input) copies of 0
      N               \ Remove printing delimiter (newline by default)
                      \ == MAIN LOOP ==
       [              \ Infinitely:
        ,             \    Pop the first item on stack
         ` ~`U        \    Add a new random character (between 32 and 126)
              '       \    Print this new character
               x?     \    If the stacks are now equal:
                 i    \        Exit program
```
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 17 bytes
```
I⁰∧Ẹ{sI⁰&|;Ṭṛᵗc↰}
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/r/qG3Do6bG8v@ejxo3POpY/nDXjupiEFutxvrhzjUPd85@uHV6MlBR7f//ShmZSgA "Brachylog – Try It Online")
```
I⁰                   The global variable I⁰
                     is the input,
  ∧                  and
   Ẹ                 starting with the empty string
    {          ↰}    call this sub-predicate again
            ṛ        with a random
           Ṭ         printable ASCII character
          ;  ᵗc      appended to the string we're building
         |           unless
      I⁰             I⁰ (which is the input)
     s               is a substring of the string we've been building
        &            in which case the string is output.
```
Can randomly stack overflow. This makes use of two recently added features in Brachylog: global variables, and the apply-to-tail metapredicate `ᵗ`.
[Answer]
# Pyth, 13 bytes
```
W!}z=akpOrd\
```
where the unprintable character is 0x7F.
[Test](http://pyth.herokuapp.com/?code=W%21%7Dz%3DakpOrd%5C%7F&input=a&debug=0)
[Answer]
# Bash 94 bytes
```
p=printf\ -v;until [[ $s = *"$1" ]];do $p x %x $[32+RANDOM%95];$p c \\x$x;s+=$c;done;echo "$s"
```
[Try it online](https://tio.run/##S0oszvj/v8C2oCgzryQtRkG3zLo0ryQzRyE6WkGlWMFWQUtJxVBJITbWOiVfQaVAoUJBtUJBJdrYSDvI0c/F31fV0jTWGiierBATU6FSYV2sbauSDFSbl2qdmpyRr6CkUqz0////RD0A)
]