In a programming in-class test, one of the problems was to write up a certain famous program in Maple. However, I had already written up this program prior to the test just as a hobby, and it was in a folder on my desktop [we were using our own laptops, no internet access]. I just copied that code into a new file, cleaned it up, and uploaded this file to the course website. I left an hour before anybody else [the exam lasted 2 hours, and I sat around pretending to be busy for 45 minutes before I left the class and went to the canteen].

Question: Is this cheating? Self-plagiarism? Have I done anything wrong here? Should I admit this to my TA?

  • 46
    If the rules of the test allow you to use any material you have offline on your laptop, then how could this be cheating? But it seems strange to me, allowing use of arbitrary offline information and then asking to reproduce something which is famous and thus has probably been solved thousands of times and could likely be in someone's collection of offline information.
    – Nobody
    Commented Nov 11, 2016 at 20:30
  • 57
    This really depends on the specific rules set for the exam. Allowing students to use their own laptops without internet access, in my opinion, would imply that you are free to use code/material you already have on your computer but not online content. It is possible that the test designer wanted to reward students who were well prepared, but didn't really anticipate that someone would have solved the exact same problem before. If this is the case, I'm inclined to say that you did not cheat. Commented Nov 11, 2016 at 20:45
  • 74
    @CaptainEmacs: Self plagiarism on an exam is an absurd concept.
    – Buzz
    Commented Nov 11, 2016 at 21:49
  • 33
    For future reference, and for others reading: if you have an exam like this, make sure you are clear in advance whether you are allowed to collect materials on your computer for use on the exam, or whether this is forbidden. That way you wouldn't have to ask this question. Commented Nov 11, 2016 at 22:19
  • 35
    My recommendation is not to say anything unless asked. There are really some idiotic professors out there that accuse students of cheating instead of taking responsibility for poorly designed tests. Commented Nov 12, 2016 at 3:13

11 Answers 11


I would say no, unless this was explicitly prohibited beforehand. Look, what's the purpose of a test? To gauge the extent to which one has comprehended the material. The fact that you did the work indicates you do. Hell, the fact you did it on your own for fun deserves recognition.

What's the point of re-doing the work while sitting in class during a test? Worse yet, suppose you did and made a mistake due to nerves/time pressure. You still did and comprehended the material, thus you pass.

Others will disagree, but in my mind, I just want to know if you do or do not understand the material.

  • 17
    I agree OP didn't cheat. But if the test is curved, this setup gives OP an unfair advantage over a hypothetical student who had previously solved the problem but didn't have the code handy.
    – user37208
    Commented Nov 12, 2016 at 23:11
  • 16
    @user37208, that is not the student's problem. It's not the student's responsibility to gauge how well prepared the other students happen to be. He solved a problem that happened to be on the test beforehand. To me that shows initiative. Maybe he just got lucky. Either way, he's not to blame. Nothing for him to feel guilty about. The other students could have done the same thing. Commented Nov 13, 2016 at 9:47
  • 11
    There is, however, a big difference between "I solved this in my spare time and am now reproducing my solution from memory" and "I am submitting the solution I wrote up previously, possibly written with the aid of reference material I do not have access to during the exam."
    – chepner
    Commented Nov 13, 2016 at 21:09
  • 3
    @chepner He would have had access to the reference material as well since he can use his own laptop. Commented Nov 14, 2016 at 4:29
  • 3
    @user7019377 Note that he said "no internet access".
    – AlexC
    Commented Nov 15, 2016 at 9:46

In general, the rules and norms of a test - what is expected, what sources can be evaluated, if any, etc - should be known before the test is taken. This usually takes the form of a syllabus or verbal instructions at exam time.

A typical set of norms is along the lines of: open book, open notes, no cooperation; closed book, open/limited notes (like 1-page hand-written sheet, or index card, or "anything that fits on a letter-sized sheet", etc); closed book, closed notes; and so on. In an electronic lab, there is usually also a policy on general internet use, and you noted no internet access - so obviously some rules and norms were in place.

These rules and norms are what makes fairness and useful evaluation possible in the academic context. If no one cared when or how you did the work, then of course the rules would reflect that; if people do care specifically to know how, when, and/or who did the work, then the rules are made to reflect that. We don't know what rules were in place at the time, but as a student it's your job to find out what they are - and if you don't know, ask as early on as possible so there are no possible misunderstandings.

