The cases of plagiarism related cheating is increasing day by day on Codechef. Some smart cheaters not just copy paste each other’s code but they make some minor changes in the copied code (like changing the variable name, adding/removing unnecessary comment, adding unused variable, adding extra tab or space, etc.) and try to show that their code is not exactly same and so they have not cheated. I think if the structure of code, sequence of function calls in the codes of two people are same, then there is a strong chance that they have cheated.
After thinking for a while I got an idea to detect this type of plagiarism or cheating (currently I have idea only for C & C++ languages).
To check if two (C/C++) programs are similar go through these steps:
step 1: convert the users code into assembly code by compiling the input codes by compiling with the command:
gcc -S filename.c filename.s (for C)
g++ -S filename.cpp filename.s (for C++)
step 2: compare the assembly code of the two users to be compared, generated in step 1. If the assembly codes are same, the users code are similar otherwise they are not.
This technique marks two (structurally similar) codes similar even if the codes differ with respect to:
- variable names
- blank spaces, newlines & tabs
- unused variables
It is obviously much faster than manual checking for plagiarism. So I would like to suggest the codechef team to use this technique for plagiarism detection.