Skip to main content
Post Undeleted by Dennis
Post Deleted by user61383
Smallest program yet.
Source Link
user61383
user61383

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;;}

C, 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(putchar(c);;)if(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(putchar(c);;)if(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(putchar(c);;)if(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(putchar(c);;)
10              if(rand()>>16 < p[c][++j])
11                  break;
12  }

The variable p[][] will contain the occurrences of each character following another. X contains the entire source, with %c%s%c instead of the assignment for X. The %c characters will be replaced with 64, the double quotation mark.

Line 06 tallies the occurrences of one character following another and starts the Markov model at the first character of the program ('p').

The while loop from 08 to 11 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 than the number of occurrences for that state.

I was able to save bytes by using sprintf over my original string-copying.

Increasing the constant 16 on line 10 can decrease the runtime, but it makes the results less random.

p[++);ar()iforile()in(Y;)putfor(aind(c,X,*a+j=j,c][c,*an(arilear(prea+16])putc])>1)>16][c=%c,*X,j=*ak;f(Y;j)fora+j]=j][256<pre(a;a;f(r*ar(Y;fore()>>>16]++j][256<putc][256<putc={sp[256]){0};j],j);}",*X,j],Y[c);a++j,34,X,c%sputf(c)fora],X="p[*ain();c]+1)>>>>1)>1);;arile();f(Y;a;f()>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;;}

C, 306 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)]++;for(j=*Y;putchar(c=j);)while(p[c][++j]<<16<rand());}",Y[999],c,j,*a;main(){sprintf(Y,X,34,X,34);for(a=Y;*a;a++)p[*a][*(a+1)]++;for(j=*Y;putchar(c=j);)while(p[c][++j]<<16<rand());}
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)]++;for(j=*Y;putchar(c=j);)while(p[c][++j]<<16<rand());}",
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      for(j=*Y;putchar(c=j);)
08          while(p[c][++j]<<16<rand());
09  }

Explanation

Line 01: p[][] holds the counts of one character following another.

Line 02: X contains the program's source, escaped with %c%s%c.

Line 03: Y will contain the program's literal source. c, j, *a are counting variables.

Line 05: Set Y to contain the quine.

Line 06: Count letter occurrences in p[][].

Line 07: Print the current state.

Line 08: Find the next character randomly, proportional to the counts in p[][].

p[++);p[99]=Y;putfor(aind(a++j,*a+j=j,c][c,*an(arile(pr*Y,Y[256]<<1);)][*Y,Y;)wha+++j=*aintfor*Y;prin(a+j]=j][256<1)pr(a;a;f(p[char(Y;for());};a;ma;ma=%s%chain(Y;ar(j][256<<<1)p[256<<raile(cha][9]<rin(j,34,34,Y[256]+j,Y,34,Y,c=Y,*a;*a;for(){0}

Grammar.
Source Link
user61383
user61383

C, 328 585 611 615 623 673 707 bytes

Source code:

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(putchar(c);;)if(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(putchar(c);;)if(rand()>>16<p[c][++j])break;}

With newlines and whitespace added for legibility/explanation:

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(putchar(c);;)if(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(putchar(c);;)
10              if(rand()>>16 < p[c][++j])
11                  break;
12  }

The variable p[][] will contain the occurrences of each character following another. X contains the entire source, with %c%s%c instead of the assignment for X. The %c characters will be replaced with 64, the double quotation mark.

Line 06 tallies the occurrences of one character following another and starts the Markov model at the first character of the program ('p').

The while loop from 08 to 11 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 than the number of occurrences for that state.

I was able to save bytes by using sprintf over my original string-copying.

Increasing the constant 16 inon line 1010 can decrease the runtime, but it makes the results less random.

Sample output:

p[++);ar()iforile()in(Y;)putfor(aind(c,X,*a+j=j,c][c,*an(arilear(prea+16])putc])>1)>16][c=%c,*X,j=*ak;f(Y;j)fora+j]=j][256<pre(a;a;f(r*ar(Y;fore()>>>16]++j][256<putc][256<putc={sp[256]){0};j],j);}",*X,j],Y[c);a++j,34,X,c%sputf(c)fora],X="p[*ain();c]+1)>>>>1)>1);;arile();f(Y;a;f()>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;;}

C, 328 585 611 615 623 673 707 bytes

Source code:

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(putchar(c);;)if(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(putchar(c);;)if(rand()>>16<p[c][++j])break;}

With newlines and whitespace added for legibility/explanation:

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(putchar(c);;)if(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(putchar(c);;)
10              if(rand()>>16 < p[c][++j])
11                  break;
12  }

The variable p[][] will contain the occurrences of each character following another. X contains the entire source, with %c%s%c instead of the assignment for X. The %c characters will be replaced with 64, the double quotation mark.

Line 06 tallies the occurrences of one character following another and starts the Markov model at the first character of the program ('p').

The while loop from 08 to 11 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 than the number of occurrences for that state.

I was able to save bytes by using sprintf over my original string-copying.

Increasing the constant 16 in line 10 can decrease the runtime, but it makes the results less random.

Sample output:

p[++);ar()iforile()in(Y;)putfor(aind(c,X,*a+j=j,c][c,*an(arilear(prea+16])putc])>1)>16][c=%c,*X,j=*ak;f(Y;j)fora+j]=j][256<pre(a;a;f(r*ar(Y;fore()>>>16]++j][256<putc][256<putc={sp[256]){0};j],j);}",*X,j],Y[c);a++j,34,X,c%sputf(c)fora],X="p[*ain();c]+1)>>>>1)>1);;arile();f(Y;a;f()>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;;}

C, 328 585 611 615 623 673 707 bytes

Source code:

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(putchar(c);;)if(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(putchar(c);;)if(rand()>>16<p[c][++j])break;}

With newlines and whitespace added for legibility/explanation:

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(putchar(c);;)if(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(putchar(c);;)
10              if(rand()>>16 < p[c][++j])
11                  break;
12  }

The variable p[][] will contain the occurrences of each character following another. X contains the entire source, with %c%s%c instead of the assignment for X. The %c characters will be replaced with 64, the double quotation mark.

Line 06 tallies the occurrences of one character following another and starts the Markov model at the first character of the program ('p').

The while loop from 08 to 11 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 than the number of occurrences for that state.

I was able to save bytes by using sprintf over my original string-copying.

Increasing the constant 16 on line 10 can decrease the runtime, but it makes the results less random.

Sample output:

p[++);ar()iforile()in(Y;)putfor(aind(c,X,*a+j=j,c][c,*an(arilear(prea+16])putc])>1)>16][c=%c,*X,j=*ak;f(Y;j)fora+j]=j][256<pre(a;a;f(r*ar(Y;fore()>>>16]++j][256<putc][256<putc={sp[256]){0};j],j);}",*X,j],Y[c);a++j,34,X,c%sputf(c)fora],X="p[*ain();c]+1)>>>>1)>1);;arile();f(Y;a;f()>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;;}

Saved 2 bytes.
Source Link
user61383
user61383

C, 336328 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(putchar(c);for(;;j++;;)if(rand()>>16<p[c][j]>>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(putchar(c);for(;;j++;;)if(rand()>>16<p[c][j]>>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(putchar(c);for(;;j++;;)if(rand()>>16<p[c][j]>>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(putchar(c);
10          for(;;j++;;)
1110              if(rand()>>16 < p[c][j]p[c][++j])
1211                  break;
13      }
1412  }

The while loop from 08 to 1311 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 than the number of occurrences for that state.

I was able to save a bunch of bytes by using sprintf over my original string-copying.

Increasing the constant 16 in line 10 can decrease the runtime, but it makes the results less random.

p[j]+;;*a;forintforearp[++);ar(c=Y;;whif)iforile(;;j,j+;j][256<pr)in(Y;jY;)putfor(aind(c,X,X*a+j=j,cha][j+c][c,*an(arilear(prea+16])inputc])>1)>16][c=%c,*X,j=*ak;f(cha;fora+++;cha=j=j]=*X=Y;j)fora+j]=j][256<pre(a;a;f(r*ar(Y;fore()>>>16]++j][256<putc][256<putc={sp[256]){0};j],j);}",*X,j],Y[c);a++j,34,X,c%sputf(c)fora],X="p[*ain();c]+1)>>>>1)>1);;arile();f(Y;a;f()>16]={0};){0}"p[*ain;wha;j=Y;marilea+1)ind(Y;;)p[9]=;whar(r(a=*ar(r(a+){s%csputf()p[*antc>>16][*a]+j,chin(c][c%c%sp[*ar*X=Y[*a;jj,34X,Y;f();j+X,c){0;j=%chaile(a;;}

C, 336 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){putchar(c);for(;;j++)if(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){putchar(c);for(;;j++)if(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){putchar(c);for(;;j++)if(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          putchar(c);
10          for(;;j++)
11              if(rand()>>16 < p[c][j])
12                  break;
13      }
14  }

The while loop from 08 to 13 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 than the number of occurrences for that state.

I was able to save a bunch of bytes by using sprintf.

p[j]+;;*a;forintforear(c=Y;;whif(;;j,j+;j][256<pr(Y;j,X,X,cha][j+)in(cha;fora+++;cha=j=j]=*X={0}}}}"p[*ain()p[9]={s%c)p[*antc,chin(c][c%c%sp[*ar*X=Y[*a;j,34,Y;f();j+){0}

C, 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(putchar(c);;)if(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(putchar(c);;)if(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(putchar(c);;)if(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(putchar(c);;)
10              if(rand()>>16 < p[c][++j])
11                  break;
12  }

The while loop from 08 to 11 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 than the number of occurrences for that state.

I was able to save bytes by using sprintf over my original string-copying.

Increasing the constant 16 in line 10 can decrease the runtime, but it makes the results less random.

p[++);ar()iforile()in(Y;)putfor(aind(c,X,*a+j=j,c][c,*an(arilear(prea+16])putc])>1)>16][c=%c,*X,j=*ak;f(Y;j)fora+j]=j][256<pre(a;a;f(r*ar(Y;fore()>>>16]++j][256<putc][256<putc={sp[256]){0};j],j);}",*X,j],Y[c);a++j,34,X,c%sputf(c)fora],X="p[*ain();c]+1)>>>>1)>1);;arile();f(Y;a;f()>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;;}

deleted 52 characters in body
Source Link
user61383
user61383
Loading
deleted 180 characters in body
Source Link
user61383
user61383
Loading
Significant improvements.
Source Link
user61383
user61383
Loading
deleted 207 characters in body
Source Link
user61383
user61383
Loading
deleted 141 characters in body
Source Link
user61383
user61383
Loading
Saved 4 bytes.
Source Link
user61383
user61383
Loading
Saved 8 bytes.
Source Link
user61383
user61383
Loading
Improved my answer.
Source Link
user61383
user61383
Loading
added 26 characters in body
Source Link
user61383
user61383
Loading
added 703 characters in body
Source Link
user61383
user61383
Loading
edited body
Source Link
user61383
user61383
Loading
deleted 20 characters in body
Source Link
user61383
user61383
Loading
Added line numbers and a description
Source Link
user61383
user61383
Loading
Source Link
user61383
user61383
Loading