It's considered poor form to get the internet to do your homework for you. 99 per cent of these requests are ignored or deleted with impunity, but when one slips through the cracks, well, the results can be strangely hilarious.
Homework Question: How do I write a program that produces the following output? Smile!Smile!Smile! Smile!Smile! Smile! Have the program define a function that displays the string Smile! once, and have the program use the function as often as needed.
Now, even to the novice programmer, the solution is straightforward but as well all know, forums such as Quora and StackOverflow don't look kindly upon those that want others to do their work for them.
For whatever reason, the question wasn't deleted and rather than sinking into electronic obscurity, it took on a life of its own as creative coders took turns coming up with ridiculous responses. The original poster didn't specific which language they wanted the answer in, so, it got funky fast.
The C# System.Random.next() method will return a random number between 0 and 2,147,483,6467 (which is 2 to the power 31, minus one). The unicode value for the S is 83, so all we need to do is pick random numbers between 0 and 2.1 billion until 83 pops up, then move onto m... It takes a few guesses to find the correct numbers, on testing between 77 billion and 107 billion numbers picked and discarded to get the right 38 characters to display.
That's just the tip of the iceberg. From replies in SQL, to others in HTML / CSS, MEL (Maya) and even lambda calculus and LOLCODE, there's something for every software engineer.
Originally published on Gizmodo Australia.