Infinite monkeys with autocomplete
You've probably heard of the infinite monkey theorem, which states that a monkey pressing keys on a keyboard at random will eventually type any possible string, the most well-known example being the complete works of Shakespeare. Of course, as the string grows longer and longer, the time taken to type that string becomes exponentially longer. But what if the monkey had an autocomplete?
Our hypothetical monkey starts with an alphabet, containing every possible character that it can type, and a dictionary that initially only contains every letter in the alphabet. At every step, it'll choose a random item from the dictionary and type it. But, the monkey has a helpful autocomplete guiding it to the correct string - if the last two items that were typed, concatenated, are a substring of the correct word that's not yet in the dictionary, it'll add that substring to the dictionary.
For example, let's start with the monkey trying to type the word hello
, with the alphabet helo
.
l o
It first types l
and o
and adds lo
to the dictionary.
l o h lo l h e
It then types various random dictionary items before typing h
and e
, and adding he
to the dictionary.
l o h lo l h e e e l
After some more random items, it types e
and l
and adds l
to the dictionary.
l o h lo l h e e e l h lo o el e h el
Next, it types h
and el
and adds hel
.
l o h lo l h e e e l h lo o el e h el lo
After typing the el
, it types lo
and adds ello
to the dictionary.
l o h lo l h e e e l h lo o el e h el lo he hel he l o
Next, it types he
and l
, but because hel
is already in the dictionary it's not added. For the same reason, lo
is also not added.
l o h lo l h e e e l h lo o el e h el lo he hel he l o h ello
Finally, it types h
and ello
, creating hello
after 24 attempts.
Your challenge is to, given a target word and alphabet containing only lowercase ASCII letters and spaces, simulate this behaviour, choosing random items and building up the dictionary until you eventually create the desired word. The alphabet will not contain any character more than once, and will at least contain every character in the target word.
At every step, you should choose a (not necessarily uniformly) random item from the dictionary, and the words you print should be separated by some consistent and unambigiuous delimiter. Although you do not have to uniformly randomly choose an item, it should be possible for any possible output sequence of strings to occur.
This is code-golf, shortest wins!
Examples
Note that this is just one possible output for each input.
word = "abcba", alphabet = "abc" -> "a,a,c,b,b,cb,c,bcb,bcb,a,a,b,cb,ab,cb,b,bcba,bcba,c,b,cb,c,ab,bcba,c,bcb,ab,c,bcba,bcb,bcb,b,bcb,bcba,ab,a,b,a,c,cb,c,bcba,cb,abcb,abcb,ba,ba,abc,a,b,bcb,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m,wor,f,e,k,x,a,d,p,o ,k,orl,m,m,hel,z,g,j,c,f,j,u,ll,h,d,e, ,t,j,c,f,wor,he,p,orl,d,r,orl,hel,q,b,b,wor,y,p,u,he,z,b,he,h,s,ll,y,wor,a,t,b,c,z,y,y,v,b,o ,d,b,or,s,d,k,q,l,x,b,p,orl,e,x,wor,ll,orl,y,o,l, ,a,g, ,x,d,e,wor,y,t,w,orl,c,f,s,i,c,hel,z,i,w,hel,f,i,y,ll,e,x,g,orld,wor,he,n,c,or,x,ll,ll,s,l,t,ll,l,p,q, ,w,worl,a,q,he,i,x,l,hel,g,o , w,m,c,o ,l,z,worl,j,i,y,n,b, w,b,wor,f,r,u,j,l,u,f,z,z,m,c,orld,c,e, w,ll,m,x,y,u,j,t,hel,o ,b,wor,he,m,d,n,f,orld,or,u,i,i,e,c,q,b,t, w,p,c,t,orl,p,c,o ,q,hel,w,orld,c,e, w,orl,b,r,u,y,ll,g,wor,hel,n,s,d,g,y,j,b,t,q,wor,hel,hel,s,y,b,a,or,n,h,orld,hel,orl,k,ll, ,f,z,o ,u,o, worl,he,o,v,e,or,r,wor,wor, worl,h,he,q,c,q,hel,orld,or,u,p,v,hel,ll,or,x,he,o ,q,ll,he,d,x,o ,orl,o ,z,o,b,world,g,or,s,v,a,o ,r,f,hel,i,r,c,s,q,ll,s,u,h,n,u, w,or,u,world,v,m,w,l,x,wor,o ,n,x, wor,a,g,orl,c, ,n,l,o ,w,k,orld,a,w,x, w,g,hel, ,k,orl,orl,r,v,l,o,o,j,orl,o worl,r,s,worl,wor,l,v,o , worl,z,n,lo ,orl,or,s,hel,world,orl,c,u,hel,z,n,z,c,orl,o w,worl,he,e,b,h,f,u,w,k,orl, wor,k,wor,c,f,orl,o worl,f,y,lo ,x,v,l,o ,c,c,z,lo,a,u,hel,orld,world, worl,orl,y,k,ll,ll,e, wor,d,h,j,a,he,j,orl, w,s, wor,he,j,orld,worl,k,hel,u,b,hel,r,w,hel,g,hel,lo, w,o worl,lo ,w,world,o ,lo w,b,t,l,b,u,q,hello, worl,or,p,hello worl,u, ,o ,o w,hel,or,or,u,z, , ,h,hello,o ,z,t,k,q,b,o w,t,m,he,m,w,worl,t,p,hello worl,k,hel,world,z,c, , w,z,b,f,hel,world,r,x,d,o worl,he,x, w,s,i,orld,o,d,t,hello,r,world,j,hello worl,o worl,he,w,f,e, worl,wor,o, worl,o w,lo, wor,lo wor,s,i,b,o worl,m,b,p,v, worl,b,lo ,worl,world,lo wor,f,orl,y,e,x,k,a,x,e,g,s,j,orl, w,d,orl,worl,s,a,worl,lo wor,lo ,o worl,s,lo worl,w,t,hel,orld,orl, worl,b,ll,g,o ,j,he,lo worl,n, ,he,c,n, worl, ,o worl,orl,p,k,b,he,o worl,z,orl,e,a,k,or,o w,z,w,lo w,z,f,u,k,s,o,he,o worl,m,h,a,k,o w,m,b,a,o,lo w,m,o w,he,a,hello,z,lo ,r,b,ll,l,he,or,hel,u, wor,he,g,t,o ,x,v,world,he,p,w,orl,lo,worl,o w, worl,lo w,b,orl,o worl, wor,r,he,h,hel,q,t,u,lo,w, w,lo wor,d,lo worl,n,hello,lo ,he,hello,lo wor,ll,lo worl,he,z,worl,orl, w, worl,lo worl,g,world,j,z,j,o, wor, wor,b,c,p,orl, wor,p,g,y, worl, ,b,k,q,g,o w,o worl,o ,p,d,orl,lo w,lo w,z,he,n,world,wor,d, worl,or,lo wor, wor,l,t,wor,worl,e,m, worl,z,j,hel,h,or,x,k, w,s,s,hello,b,p,lo w,l,g,p,o worl,j,wor,m, w,o,t,u,u,o,orld,s,u, w,orl,he,world,d,t,g,l,u,hello,n,worl,o w,lo worl,d,p,orl,q,o wor,u,v,or,q,d,c,hello worl,he,j,r,world,wor,o wor,hel,world,l,orld,q,x,wor,x,o ,ll,hello, wo,r,lo wor, ,or,j,o worl,t,hel,n,o,p, w,b,world,world,he,lo world,v,or,wor,o,lo world,lo worl,f,hello worl,u,orl,d, ,wor,z,r,lo w,p,o worl,o wor,b,he,f,hello wo,j,o ,o,or,f, ,o w,d, worl,wor,hel,k,y,hel,x,o worl, wor,g,ll, worl, wor,n, wo,orl,hel, wo,s,orld,he,lo,he, worl,o w,lo world,p,lo ,a,o ,v,c,p,t,or, w,q,f,o , wor,o worl,p,s,world,v,m,w,s,r,a,g,orl, ,z,p,v,j,o,o,r,l,c,q,orld,r,l,g,d,rl,lo wor,k,w,o , ,x,k,o,i,z,h,n,t,n, worl,w,w,s, wo,hel,he,f,lo , ,o worl,s,p,hello worl,r,o w,o worl,o w,j,c,world,lo worl,o ,wor,z,y,lo world,lo world,orld,s,u,hello,orl,lo wor,r,or,t,l,m,ll,worl,b,u, wo,o ,t, ,or,ll,ll,o,o w,llo,e,s,b,t,z,d,u,world,p,orld,wor,hello worl,lo worl,p,a,lo w,orld,w,wor,o w,lo worl,w,j,lo worl, worl,s,g,k,a,o w, ,o,hel,o,s,wor,u,w,p, wor,y,ll,he,j,orld,hello worl, worl,g,ll,o,lo worl,n,o,o worl,orld,m,lo,rl,o ,wor,hello worl,e,t,ll,g,d,d,orl,n,k,x,lo worl,a,q,wor,lo wor,lo worl,rl,o ,a,ll, wo,s,w,o w,e,h,lo,wor,o ,c,or,f,z,hel,lo worl,j,i,b,d,rl,lo ,j,j,o w,llo,i,b,z,c, worl,worl,e,o w,m, worl,wor,v,lo worl, ,r,u,y,g, w,m,r,ll,b, worl,g,o wor,b,a,m,n,orld,he,wor,hello,lo worl,orld, worl, , worl,o,q,b,o,e,rl,u,or, wo,u,o wor,hello worl,ll, ,llo,h, , ,wor,rl,y,l,z,he,orld,lo wor,x,g,n,b,world,j,ll,m,x,x,rl,n,lo worl,o worl,b, w, wo,b,z,x,o,v,or,t,hello,w,p,a,o,p,llo, ,y,d,p,h,c, wor,b,r,rl,u,c, worl,llo ,i,lo ,o ,q,p,w,he,he,b,lo,a,z,a,e, wor,v,or,hello wo,lo wor,m,hello worl,lo world,hello,v,worl,hel,s,llo ,e,d,o w,world,lo wor,lo ,hello worl,worl,w,w,orld,hello,o w,q,u,o ,worl,l,a,w, , wor,u,y,rl,s,p,o w,g,a,rl,v,y,orl,worl,o worl,rl,wor,x,u,or,s,orld,x,o ,q,p, w,z,u,t,d,a,orl,ll,o ,r,i,k,lo wor,p,b,a,ll,d,z,hello worl, ,hello worl, wor,o w,world,ll,world,hello,lo worl,k,llo ,hel,e,or,rl,hello,v,q, wo,lo wor,e,s,o,wor,lo ,o w,o ,or,x,wor,d,q,d,wor,hello wo,world, wo,a,llo ,worl,orld, wor,y,y,lo wor,o w, w,o,k,k,o ,b,llo worl,orld,worl,llo worl,ll,y,lo worl, wo,llo,hello,p, wo,u,hello worl,lo wor,m,n,orl,r,s,a, wor,wor,x,lo,u,lo world,lo world,s,o wor,o ,a,he,q,b,o,rl,o w,q,n, w, worl,e,a,k,o w, wor,a,f,o,hello worl, worl,o wor,z,g,s,o w, ,hello,hel,lo,i,lo worl,g,t,lo,lo world,rl,lo wor,o,t,ll,x,w,g,k,v,rl,he,y,hel,world,o wor,a,lo ,b,orl,lo, worl,q,o worl,world, w,hello wo,h,o ,o ,wor,hello,hel,lo ,b,q,o w,l,t,n,llo,e,q,q,q,lo worl,hello wo,orld,hello wo,h,x,p,z,hel,n,w,f,o wor,w,h,or,u,s,hello worl,hello ,d,d,rl,hello worl,wor,orl,hello,world,ll,lo,m,hello ,d,lo ,i,lo wor,orld,o ,z,m,hello wo,llo worl,ll,lo worl,world,hello ,llo,hello,e,rl,worl,h,llo worl,u,llo ,world,r,y,lo wor,g,z,d,worl,m,or,llo, wo,or,he,x,o worl,i,hello worl,k,f,w, w,o ,lo world,lo w,i,a,w,o ,z,r,hello ,hello ,hello worl,x,s,llo wo,u,worl,hello, worl,hello worl, ,world,t,llo world,rl, ,p,l,lo,lo w,worl,l, , ,rl,llo wo,h,o worl,llo worl,s,s,a,he,orld,p,lo ,i,f,hello wo,a,llo worl,llo,llo wo,he,llo ,b,ll, w,lo worl,i,t,k,world,r,llo ,lo worl,o w,d,j,lo worl,t,w,world,a,s,hello worl,or,hello wo,o ,llo wo, wo,u,orld,hello ,hello , worl,u,n,z,lo,o worl,llo , , wo,e,o wor,x,lo , w, world,s,hello ,lo world, world,worl, worl,b,h,h,q,world,s,c,lo w,d, ,l,hello worl,g,wor,or,t,x,i, worl,lo wor,s,p,s,llo worl,lo world,p,orld,f,k, w,orl, world,i,lo,orld,d,p,b, worl, ,world,b,b,ll,orl,l,a,llo ,p,k,world,i,hel,m,lo world,lo world,rl,world,d,q,r,he,j,hello worl,t,v,llo wo,p,d,g, world,world,r,hello,c,hello worl,llo world,lo world,z,m,t,q,j,t,m,d,n, worl,r,hello worl,lo worl,orl,p,hello ,g,o,rl,c,d,ll,lo w,o w,w,wor,orl, worl,llo world,y,llo world,o w, worl,c,g,lo worl, ,q,lo ,h,he,lo w,worl,lo worl,orld,m,u,wor, w,llo world,q,e,p,hello wo,hello worl,worl, world,s,o ,o ,d,o worl,n,x,world,hello worl,hello ,lo world, wo,x,rl,x,s,llo,lo ,a,hello ,e,q,lo w,world,x,i,o wor,w,z,s,o ,k,k,g,llo ,i,hello wo,lo w, worl, w,c, wor,c,c,lo , wo,lo world,lo,o wor,k,world,o wor,y,lo ,q,s,s, worl,hello ,lo , wor,orl,lo wor,llo,hello wo,wor, w,f, wo,w,k,r,j,o ,orld,i,or,p,b,rl,l,llo,e,rl,o,or,v,hello wo,lo ,w,j,w,hello,o w,hello worl,lo worl,e,i,llo,r,llo ,u,x,w,m,worl,h,wor,o, ,lo,o w,f,hel,c,lo world,b,a,llo worl,g,d,j,k,x,hello wo, world,o wor,llo world,hel,h,llo world,t,q,llo worl,x,h,lo ,v,or,b,u, wor,d,e,b,h,x,w,llo ,h,w, worl,o,hello, w, w,d,hello w,t,q,hello wo,llo wo,rl,m,lo wor,r,lo ,o w,hello,llo world,s,k,q,orld,y,v,hel,l,hello wo,w,a,orld,e, ,p, wor, wo,llo,wor,t,hello worl,f,hello w,wor,lo world,or,j,lo,d,i, worl, ,l,o ,wor,lo worl,g,b,m,s,s,ll,worl,orld,he,hello,rl,q,q,c,o worl,x,llo world,b,rl, ,d,ll,o, ,x,rl, wo,v,hel,llo world,l,hello,n,or,d,he,llo world"
word = "code golf and coding challenges", alphabet = "abcdefghijklmnopqrstuvwxyz " -> too large to fit in post