Here we offer some advice on how to keep out of trouble. We're assuming that you want to avoid committing an offence, and trying to help you with this goal.
This is a longish page, so here is a list of the major headings:
The university's writing services offer advice on How Not to Plagiarize. That advice has a similar purpose to ours, but it's intended for the essay-writing context, not the programming context that we're mainly interested in here.
Since the academic offences we're concerned with here involve wrongly trying to get credit for someone else's ideas or code, there are two basic defences:
The whole point of education is the transmission of ideas, and one of the best ways of being sure you have those ideas straight in your own mind is to discuss them with others. Those others will initially be teachers such as course instructors and tutors, but for a really effective and memorable education, you need animated discussions with your friends.
Obviously, we don't want to keep you away from your education, but there comes a point where an animated discussion of an algorithm or data structure or mathematical analysis drifts into the solution for your current assignment, with the exact algorithm required and the details of the code to be used in the program you have to hand in.
If you find yourself drifting across the boundary between learning (good!) and getting someone else's assignment solution (bad!), here are some things to do.
Talk about the class of algorithm or data structure in general, rather than the specific one in your assignment. "In general" is hard to achieve, so what this really means is discussing some other example or problem instead of the assignment. Get an example from your class notes or a new problem from your text, and try to solve that.
Or your instructor may be able to suggest a problem you and your friends could work on safely, as practice on something relevant that won't lead you into an academic offence.
Don't write anything down, even if you're just discussing a related example instead of the assignment. Think hard about the topic, but keep it to thinking.
Of course you'll want to write things as you talk about them, but don't keep the notes. Later, when you return to the problem on your own, you'll have to work from what you remember, and you'll naturally re-write things in your own way.
Taking your partly-formed ideas and turning them into functioning programs is an important part of learning. If you make your code work on your own, you really learn to program well.
Running into program bugs is not an annoyance that you'll grow out of. It happens to every programmer all the time, and we all learn from it. When you've just started programming, bugs are especially valuable: they point out where your understanding is weak, the error messages teach you to read carefully (a common need for new programmers), and fixing your bugs makes you feel incredibly smart.
But sometimes you just can't. To offer advice on bug fixing takes us outside the purpose of this web site, but we need to tell you where to go for help. Ideally, you should go to your course instructor's or tutor's office hours; they're probably better at resisting the temptation to re-write your program for you than your friends are, and getting help from them is guaranteed not to be an academic offence.
If you must ask for help elsewhere, then don't show anyone your actual program. Instead, take an extract from the program -- a very short extract that illustrates the problem you've run into. Ensure that the short extract doesn't embody your solution to the whole assignment, so that your friends can help without getting anyone into trouble.
A "short extract" is shorter than you think. Often you can isolate your troubles to only ten lines or so, and even a complicated coding problem can almost always be illustrated in fewer than fifty lines of code.
We're going to be really unhappy if we see your solution in the course newsgroup, and sending a program to someone by e-mail is generally considered a very strong indication that an academic offence is taking place.
Suppose you do have a detailed discussion of an assignment with someone. You throw out your notes, but you vividly recall what you were talking about. If you start writing your own solution now, you'll inevitably be using the shared solution.
So don't start now. Wait at least a few hours, and spend the time thinking about something else. Some professors recommend watching television for at least an hour, but we bet you're too busy for that; so work on your English essay or your problem set for your mathematics course instead. If it's late at night, wait until the next morning.
Waiting can actually help. You'll find that your brain is beavering away underground on the problem, and it's likely to throw up answers at the oddest times. In fact, this is the major reason why you shouldn't do your assignment at the last minute: it takes away your chance to think of things yourself.
(Yes, in computer science, beavers work underground.)
Suppose you have a working solution, and your friend doesn't. "Let me use your solution," he says, or maybe, "Just let me look at your solution." Later, your course instructor says, "What made you give him your solution?" You answer, "He's my boyfriend [or my brother, or my old friend from school], and I had a duty to give it to him."
No, you didn't, and you committed an academic offence. He'd have gotten at least part marks for a partial solution, and if he doesn't figure it out for himself, then he's not learning from the assignment and he's going to do worse on the test and exam.
Instead, try answering your friend, "I'm afraid we would get caught," or -- if you have time -- "Tell me what's the problem." (Not "Show me"!) And remember, both of you are in trouble if your friend is found copying from you.
One instructor reports checking on the performance of twenty pairs of students whom he suspected of cheating but hadn't had time to interview before the end of the course.
He discovered that one of each pair failed the course, and the other did just fine.
Now, this report may be a little exaggerated, and anyway one wouldn't expect such a striking result to be reproduced in every case. But it does show that not just that cheating is detectable, but also that cheating doesn't help. If you feel the need to cheat, what you really need is legitimate help and considerable work put into working out your own solutions. Don't endanger your friends' progress by asking them to help you do something that won't work anyway.
If you think you've received too much help from someone else, but you want to see what mark your work would get anyway, then by all means hand it in -- but write clearly on everything that you hand in that you had help. It's not an offence if you don't claim it's your own work.
Of course, your mark will be reduced, and might be as low as zero, but you'll have your work evaluated, and you won't find yourself talking to an instructor who suspects you of an offence.