Very nerdy Xmas solution

---------- Forwarded message ----------
Date: Wed, 8 Dec 1999 00:38:02 -0800 (PST)
From: Dan Lyke
To: John Aldrich
Subject: Re: Fwd: [OT] Christmas Present Mystery

On Tue, 7 Dec 1999, John Aldrich wrote:

This is TOO strange! Any ideas how it works???? I compiled it as a
"user" and it worked just fine (hint: "On the first day of
Christmas...." )

Cute.

Search for '"' and you'll find two strings (backslash escaped to span lines). It sets up a state machine to decode the first using matching against the first 32 bytes of the second string to index the second 32 bytes. I've broken the second string in the program below to show this match, and included two loops that decode the first string.

From here it should be trivial to put your own strings back in...

Ya know, sometimes I wonder what would happen if I stored *useful* information in those neurons...

Anyway (and yes, this one's safe to run in user space...[grin]):


#include 

char *s1 = 
"@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l,+,/n{n+,"
"/+#n+,/#;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l q#'+d'K#!"
"/+k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d}rw' i;# "
"){nl]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#n'wk nw' "
"iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/*de}'c ;;{nl'-{"
"}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;#'rdq#w! nr'/ ') }+}{rl#'{n' ')"
"# }'+}##(!!/";

char *s2 = 
"!ek;dc i@bK'(q)-[w]*%n+r3#l,{}:"
"\nuwloca-O;m .vpbks,fxntdCeghiry";

int main(int argc, char **argv)
{
int i, j;

for (i = 0; s1[i]; i++)
{
if (s1[i] == '/')
	      printf(" / ");
else
{
for (j = 0; s2[j] != s1[i]; j++)
{
}
putchar(s2[j + 31]);
}
}
return 0;
}

Wednesday, December 8th, 1999 danlyke@flutterby.com