I will close with my general advice on all matters of honesty: if you feel like you need to hide it, you should think very carefully about what exactly it is that you are doing. If you pretended to be busy during the exam so it didn't look like you finished impossibly quickly, that suggests that at the time you thought something was fishy - or ambiguous - about what you were doing then.

In the future you should ask in advance what the rules are if you don't know them, and if an unexpected scenario comes up - ask the person in charge right then!

I cannot really offer advice on what to do now, though, as that is going to be a pretty personal decision. If you have a good relationship with the teacher I'd especially advise you to contact them to talk about the issue, noting how you thought it wasn't against the rules but now you are concerned that you should have said something at the time and had no idea that the solution you had - which was your work in full - was going to be on the test.

As a final note, if you wonder why using the solution might not have been allowable: the solution you had was not completed in a verified time limit, and you obviously would have had access to the internet, other people's potential help, etc, in preparing your solution. No other students had such an opportunity, so when the person is grading it would certainly not be fair for other student's work to be compared to yours when your work was not prepared in the same environment (and the grader has no idea you had advantages the other student's did not have in the exam).

Ultimately how you handle the current (past) situation is up to you, but I hope in the future that you'll act differently so you don't end up in such an uncomfortable position - when in doubt, ask.

  • 6
    I disagree. Answering an exam question log before it is asked is the consummate mark of the person who will invent the next world-changing paradigm shift. Fearing to violate unwritten phantom "rules" and "norms" and fretting about "ask[ing] in advance" are the defining attributes of his potential lackeys. Commented Nov 12, 2016 at 16:32
  • 23
    @A.I.Breveleri That's basically the base rate fallacy - or to use a saying, "They laughed at Einstein...but they also laughed at Bozo the Clown." For 6-7+ billion people, there are a handful of world-changing outcomes per generation (base rate). The vast majority of people who ignore rules and normative ethics do not fare well in society, finding themselves made suspect, reprimanded, fired, outcast, or jailed. Successful "self-actualized" individuals who are willing to be contrarian do so to a tiny amount of all social rules, in a tiny amount of situations - and they choose very carefully.
    – BrianH
    Commented Nov 12, 2016 at 17:41
  • 5
    This is completely false... The professor allowed laptops to be used... obviously offline materials were allowed, otherwise why would he allow this situation to occur? It's not the student's job to read the professor's mind. The professor is responsible for the uncomfortable situation and he's the one to be blamed if anyone is to be blamed. Lazy professors creating ambiguous scenarios... if they thought a little they could avoid these situations. Commented Nov 13, 2016 at 9:21
  • 2
    @AmeetSharma Ambiguity and the need for mind-reading can be easily resolved by just asking - resolves the need to guess. Anyone in charge should certainly make the rule clear, but my answer is focused on being pragmatic - the professor almost always has very little to lose in a situation like this, where you as a student have all the risk in a misunderstanding. Blaming others can make one feel better, but it doesn't necessarily protect you - especially when there is a large power differential, as there is in a case like this, where complaints can fall on deaf ears. Better 'ask' than sorry.
    – BrianH
    Commented Nov 13, 2016 at 16:30
  • 2
    Sometimes I'll pretend to be busy after finishing an exam early just so I'm not the first person to leave. No fishy behaviour involved. Commented Nov 13, 2016 at 23:56

One important distinction here is that when writing software, it isn't the actual writing that's the time consuming part, it's the thinking and verifying that your solution does what it's supposed to.

No matter what else, you've already done this. In this context it wouldn't take you half-again as long to write it from scratch compared to your classmates that haven't, even if you didn't reuse any of your actual code. That is not your problem.

Every experience we get and project we do gives us the resources to solve problems we are faced with. The only thing that may be an issue here is whether or not you should have copied your previous code, or written it from scratch as all your classmates did for a more fair comparison. We can't really answer this, as it is dependant on what rules your college / university / class set.

If you feel nervous about this, bring it up to your TA or professor as a question for the next exam:

If we get a problem that I've solved on my free time, can I reuse that solution?


They allowed you to use your laptop. Were offline materials (pdfs, notes) prohibited? If not, you IN FACT did not cheat, regardless of what anyone else may say.

This is no different than a situation which I experienced multiple times when working on my CS degree, where well-known code-golf/basic theory questions were asked and I had already seen them. That's just good fortune, there's nothing to do but enjoy it.

And, regardless of the ethical contortions you might go through to conclude that you acted wrongly, don't turn yourself in. Academic disintegrity is taken very seriously and depending on who received your admission, a series of needless escalations later, you could find yourself at the business end of an uncaring and unthinking bureaucracy.

  • 2
    Indeed. The instructor was naive enough to let students use their own laptop. Further, any programming student who is serious enough in their studies is likely to have code snippets on their personal machines developed from their own studies of how to solve common programming problems. Bad assessment vehicle plus naive instructor equals well-prepared student gets to sleep at night.
    – Mad Jack
    Commented Nov 13, 2016 at 2:52

Yes, this is cheating.

Imagine it was a hard problem that you set out to solve on your own time at home. You would not be under any time pressure to solve the problem. You would have any resource you wanted to research and solve the problem--textbooks, google, etc... You then work on the solution, find bugs, refactor, and come to a final working solution.

Now, during the test you simply cut and paste your solution and you're done in 60 seconds on a 2 hour test. Since you intuitively know this is wrong you fake working for 45 minutes until boredom overcomes you and you leave.

The proper thing to do, would be to derive a solution given what you already learned working on the problem at home. If this were not the intent of the test, it would have been a take home test with lenient deadlines.

It's rather appalling that the most upvoted answers here seem to think this behavior is ethical.


To solidify my argument, consider the following scenarios:

  1. Your professor assigns you a homework assignment during the semester. At the end of the semester he puts the same problem on the exam. You pull out your homework during the exam and transcribe your answer word-for-word.

  2. You write your program at home. Anticipating various programs will be asked for on the exam you transcribe your programs to little pieces of paper. During the exam you pull out the hidden paper and transcribe the solution for the exam word-for-word.

  3. No internet access is allowed. Therefore, you write a web scraper to download all of StackOverflow's content to your personal laptop for offline use. During the exam you reference your local copy of SO.

The crux of the ethical argument, hinges on the intent, or spirit, of examinations. It seems as if many people are simply arguing for technical loopholes to avoid the actual intent of the examination for personal advantage.

The spirit of an exam is to test your mastery of the material and to see how you can regurgitate and apply that information under time-limited conditions. The method of copy and paste violates the spirit of the exam.

  • 13
    I studied for my history test beforehand. When I got to the part on who won the Civil War, I memorized "The North". I put that down on my test, because I worked out beforehand that it was the correct answer. That is not cheating.
    – krillgar
    Commented Nov 14, 2016 at 12:41
  • 2
    Covered in paragraph 4--"the proper thing to do." Most people don't have cut-n-paste loaded into their brain. The point of a test is to see if you can regurgitate and apply concepts you have learned (from your brain). A test is not a semester long project, where you just paste the solution you worked out beforehand. An anecdote (even a real one) is not a valid ethical argument. You have an excellent memory, congratulations; not the point of the test. Why not just type up the answer before hand, bring it in on a separate hidden sheet of paper, and copy the answer down?
    – James
    Commented Nov 14, 2016 at 14:27
  • 1
    @TechMedicNYC Most people don't have cut-n-paste loaded into the brain. But if given the opportunity to to prepare notes several people might have implementations of specific algorithms written down.
    – Taemyr
    Commented Nov 15, 2016 at 14:51
  • 1
    @Taemyr They would still have to translate that algorithm to actual, runnable code here. No matter how you slice it, unless existing solutions to problems already stored on your computer are explicitly allowed (and can you really imagine a professor allowing the full contents of your hard drive? Every open source project you've checked out or HTML page you have cached?), it gives the OP some unexpected, unfair advantage to simply copy a fully working and tested solution.
    – jpmc26
    Commented Nov 16, 2016 at 6:00
  • 1
    @jpmc26 they where allowed to bring their private pc to the test. That suggests that the contents of the hd was allowed.
    – Taemyr
    Commented Nov 16, 2016 at 7:54

No this is not cheating in any way. If the professor allowed laptops to be used, then obviously offline materials were allowed. Otherwise he would have given explicit instructions to the contrary. It is not the student's job to read the professor's mind and second guess his own actions. All a student can do is follow the rules set, and that's what you did here. It is not the student's responsibility to gauge what's "fair" and "unfair" in the middle of a test.

What if I learned a shortcut method of solving a problem... a method that wasn't discussed in class, and I use that to get an answer to an exam problem, and nobody else does. Have I cheated? I had an "unfair" advantage. Should I be punished? Makes absolutely no sense. To consider this cheating is getting into loony territory.

What if I find an online resource that explains material better than the text we use in class? I have an "unfair" advantage now. Am I cheating?

  • "then obviously offline materials were allowed" This does not follow. Professors are as human as the rest of us, and as such they make mistakes.
    – Taemyr
    Commented Nov 15, 2016 at 14:52

Unless it was an open-book test, yes, you cheated.

  • 3
    @immibis The OP didn't just use "information saved on his laptop". He used the solution saved on his laptop. Given that in some exams the time constraint is used as a way to see how well the students understood the subject and sometimes even their ability to work under pressure (i.e. the average student wont complete 100% of the test perfectly in X hours, but will do so in, say, 2X hours) by reusing a solution he had already written he basically extended his exam time by a lot. Given that he had already done that task even starting from scratch he should have had already a big advantage.
    – Bakuriu
    Commented Nov 12, 2016 at 8:23
  • 8
    I downvoted because the reasoning is not sound. If a student has an eidetic memory, a resource which other students clearly do not have, is he prohibited to use this to his advantage to immediately write down the answer because it was already repeated earlier ? If a student does immense work in preparation and solves questions to train it and the same question is asked in the test and he writes down the answer, did he cheat ? Nobody forced the asker to do this on his own free time. So as long as the rules of the exam explicitly do not allow to reuse a solution, I do not see a violation. Commented Nov 12, 2016 at 15:40
  • 3
    @ThorstenS. Oh please. This is not reusing a solution. This is evading the conditions of examination that every other student in the course had to abide by. If the student had simply used the experience he gained by doing it - or looking it up - the first time around, and recoded, this would be fine. Try this in front of an academic honesty board, telling them "it didn't say NOT open book", and see what the board comes back with. Commented Nov 12, 2016 at 16:29
  • 3
    Yes or no, are not very helpful answers here. Value in questions like this comes from explanation and reasoning, and when possible, references to related information and argument.
    – dionys
    Commented Nov 12, 2016 at 16:49
  • 3
    @ScottSeidman "This is evading the conditions of examination" is begging the question because exactly those conditions are unclear. Conditions are not only a source of inconvenience for students, they are also a protection (!) for students against arbitrariness of evaluation. BrianDHall's answer which I find personally the best makes the problem very clear. I attack your specific reasoning because you claim unfair resource advantages where I do not see the vital difference between students who are smarter, more prepared or having unusual advantages (speedreading, good memory). Commented Nov 12, 2016 at 19:43

The fact that you are asking others about whether you cheated is a sign to me that you feel guilt. Though you are not considered liable for cheating simply because you feel guilty about your actions, your conscience tells you that you had unfair an advantage over other students.

Because you have such a desire to learn, you effectively studied for an un-study-able test, which is a huge and fair advantage over other students, but to use your previously written material for an exam (it sounds like a closed notes exam), I think is an unfair to other students.

The question that you have asked is about morals. There are many different standards of morals, and every person has his or her own set of morals (including the authors of the answers written above), but to me it seems that your set of morals is asking you to talk to your TA/ Professor. I agree with BrianDHall:

" If you pretended to be busy during the exam so it didn't look like you finished impossibly quickly, that suggests that at the time you thought something was fishy - or ambiguous - about what you were doing then."

Many others have answered your question not regarding the ethics of the situation, but whether you merit justice. Ultimately, the decision is up to you, but I wish that you had considered asking the professor/ TA during the exam, rather than feel guilty afterward, and that you will more carefully consider consequences before making your decisions in the future.

  • 1
    Although "pretending to be busy" brings up suspicions, the fact that they were allowed to use their own laptops leads me to assume it was open book test. Either it was open book(allowed to use pdf notes) or just a poorly designed test. Therefore, unless the professor specifically mentioned pdfs weren't allowed, I see no wrong in using old code in which he wrote himself. Commented Nov 13, 2016 at 20:47
  • I agree that the test was poorly designed, but @ImeanH asked the question because s/he felt that using previous material is dishonest.
    – Nate
    Commented Nov 14, 2016 at 16:22
  • You assume that it was an open book test, which is probably not the case; if the test were an "open-book" test, @ImeanH would not have asked the question. I assume that it was not an "open-book" test, otherwise, there would be nothing to discuss. At the end of the day, ImeanH will never feel at peace justifying what s/he considers to be dishonest behavior.
    – Nate
    Commented Nov 14, 2016 at 16:27
  • "Self-justification describes how, when a person encounters cognitive dissonance, or a situation in which a person's behavior is inconsistent with their beliefs, that person tends to justify the behavior and deny any negative feedback associated with the behavior." (en.wikipedia.org/wiki/Self-justification)
    – Nate
    Commented Nov 14, 2016 at 16:34

In my opinion it you did not cheat on your knowledge of your programming concepts but exams are conducted to also test how under a stressful condition (like an examination) a student will be able to cope with it and still come up with a solution. If you already programmed it as hobby it should have been easy for you to do it on your own and still finish early (may be not as early as you did but still).

Also consider another scenario. If few days before exam while revising for it I made a note and by mistake that was left in my pocket and by luck or chance that note related question is in the exam and I copy it from my self-made note which was by mistake left in my pocket is it cheating? If copy-pasting is not cheating then why is that cheating while in both cases I'm simply copying my own content? Just because it will take more time than copy-paste? The only thing which classifies your case as no cheating is the test was poorly designed because usually before entering exam room they ask you to leave behind any paper or note outside the room and in your programming test they should have clarified it in advance to not use your material on your laptop or made sure everything was cleaned before entering exam room.


one of the problems was to write up a certain famous program in Maple.

What do you mean by "write up"? Convert a famous piece of code in (say) C++ to Maple? Perhaps it was "eratosthenes sieve"? If you had already done that you were ahead of the pack anyway. And if you were allowed to use your laptop, and there was no requirement for it to be wiped of extraneous information prior to the exam, then you didn't break any rules.

That would be like if you were doing an English Literature exam, and you knew one of Shakespeare's plays might be asked about, and you just happened to spend the night before the exam studying the exact play that was in the exam.

That just shows good preparation.

I don't see what the alternative is. "Oh, I knew the answer, but because I did I had to pretend I didn't".

Imagine the question was something you could memorize. Like, "what is the principle crop grown in Bogotá?". If you happened to have memorized that in advance of the exam, well, good work!

This, if anything, shows a flaw in the examination question. If the question had been about some code that no-one had seen before, and it had to be converted to Maple, then no-one could possibly have worked it out in advance. But if the question was about converting a function that does a random shuffle of playing cards, then there would always be the possibility that someone would happen to have already have such code on their laptop.

  • 1
    I just don't see it that way. The situation is more as if the student suspected that he might be asked to write the Constitution on an exam. Spent all night studying the Constitution, then wrote it down from memory on a piece of paper. The next day, on the exam, the student stapled the paper from the night before onto the exam. Commented Nov 16, 2016 at 14:25
  • If he was allowed to bring the paper with him, surely that is OK? If the rules of the exam allowed a laptop, with any documents on it that the student cares to bring, with them, and the question asks for the Constitution to be quoted, surely it is valid to copy and paste it into the answer? What would you have him do? Retype it? What would be the difference to the end result? Commented Nov 16, 2016 at 20:55
  • 1
    Yes, and if there was no message about whether he was allowed to bring the paper, the assumption is that he wasn't, because this is an exam. It was a poorly designed exam, but I'm willing to bet that an academic honestly panel wouldn't see it your way. Commented Nov 16, 2016 at 20:59

It depends on what type of test you were in. if your test result depends on how much time toke to achieve result , obviously you cheated. but if time not matters and test was made to evaluate your programming skills you done your best. You 've made it with Reusability feature of your code.

Reusability is one of the most important subjects in programming context.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .