Your boss has found out that quite a bunch of his employees (including you) like to steal code from others. He ordered you to write him a program that he can use to find people who steal code from others.
Task:
Write a program/function that detects if somebody copied (part of) his code from somewhere else.
The program will get all the existing programs and the program that it should test from two separate inputs. Edit: Since there are no answers so far, you may use regular expressions!
Output
- The program should then output all the stolen pieces of code, separated by either a space or a newline. (It may have a space or a newline at the end.)
- A piece of code is considered to be stolen/copied if it consists of 10 or more successive bytes. (Sorry, Java fans!)
- You have to output as much as possible, but if there are overlapping ones, you may ignore one of them or output both of them.
Twist:
As mentioned before, you also love duct tape coding. That means, everything in your code will be copy-pasted from a stack exchange site! You can copy whatever you want (not limited to code in code blocks) and as much as you want. (But at least 10 bytes) (Same rule as above about what is considered to be stolen/copied.) (Please do note that any answers that were posted after this question may not be used.) Please provide links to where you got your code from.
Examples:
Input:
x = document.getElementById("ninja'd");
(The first input)
y = document.getElementById("id");
(The second input)
Output:
= document.getElementById("
Input:
foo
(The first input)
foo+bar
(The second input)
Output:
Nothing.
Input:
public static void main(String[] args)
(The first input)
public static void main(String[] args)
(The second input)
Output:
main(String[] args)
Input:
for(var i=0; i<x.length; i++){}
(The first input)
for(var i=0; i<oops.length; i++){break;}
(The second input)
Output:
for(var i=0; i<
.length; i++){
or
for(var i=0; i< .length; i++){