Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!ira.uka.de!ifistg!raichle From: raichle@informatik.uni-stuttgart.de (Bernd Raichle) Newsgroups: comp.text.tex Subject: (Another) puzzler for wannabe wizards Keywords: Dirty Tricks, catcode changing, puzzle Message-ID: Date: 5 Jun 91 10:56:23 GMT Sender: news@ifistg.uucp Reply-To: raichle@azu.informatik.uni-stuttgart.de Distribution: comp Organization: Informatik, Univ. Stuttgart. W.Germany Lines: 49 Some time ago Don Hosek posted > A couple puzzlers for those who think that they're TeX gurus. Here is another puzzle... % ------- CUT HERE ------ % use plainTeX \catcode`\"=\active\gdef"{\"} T"ater % output: T\"ater \begingroup\catcode`\"=12 \showthe\catcode`\" % print: 12 % @ \showthe\catcode`\" % print: 12 T"ater % output: T''ater \catcode`\"=\active T"ater % output: T''ater \endgroup T"ater % output: T\"ater \bye % ------- CUT HERE ------ At the place marked with @ there should be a local(!) re-definition of the active char " This re-definition should satisfy the following constraints: - do not assume that the catcode of " is 12 - no side-effects (local or global) except of changing the macro definition of " with catcode `active' (i.e., you can't use a counter, macro, ... to save the current catcode of ") - with the behaviour specified in the comments - "small is beautiful" => TeX code with no more than 160 chars - do not use \aftergroup A solution with \aftergroup: % @= \begingroup \catcode`\"=\active \aftergroup\def\aftergroup"\catcode`\"=12 \aftergroup{\aftergroup"\aftergroup}% \endgroup Have fun -bernd __________________________________________________________________________ Bernd Raichle, Student der Universit"at Stuttgart | "Le langage est source privat: Stettener Str. 73, D-7300 Esslingen | de malentendus" email: raichle@azu.informatik.uni-stuttgart.de | (A. de Saint-Exupery)