🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text.tex
Article #10127

Re: (Another) puzzler for wannabe wizards

#10127
From: Raymond Chen
Date: Thu, 06 Jun 1991 16:14
40 lines
2192 bytes
In article <RAICHLE.91Jun5125624@azu.informatik.uni-stuttgart.de>, raichle@informatik (Bernd Raichle) writes:
>% use plainTeX
>\catcode`\"=\active\gdef"{\"}
>T"ater                     % output: T\"ater
>\begingroup\catcode`\"=12
>  \showthe\catcode`\"      % print:  12
>  % @<Insert your hack at this place@>
>  \showthe\catcode`\"      % print:  12
>  T"ater                   % output: T''ater
>  \catcode`\"=\active
>  T"ater                   % output: T''ater
>\endgroup
>T"ater                     % output: T\"ater
>\bye

I know we were expressly forbidden from using \aftergroup, but here's
a solution shorter than the one Mr. Raichle provided (47 characters)

   {\catcode`"\active\aftergroup\let\aftergroup"}"

Of equal length, but slightly more devious (using the fact that we can
use " itself as a scratch variable!)

   {\catcode`"\active\aftergroup\let\futurelet"}""

Anyway, here's a non-aftergroup solution.

   {\catcode`"\active\let"a\expandafter}\expandafter\let""

It makes the assumption that \catcode`\a=11, which is a safe assumption
because if it weren't, the \catcode csname wouldn't have been parsed
correctly in the first place!

Other things I tried...

   use an \halign to control the order of tokenization
   using \char34 instead of \catcode`"12" (turned out not to be necessary)
   using \afterassignment instead of \aftergroup (turned out not to be nec.)

Does this make me a wizard?
Technical Details
Message-ID: <1991Jun6.161408.16830@agate.berkeley.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!stanford.edu!agate!sunkist.berkeley.edu!raymond
References: <RAICHLE.91Jun5125624@azu.informatik.uni-stuttgart.de>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!stanford.edu!agate!sunkist.berkeley.edu!raymond
From: raymond@math.berkeley.edu (Raymond Chen)
Newsgroups: comp.text.tex
Subject: Re: (Another) puzzler for wannabe wizards
Keywords: Dirty Tricks, catcode changing, puzzle
Message-ID: <1991Jun6.161408.16830@agate.berkeley.edu>
Date: 6 Jun 91 16:14:08 GMT
References: <RAICHLE.91Jun5125624@azu.informatik.uni-stuttgart.de>
Sender: usenet@agate.berkeley.edu (USENET Administrator)
Reply-To: raymond@math.berkeley.edu (Raymond Chen)
Distribution: comp
Organization: U.C. Berkeley
Lines: 40
In-Reply-To: raichle@informatik.uni-stuttgart.de (Bernd Raichle)
Originator: raymond@sunkist.berkeley.edu