A Self-Reproducing Program

February 20, 2009

Write a program that takes no input and generates a copy of its own source text as its complete output.

Pages: 1 2

The Digits of Pi

February 20, 2009

The ratio of the circumference of a circle to its diameter is given by the constant known by the Greek letter pi, and is an irrational number (its representation is non-terminating and non-repeating) with a value slightly larger than 3.14159. What is the one-thousandth digit of pi? (Counting begins at zero, so the zeroth digit of pi is 3 and the fourth digit of pi is 5.)

Pages: 1 2

Multiple Dwellings

February 20, 2009

Baker, Cooper, Fletcher, Miller and Smith live on different floors of an apartment house that contains only five floors. Baker does not live on the top floor. Cooper does not live on the bottom floor. Fletcher does not live on either the top or the bottom floor. Miller lives on a higher floor than does Cooper. Smith does not live on a floor adjacent to Fletcher’s. Fletcher does not live on a floor adjacent to Cooper’s. Where does everyone live?

Pages: 1 2

ROT13

February 20, 2009

From the Jargon File:

rot13 /rot ther’teen/ /n.,v./ [Usenet: from `rotate alphabet 13 places'] The simple Caesar-cypher encryption that replaces each English letter with the one 13 places forward or back along the alphabet, so that “The butler did it!” becomes “Gur ohgyre qvq vg!” Most Usenet news reading and posting programs include a rot13 feature. It is used to enclose the text in a sealed wrapper that the reader must choose to open — e.g., for posting things that might offend some readers, or spoilers. A major advantage of rot13 over rot(N) for other N is that it is self-inverse, so the same code can be used for encoding and decoding.

Write a function that takes a string and returns the ROT13 version of the string; you may assume that the character set is ascii. What is the meaning of “Cebtenzzvat Cenkvf vf sha!”

Pages: 1 2

Follow

Get every new post delivered to your Inbox.

Join 611 other followers