Xref: utzoo comp.lang.c:17486 comp.lang.modula2:1404 comp.lang.pascal:1678 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!rochester!rit!ritcv!dgr0093 From: dgr0093%ritcv@cs.rit.edu (340 Ok) Newsgroups: comp.lang.c,comp.lang.modula2,comp.lang.pascal Subject: Re: Another Silly programming puzzle.... Summary: Ah c'mon, it's easy to do better than THAT.. Keywords: contest silly Message-ID: <1039@cs.rit.edu> Date: 7 Apr 89 00:35:27 GMT References: <1210@microsoft.UUCP> <12320@reed.UUCP> Sender: news@cs.rit.edu Reply-To: dgr0093%ritcv@cs.rit.edu (Michelangelo H. Jones) Followup-To: comp.lang.c Organization: Rochester Institute of Technology, Rochester, NY Lines: 50 I wasn't going to post this, but decoding rot13 text is much easier than that last program would indicate. I wrote this a few months ago, and it's a full text filter, so you can pipe things at it as well as calling it with a filename to translate. I find the "text filter guts" very useful for building other simple text filters. Of course, "rot13 file | rot13" just types out the original file, so you can be silly with it, too, if you're so inclined. :) program rot13; type line = string[120]; var buf: line; function rot13 (inp:line): line; var count: integer; begin for count := 1 to length(inp) do case inp[count] of 'A'..'M', 'a'..'m': inp[count] := chr(ord(inp[count])+13); 'N'..'Z', 'n'..'z': inp[count] := chr(ord(inp[count])-13) end; rot13 := inp end; begin if paramcount > 0 then begin close (input); assign (input, paramstr(1)); {$I-} reset (input); {$I+} if ioresult <> 0 then begin writeln ('Error opening ',paramstr(1), ' as input: aborting'); halt end end; repeat readln (buf); writeln (rot13(buf)) until eof (input) end. ------------------------------------------------------------------- Dave Rutherford Michelangelo H. Jones DGR0093@RITVAX.BITNET -------------------------------------------------------------------