To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.off-topic.geekOpen lugnet.off-topic.geek in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Off-Topic / Geek / 1995
1994  |  1996
Subject: 
Programming Brain Teaser
Newsgroups: 
lugnet.off-topic.geek
Date: 
Thu, 7 Sep 2000 01:00:57 GMT
Viewed: 
112 times
  
Hey Y'all:

Someone posed the following teaser to me, and I admit that it has stumped me
completely.  It has even stumped my programmer buddies (which creates doubt in
my mind that there IS actually a solution to the puzzle).

The question was posed thusly:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
What line of code written either in C, C++, or Perl will compile written
forward as well as backwards?  The following was submitted as an example of
the FORM of the answer, while not itself being the answer:

print "abcdefghijklmnopqrstuvwxyz";

;"zyxwvutsrqponmlkjihgfedcba" tnirp

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
And again, it was asserted that both statements would compile.

-- Richard (scratching his head)



Message has 4 Replies:
  Re: Programming Brain Teaser
 
(...) it doesn't have to actually produce anything, right? try this: perl -e 'print ,"lalal", tnirp' e- lrep :) I seem to recall some JAPH's code that would actually do things and would still qualify... but I can't find it yet... :) Dan (24 years ago, 7-Sep-00, to lugnet.off-topic.geek)
  Re: Programming Brain Teaser
 
(...) Does the code need to compile in all of those, or just some of them? It's really easy in perl. :) Does it have to compile by itself, or can it be part of a larger program? The former is more difficult in C/C++... Also, what qualifies as a (...) (24 years ago, 7-Sep-00, to lugnet.off-topic.geek)
  Re: Programming Brain Teaser
 
(...) #include <stdio.h> #include <stdlib.h> #include <time.h> void rof(void) {}; void main(){ int C; C = 0 // line below ; for (C;C;C) rof; // Ok so its lame } // Should be valid in perl too, but I am not sure. Just an off the cuff answer. DaveG (24 years ago, 7-Sep-00, to lugnet.off-topic.geek)
  Re: Programming Brain Teaser
 
(...) Well the obvious answer is ";", but that's a bit too simple. I can't think of anything else that doesn't involve several variable and/or function definitions elsewhere. (24 years ago, 7-Sep-00, to lugnet.off-topic.geek)

19 Messages in This Thread:







Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR