Quote (I.e. my question: is there anyway to tell the difference between code that has been copied/pasted and code that has been written out?)It depends on how long your code is, how much time you want to spend hiding the old one and so on.If you end up in a court case, they will typically take a copy of the whole code trees and history (sourcesafe/CVS/subversion), parse it and load it into a database to make statistical analysis on class, function, variable names, database schema, etc to see if there are many repetitions (a repeated class name can be by chance, more are suspicious). If there are some matches, generally more indepth check on the code and the algorithms follows, expecially on the core classes/libraries.In the Cantor vs Tradition case the 2% code found copied was around a class that would have been obsoleted soon after. The fact is that they did try to conceal it was the same code but without luck.If I were you I wouldn't copy the code. I would write notes about the generic algorithm, the mathematical formulas and then re-implement it afterwards yourself.And maybe (even if you work at home on your PC), maintain everything withing a source revision system so that you can eventually prove that you have been writing the code bit by bit and it didn't just appear in one day on your hard-disk (it's true you can always modify the timestamps, but if the police comes and put a seal around your hardware you can argue that you didn't have time to tamper with it)Whatever you do, good luck!