LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-18-2004, 10:58 PM   #1
muneebs123
LQ Newbie
 
Registered: Sep 2003
Posts: 23

Rep: Reputation: 15
How to Compare the c/c++ codes


Hi
I am a teacher for linux programming, and i was wondering if there is some script or program that is available that compares different code files and then tells me the percentage of similarity. The script should be a batch one able to search and compare more than 200 files so that i know which students have copied from each other.
 
Old 02-18-2004, 11:33 PM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Moved: More suitable in our Programming forum. Regards.
 
Old 02-18-2004, 11:43 PM   #3
bdp
Member
 
Registered: Apr 2002
Distribution: RH 9
Posts: 230

Rep: Reputation: 30
Hi muneebs123,

I am unsure if a proper linux script already exists, but would suggest quantifying the similarity between any two codes with an autocorrelation function. Essentially define an initial window of say 100 bytes and another window that slides down the code, 100 bytes at a time, moving 50 bytes per movement to satisfy the Nyquist sampling criterion. Autocorrelate the initial and sliding window once per 50 byte movement and consider a 'hit' (i.e. copied code) to be some high degree of correlation, perhaps 0.95. Of course the initial window will also need to slide down the data to compare all possible initial windows with all possible final windows.

This method is routinely used in many data analysis applications.

If you are interested in applying this approach I can provide more details.

Cheers, - Brian
 
Old 02-19-2004, 12:05 AM   #4
muneebs123
LQ Newbie
 
Registered: Sep 2003
Posts: 23

Original Poster
Rep: Reputation: 15
yes i will be interested. Please provide some details
thanks
 
Old 02-19-2004, 12:53 AM   #5
bdp
Member
 
Registered: Apr 2002
Distribution: RH 9
Posts: 230

Rep: Reputation: 30
Hi muneebs123,

This site gives a nice intro to autocorrelation:
http://astronomy.swin.edu.au/~pbourk...sis/correlate/

how about taking my uppermost reply and the link above and asking the students to write the code

i'd suggest using FFTW (google can explain quickly) to implement fourier transforms if you choose to use frequency space.

cheers, - brian
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Are the hex codes for colors in a jpg the same codes as used in html? abefroman Linux - Security 3 07-31-2005 03:21 PM
exit codes introuble Programming 2 05-08-2005 12:53 PM
terminal -> codes aap Linux - Newbie 13 02-05-2005 12:52 PM
return codes in c exvor Programming 4 01-21-2005 08:45 PM
wht do these codes mean? jackandking Programming 10 12-25-2004 11:14 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration