Skip to content

Instantly share code, notes, and snippets.

@monomere
Created July 21, 2024 14:14
Show Gist options
  • Save monomere/556e8acee1adbf63e4b221e42db41c22 to your computer and use it in GitHub Desktop.
Save monomere/556e8acee1adbf63e4b221e42db41c22 to your computer and use it in GitHub Desktop.
quine clock in c. CC-BY-3.0
int f[10]={56,0,11,48,56,51,40,20,1972},x,y,j,b,d,w,k,sleep(
int),printf(const char*,...);long t,time(long*);char*s,*v,*g
,*ctime(long*);void p(int c){printf("\e[%sm%c",x<32&&y<5&&((
x/4%3!=2&&x%4<3&&(j=v[x/4],d=f[j],d=0x7bff-16*j-2*(!d?d:d-64
-j/6*3072+(16<<(1<<(((j+3)/4*3+1)/2)))),b=(d>>((4-y)*3+2-x%4
))&1))||y%2!=0&&!((x+3)%12))?"31;7":"",c);x-=c==10?++y,x:-1;
}int main(){s="int f[10]={56,0,11,48,56,51,40,20,1972},x,y,"
"j,b,d,w,k,sleep(\nint),printf(const char*,...);long t,time"
"(long*);char*s,*v,*g\n,*ctime(long*);void p(int c){printf("
"\"\\e[%sm%c\",x<32&&y<5&&((\nx/4%3!=2&&x%4<3&&(j=v[x/4],d="
"f[j],d=0x7bff-16*j-2*(!d?d:d-64\n-j/6*3072+(16<<(1<<(((j+3"
")/4*3+1)/2)))),b=(d>>((4-y)*3+2-x%4\n))&1))||y%2!=0&&!((x+"
"3)%12))?\"31;7\":\"\",c);x-=c==10?++y,x:-1;\n}int main(){s"
"=\"@;printf(\"\\e[2J\");for(;printf(\"\\e[H\"),x=y=0,t=tim"
"e(0),\nv=ctime(&t)+11;){for(b=0;b<8;++b)v[b]=57-v[b];for(g"
"=s;*g;++g\n)if(*g+0==0x40){for(k=0;s[k];k++){if(x==59)p(34"
"),p(10),p(34)\n;switch(s[k]){case 10:case 34:case 92:p(92)"
";default:p(s[k]!=\n10?s[k]:'n');}}p(34);}else p(*g);sleep("
"1);}}";printf("\e[2J");for(;printf("\e[H"),x=y=0,t=time(0),
v=ctime(&t)+11;){for(b=0;b<8;++b)v[b]=57-v[b];for(g=s;*g;++g
)if(*g+0==0x40){for(k=0;s[k];k++){if(x==59)p(34),p(10),p(34)
;switch(s[k]){case 10:case 34:case 92:p(92);default:p(s[k]!=
10?s[k]:'n');}}p(34);}else p(*g);sleep(1);}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment