[net.puzzle] three spies

rainbow@ihuxe.UUCP (Rob Buchner) (10/15/83)

The King has just summoned you into his chamber along with his other two top
spies. He says he has a special assignment of utmost importance for one 
person. He has summoned you three and must now determine which of you is the 
most worthy. He says that he has five hats, 3 are black and two are white.
One hat is placed on each persons head leaving two unidentified hats left over.
The question now is to determine which color hat you have on your head. If you
guess wrong you will be beheaded. If you guess right and succeed in your spy
mission, fame and fortune will be yours. The King asks the first man. The 
first man thinks a little and says he cannot tell. The King asks the second
man and he also cant tell. Now the King asks you what color is your hat.
You of course reply with the correct answer even though you are blind and the
others arent. What color hat did you have on?

klutz@ihuxl.UUCP () (10/16/83)

1) If the first man knew, both of the other two spies hats would be
   white; therefore, they are not both white. (They were either
   half and half or both black)

2) Thus, if the second man sees a white hat on the third man, his
   would then be black. But he didn't know.

3) Therefore the third man knows his hat is black.

			Sherwin Clutter
			AT&T-BL - Naperville, IL
			ihuxl!klutz

rcj@burl.UUCP (R. Curtis Jackson) (10/19/83)

Come on, people -- don't post the answers to the net in decrypted
form!!  Give everyone else a chance to solve it.

If you must show off your knowledge, do it rot 13.

BTW, I would advise (to cut down net traffic and save everyone's
phone bills) that the submitter of each puzzle include the
answer (rot 13, of course) with the puzzle to keep people from
clogging the net with 27 correct solutions to each puzzle.

Thanks for your time and consideration,
-- 

The MAD Programmer -- 919-228-3814 (Cornet 291)
alias: Curtis Jackson	...![ floyd clyde ihnp4 mhuxv ]!burl!rcj

rtf@ihuxw.UUCP (10/19/83)

curtis,

	what the hell is "rot 13" ???????

				ignorantly yours,
				sparrow

rcj@burl.UUCP (R. Curtis Jackson) (10/19/83)

I have had three people ask me what rot 13 is, so I decided
to (once again, for you net.jokes readers) explain:

rot 13 is a method of encryption that is used to hide things from
those who might not want to see them.  Offensive jokes on the net
are encrypted in this manner so that only those who want to read
them have to do so.  It is accomplished by adding 13 to the ascii
value of each letter; this addition of 13 is wrapped around within
each of the two (upper and lower case) character sets.  For instance,

'c' + 13 ==> d e f g h i j k l m n o = 'p'
'T' + 13 ==> U V W X Y Z A B C D E F = 'G'
etc.

Here is a program that reads stdin and outputs stdout; it will encrypt/
decrypt any rot13 text.  Because it is a filter, it can easily be used
at the '?' prompt of readnews with the 's' option:

? s | rot13

It will take an argument for the rotation value -- but the default (and
the standard for netnews, because it is easily reversible) is 13.

NOTE:  IF YOU ARE RUNNING ONE OF THE NEWER VERSIONS OF NEWS (I BELIEVE
IT IS 2.10 AND UP), YOU CAN TYPE AN UPPER-CASE D ('D') TO THE '?' PROMPT
OF READNEWS, AND IT WILL DECRYPT ONLY WHAT IS ENCRYPTED WITH ROT 13
AUTOMAGICALLY.  It does not always work correctly, though; so you may
have to back up with a '-' ('D' option does not accept a '-' modifier
like 'f' and 'r' and 's'), then type 'D 13' to the prompt and it will
perform the same function as the program below.  Note that the 'D'
option is NOT like the 's' option; you can save an article with 'D', but
you lose the header and the only way to do it is 'D > filename'.
====================================================================
/* program to rotate the upper and lower case ascii character set */

#include <stdio.h>
#include <ctype.h>

main(argc,argv)
	int argc;
	char *argv[];
{
	int c;
	int rotation;

	if (argc > 1)
	{	if (sscanf(argv[1],"%d",&rotation) != 1) exit(1); /* bad conversion */
	}
	else rotation = 13;
	while (rotation<0) rotation += 26;

	while ( (c=getchar()) != EOF ) {
		if (isupper(c))	{
			putchar('A'+ (c-'A'+rotation) % 26 );
			}
		else if (islower(c)) {
			putchar('a' + (c-'a'+rotation) % 26);
			}
		else putchar(c);
		}
}

-- 

The MAD Programmer -- 919-228-3814 (Cornet 291)
alias: Curtis Jackson	...![ floyd clyde ihnp4 mhuxv ]!burl!rcj