C, 328306 328 585 611 615 623 673 707 bytes
p[256][256]={0};char*X="p[256][256]={0};char*X=%c%s%c,Y[999],c,j,*a;main(){sprintf(Y,X,34,X,34);for(a=Y;*a;a++)p[*a][*(a+1)]++;j=*Y;while(c=j)for]++;for(putcharj=*Y;putchar(cc=j);;;)ifwhile(randp[c][++j]<<16<rand()>>16<p[c][++j])break;;}",Y[999],c,j,*a;main(){sprintf(Y,X,34,X,34);for(a=Y;*a;a++)p[*a][*(a+1)]++;j=*Y;while(c=j)for]++;for(putcharj=*Y;putchar(cc=j);;;)ifwhile(randp[c][++j]<<16<rand()>>16<p[c][++j])break;;}
01 p[256][256]={0};
02 char*X="p[256][256]={0};char*X=%c%s%c,Y[999],c,j,*a;main(){sprintf(Y,X,34,X,34);for(a=Y;*a;a++)p[*a][*(a+1)]++;j=*Y;while(c=j)for]++;for(putcharj=*Y;putchar(cc=j);;;)ifwhile(randp[c][++j]<<16<rand()>>16<p[c][++j])break;;}",
03 Y[999],c,j,*a;
04 main(){
05 sprintf(Y,X,34,X,34);
06 for(a=Y;*a;a++) p[*a][*(a+1)]++;
07 j=*Y;
08 while(c=j)
09 for(putcharj=*Y;putchar(cc=j);;;)
10 08 ifwhile(randp[c][++j]<<16<rand()>>16 < p[c][++j])
11 break;;
1209 }
Explanation
The variableLine 01
: p[][]
will containholds the occurrencescounts of eachone character following another.
Line 02
: X
contains the entireprogram's source, escaped with %c%s%c
instead of the assignment for X. The
Line 03
: %cY
characters will be replaced with 64,contain the double quotation markprogram's literal source.
Line 06c
tallies the occurrences of one character following another and starts the Markov model at the first character of the program, ('p'j
), *a
are counting variables.
The while loop from 08Line 05
to: Set 11Y
first outputs the current state of the Markov model, then finds the next state. A state is chosen as the next transition if the next random number is less thanto contain the number of occurrences for that statequine.
I was able to save bytes by using sprintf over my original string-copyingLine 06
: Count letter occurrences in p[][]
.
Increasing the constant 16Line 07
on line : Print the current state.
10Line 08
can decrease: Find the runtimenext character randomly, but it makesproportional to the results less randomcounts in p[][]
.
p[++);ar()iforile()in(Y;)putfor;p[99]=Y;putfor(aind(c,Xa++j,*a+j=j,c][c,*an(arileararile(prea+16])putc]pr*Y,Y[256]<<1)>1;)>16][c=%c,*X][*Y,j=*ak;fY;)wha+++j=*aintfor*Y;prin(Y;ja+j]=j][256<1)fora+j]=j][256<prepr(a;a;f(r*arp[char(Y;foreY;for()>>>16]++j][256<putc][256<putc={sp[256]){0};j],j);}";a;ma;ma=%s%chain(Y;ar(j][256<<<1)p[256<<raile(cha][9]<rin(j,*X34,j]34,Y[c);a++jY[256]+j,Y,34,XY,c%sputf(c)fora]c=Y,X="p[*ain();c]+1)>>>>1)>1);;arile();f(Y;a;f*a;*a;for()>16]={0};){0};wha;j=Y;marilea+1)ind(Y;;);whar(r(a=*ar(r(a+){sputf()>>16][*a]+j,j,X,X,c);j=%chaile(a;;}