Ignoring all the intricate details, Here is a naive school level algorithm to do this.
Test 1:First count the number of variables used in both programs.See the difference between them and decide a threshold difference for passing the test depending upon your needs and the programs you are comparing.
Test 2:Then determine the data type of variable that is used maximum times in both programs and if the data type differs then in most cases the programs will differ but again, It is not always the case.
Test 3:You could compare their cyclomatic complexity. This could also help in determining the likeness as it tell you about the number of independent paths in your programs.
There can be many more tests like comparing the number of blocks or function calls and you could set the rate of likeness to be equal to percentage of tests passed.
But of course This algorithm is naive and will have test cases for which it will fail, but for the basics and a start I think it should do fine.