##PHP, <s>144</s> <s>135</s> <s>130</s> <s>120</s> 272 bytes <?php $s='<?php $s=\'%s\';$s=sprintf($s,$s);$p=$n="";foreach(str_split($s)as$w)$p=$m[$p][]=$w;do echo$n=$m[$n][array_rand($m[$n])];while("\n"!=$n); ';$s=sprintf($s,$s);$p=$n="";foreach(str_split($s)as$w)$p=$m[$p][]=$w;do echo$n=$m[$n][array_rand($m[$n])];while("\n"!=$n); * The last counted character is a newline, which I use for knowing when to stop Or, formatted for readability: <?php $s = '<?php $s=\'%s\';$s=sprintf($s,$s);$p=$n="";foreach(str_split($s)as$w)$p=$m[$p][]=$w;do echo$n=$m[$n][array_rand($m[$n])];while("\n"!=$n); '; $s = sprintf($s, $s); // Previous character, Next Character, Result $p = $n = ''; // Get and iterate the characters in this file foreach (str_split($s) as $w) { $p = $m[$p][] = $w; } do { echo $n = $m[$n][array_rand($m[$n])]; } while ("\n" != $n); Sample output: <?p=')ay_r_gecorr_splililen]=$p=$w; and: <?p=$n=$ntststs$m[$n=$m[ay_r_chondo$n=$ph(s$nt(fitstr_r_geantentr_s('m[$n=$n"!=$p etstsp][$w;d(fililile(s$w)$nt(sphor_str_getrarast(''''m[$n='m[$m'; and: <?p=$who eay_re($n=$n=$nt(')];d(fililileando et($m[]=$pleay_ch(')aray_ren='''))ay_st_r_s($m[$m[asp])ay_co$m[$p $phorentechitr_rean)][$n=$nd("\n"!=$n=$wh(filend('')ay_gen=$ndo$nt_rasp=$n][$p=$whp=$n='m[$n"\n)))))][$w;dorechph(';dorracho$ple_s$w;fil and: <?ph($n);