Skip to main content
7 of 13
being a grammar nazi
Victor Stafusa
  • 8.8k
  • 5
  • 40
  • 61

Trolling homework questions - sorting

I am intending to make this a new category of programming puzzle (let's call it ""). So you could expect this to be the first question of the series.

The idea of this category is:

Suppose that some lazy guy in StackOverflow or elsewhere, asks a homework give-me-dah-codez question. Your task is to give code that works, but is still useless, severely frustrating the OP.

This could be achieved by:

  • Deliberately misinterpreting the question and giving code that clearly answers what the OP asked, but does something different than what he intended.
  • Giving code that runs in superexponential time or worse, when the trivial solution would be linear or better.
  • Introducing something extremely unacceptable or unreasonable in the code that cannot be removed without throwing everything away, rendering the answer utterly useless for the OP.
  • Writing code that is a direct and plain cheat on the question.
  • Being a creative troll.
  • Being evil.

In your answer, you should briefly explain what you are doing to troll the OP.

Furthermore, we have one restriction: The chosen language should not be the sole reason to troll the lazy OP. Otherwise, you could just plainly encode the correct solution using brainfuck, golfscript or some language that is clearly a crazy, unexpected or unusual choice for the problem, but this would ruin the intention of this as everybody would do that. The intention is to write the homework in a language that the lazy OP might think acceptable, but still frustrate him.

Now, for the actual first question in this category, the hypothetical lazy OP asks:

I need a program where the user inputs an array of doubles and the program outputs the array sorted. Could you please give the code?

The winner is the most upvoted answer, except if the answer is somehow not eligible (in that case I will drop a comment). If the previously most upvoted answer is beaten in the future in the number of upvotes after being accepted, the new best answer is accepted and the previous one is unaccepted. In the case of a tie, I will choose the winner at will among the tied ones or just wait a bit more.

EDIT and EDIT 2: Clarification about the choice of programming languages.

Further EDIT: Answers that have no code are not eligible. They might be fun and get some upvotes, but won't be accepted.

Victor Stafusa
  • 8.8k
  • 5
  • 40
  • 61