From owner-freebsd-hackers@FreeBSD.ORG Fri Mar 18 01:36:16 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EA4E616A4CE for ; Fri, 18 Mar 2005 01:36:16 +0000 (GMT) Received: from blackwater.lemis.com (wantadilla.lemis.com [192.109.197.135]) by mx1.FreeBSD.org (Postfix) with ESMTP id 210D443D55 for ; Fri, 18 Mar 2005 01:36:15 +0000 (GMT) (envelope-from grog@lemis.com) Received: by blackwater.lemis.com (Postfix, from userid 1004) id 25A2485664; Fri, 18 Mar 2005 12:06:12 +1030 (CST) Date: Fri, 18 Mar 2005 12:06:12 +1030 From: Greg 'groggy' Lehey To: Roman Kurakin Message-ID: <20050318013612.GO65340@wantadilla.lemis.com> References: <4239B16E.8080502@cronyx.ru> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="N5iGxCIPT7YMRg16" Content-Disposition: inline In-Reply-To: <4239B16E.8080502@cronyx.ru> User-Agent: Mutt/1.4.2.1i Organization: The FreeBSD Project Phone: +61-8-8388-8286 Fax: +61-8-8388-8725 Mobile: +61-418-838-708 WWW-Home-Page: http://www.FreeBSD.org/ X-PGP-Fingerprint: 9A1B 8202 BCCE B846 F92F 09AC 22E6 F290 507A 4223 cc: freebsd-hackers@freebsd.org Subject: Re: style(9) example :-) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Mar 2005 01:36:17 -0000 --N5iGxCIPT7YMRg16 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thursday, 17 March 2005 at 19:33:50 +0300, Roman Kurakin wrote: > Hi, > > I was unable to refrain from posting this :-) > > int i;main(){for(;i["] o, world!\n",'/'/'/'));}read(j,i,p){write(j/p+p,i---j,i/i);} There used to be a whole culture of this sort of thing. My favourite one is an anagram generator: #include =20 long a [4],b[ 4],c[4] ,d[0400],e=3D1; typedef struct f{long g ,h,i[4] ,j;struct f*k;}f;f g,* l[4096 ]; char h[256],*m,k=3D3; long n (o, p,q)long*o,*p,*q;{ long r =3D4,s,i=3D0;for(;r--;s=3Di^ *o^*p, i=3Di&*p|(i|*p)&~*o++,*q ++=3Ds,p ++);return i;}t(i,p)long*p ;{*c=3Dd [i],n(a,c,b),n(p,b,p);}u(j)f*j;{j->h =3D(j->g =3Dj->i[0]|j->i[1]|j->i[2]|j->i[3])&4095;}v( j,s)f* j; {int i; for(j->k->k&&v(j->k, ' '),fseek( stdin, j->j, 0);i=3Dgetchar(),putchar(i-'\n'?i:s),i- '\n';);}w(o,r,j,x,p)f*o,*j;long p;{f q;int=20 s,i=3Do->h;q.k=3Do;r>i?j=3Dl[r=3Di]:r>1, s|=3Ds >>2,s|=3Ds>>4,s |=3Ds>>8 ,j=3Dl[r =3D((r&i |s)&~(s>>1))-1&i]):0;--x;for (;x&&!(p&i);p>>=3D1);for(;!x&&j;n(o->i,j->i,q. i),u(&q),q.g||(q.j=3Dj->j,v(&q,'\n')),j=3Dj->k);for(;x;j=3Dx ?j->k:0){for(;!j&&((r=3D(r&i)-1&i)-i&&(r&p)?2:(x=3D0));j=3Dl[r]);! x||(j->g&~o->g)||n (o->i,j->i,q.i)||( u(&q), q.j=3Dj ->j,q.g?w(&q ,r,j->k,x ,p):v(&q, '\n')); }}y(){f j;char *z,*p; for(;m ? j.j=3D ftell( stdin) ,7,(m=3D gets(m ))||w( &g,315 *13,l[ 4095] ,k,64* 64)&0: 0;n(g .i,j.i, b)||(u (&j),j. k=3Dl[j.h],l[j.h]=3D &j,y())){for(z=3D p=3Dh;*z&&( d[*z++]||(p=3D0)););for(z=3Dp?n(j.i ,j.i,j.i)+h:""; *z;t(*z++,j.i));}}main(o,p)char** p; {for(;m =3D *++p;)for(;*m- '-'?*m:(k=3D -atoi(m))&0;d[*m]||(d[*m ]=3De,e<<=3D1),t(*m++,g.i)); u(& g),m=3Dh ,y();} To run it, you need a dictionary such as /usr/share/dict/web2. For example: gson free software foundation < /usr/share/dict/web2 gson obfuscated c contest < /usr/share/dict/web2 gson unix international < /usr/share/dict/web2 gson george bush < /usr/share/dict/web2 gson bill clinton < /usr/share/dict/web2 gson ross perot < /usr/share/dict/web2 gson paul e tsongas < /usr/share/dict/web2 Greg -- See complete headers for address and phone numbers. --N5iGxCIPT7YMRg16 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (FreeBSD) iD8DBQFCOjCMIubykFB6QiMRAi/ZAKChSm/I6J9YhnpRZuwNNFiV3gxndwCfeL2Z GvdncGA/yLcgizj7XVXNIzI= =gfd7 -----END PGP SIGNATURE----- --N5iGxCIPT7YMRg16--