home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Powerdrive 1997 February
/
POWERDRIVE0297.ISO
/
share
/
rollen
/
nethack
/
misc
/
nhdecode.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-12-13
|
1KB
|
37 lines
#include <stdio.h>
/* nhdecode.c Latest update: Wednesday, April 13th 1994.
* Creator: Boudewijn Wayers (wsbusr1@urc.tue.nl).
*
* This program reads from the standard input and writes on the
* standard output.
* It takes the (encoded) "rumors" or "oracles" file as input and
* decodes this file.
* No looking at the sources! Just a glimpse of the rumors file and
* half an hour of trying was enough to construct the encoding /
* decoding algorythm.
*
* PS: The following line does the same as the above program:
main(){int _,l=0;while((_=getchar())!=-1)l=_=='\n'?putchar(_),0:(putchar(_^1<<l),++l%5);}
* I couldn't quite fit it on one line, but if someone can, please mail
* me the result, will you? For some reason, changing putchar to putc
* gives a "Bus error". Changing '\n' to 13 would make the program
* incompatible across machines.
*/
main()
{ int char,counter;
counter = 1;
while ((char=getchar()) != EOF)
{ if (char=='\n')
{ putchar(char);
counter = 1;
}
else
{ putchar(char^counter);
counter *= 2;
if (counter==32) counter=1;
}
}
}