Wikipedia:Reference desk/Archives/Computing/2011 July 6

= July 6 =

10-line C++ program that would change the world
I'd like a sample 10-line C++ program that could change the world (you don't have to include the part that would change the world). the point is, there would be one part, maybe inside the loop, that's ?????, and then I would just figure out that one part to change the world. any takers? 188.29.111.138 (talk) 23:40, 6 July 2011 (UTC)


 * note: it has to be possible. 188.29.111.138 (talk) 23:41, 6 July 2011 (UTC)


 * Sure, just say what in the world you want changed. Shall we sit very still while you debug the code? You are really asking for the power of Aladdin's jinni (genie). The jinni met a blonde and offered her one wish that could be literally anything in the World. Blondie responded "I want Gucci sunglasses!". The jinn replied "Of course I can give you that. But don't you want to use this unique opportunity to remove all the hunger, war and suffering in the World?". Blondie replied "Yes, I'll do that instead. Let's have Gucci sunglasses for everyone". Cuddlyable3 (talk) 23:58, 6 July 2011 (UTC)


 * Strictly, I think the ANSI standard for C++ requires a newline at the end of the file; but that would make this program 11 lines. Fortunately, most modern C++ compilers are not so pedantic; this compiles in g++ and in XCode.  In case it is not obvious, theWorld is changed on line 7.  Nimur (talk) 00:46, 7 July 2011 (UTC)
 * Put the newline at the end, get rid of  (  is usually a bad idea anyway &mdash; why have namespaces if you're not going to use them?), and use  .  --Trovatore (talk) 02:20, 7 July 2011 (UTC)
 * Honestly! You have a chance to change the world in any way you want, and the best you can do is to increment it? 188.29.86.142 (talk) 00:53, 7 July 2011 (UTC)
 * My change to theWorld is merely incremental. I've made peace with that.  But of course, you still have the opportunity to change line 7 to anything you like, as you said you were going to.  All you have to do is "just figure out that one part"... Nimur (talk) 01:23, 7 July 2011 (UTC)
 * I took the liberty of removing your highly offensive "theWorld++;" in the middle of the program, replacing it with // ??? per your indication. I mean, come on.  The world - the real world - already gets incremented in the main loop, namely the number of nanoseconds, without anyone doing anything.  Hopefully we could make a more fundamental change.


 * I suspect I could turn it back-to-front in 10 lines. I'd like to be able to turn it upside down though, which might be harder. AndyTheGrump (talk) 01:01, 7 July 2011 (UTC)
 * Thinking further, the Bible tells us that in the beginning the World was without form and void - presumably a null pointer. I think that what is required is to make theWorld point to an instance of class World. (Though personally, I suspect that the Creator programs in Java...). AndyTheGrump (talk) 01:38, 7 July 2011 (UTC)

And, not to be flippant guys, but I meant actual code that would actual do something. For example:

void SUPERquickSort(int arr[], ???) { int i = ???, ??? ???     /* recursion */ if ??? SUPERquickSort(arr, ???); if ??? SUPERquickSort(arr, ???); }

Would be the PERFECT example of what I'm asking about... before 1960. That's because quicksort was invented in 1960, so if it were before 1960 now, then I could fill in the ???'s in the above to get quicksort. You see how that works? So, please give me the same thing that I can use today to change the world, just by filling in the ????'s. Ten lines or fewer. Thank you! 188.28.246.47 (talk) 02:19, 7 July 2011 (UTC)
 * OK, you've answered your own question. Invent a sorting algorthm that's faster than quicksort.
 * But since you asked, here's one I'd like to see :
 * APL (talk) 02:39, 7 July 2011 (UTC)
 * APL (talk) 02:39, 7 July 2011 (UTC)


 * Thanks! I marked this resolved. 188.28.246.47 (talk) 02:57, 7 July 2011 (UTC)
 * p.s. don't get your hopes up - I meant the thread! 188.28.246.47 (talk) 02:58, 7 July 2011 (UTC)


 * Perhaps you would be interested in List of unsolved problems in computer science? I think it is generally agreed that a significantly faster Integer factorization algorithm would have far-reaching implications. 130.88.73.71 (talk) 14:13, 7 July 2011 (UTC)