It is spectacularly easy to cheat on CS labs at the high school level and above (roughly ages 14 and up), particularly on short, early assignments. In fact, there is article in today's NY Times about this problem.
For instance, for a very early assignment, a question might be:
Create a small program that will ask the user for a word and a number n, and responds by printing out the word n times.
This is a rather extreme example, but it could easily be the first part of a lab assignment for a student who has just encountered for loops for the first time.
Detecting cheating here is nonsensical because a huge portion of the resulting code will be nearly identical even if the students didn't cheat. For that reason, I am seeking ways to discourage students from trying to cheat in the first place.
What are some best practices for staving off the flow of plagiarism?