Python 3.8 (pre-release), 103103 102 bytes
exec(s:="from random import*;c='e'\nwhile c:print(end=c);c=choice(f'exec(s:={s!r})'.split(c)[1:])[:1]"[0]")
the program stops by crashing due to an IndexError. To avoid crashing, [0] must be replaced by [:1] for the cost of 1 byte
How it works?
- I started from the quine
exec(s:="print('exec(s:=%r)'%s)")
then the core program is the following :
from random import*
c='e'
while c:
print(end=c)
c=choice('<the quine string>'.split(c)[1:])[:1][0]
- I assign
cto the first letter of our quine (e).
while c is not the empty string :
- I print
c - I randomly choose a successor of
cbeween all possible successor
to choose a successor :
- let say our string is
"abacbdeb"and I want a successor of'b': - I split the string using
'b'as separator :['a','ac','de',''] - I remove the first substing which corresponds to the char before the first occurence of
b:['ac','de',''] - I take up to 1 char of these substring :
['a','d','']
If the char is at the end of a string , it will have the empty string as potential successor and will crash the program when atempting to get its first character. It only works beacuse no char is repeated twice.