After all assignments are submitted, a dictionary is created that maps student number to the hash of their file.
This dictionary, or hashmap, or mapping (whatever your language calls it) will look as follows:
{100: "aabb", 104: "43a", 52: "00ab", 430: "aabb", 332: "43a"}
The key is the student number, and the value is the hash.
Our task is to pick out the cheaters! The cheaters are the ones which have identical hashes.
Given the input {100: "aabb", 104: "43a", 52: "00ab", 430: "aabb", 332: "43a"}
, the function should return (or print) the following text:
100 has identical files to 430
104 has identical files to 332
Notice how the files where the hashes are unique are not mentioned.
Also, the order is important here:
{100: "aabb", 202: "aabb", 303: "ab", 404: "aabb"}
should return (print) the following text:
100 has identical files to 202,404
It is incorrect to print any of the following:
202 has identical files to 100,404
100 has identical files to 404, 202
You should print it in terms of how it appears in the dictionary. In some languages, going through a dictionary is random, so in this special case, you are allowed to change the method of input such that you can go through it in an orderly fashion.
More Examples:
{} # prints nothing
{100: "ab", 303: "cd"} # prints nothing again
{100: "ab", 303: "cd", 404: "ab"}
100 has identical files to 404
{303: "abc", 304: "dd", 305: "abc", 405: "dd", 606: "abc"}
303 has identical files to 305,606
304 has identical files to 405
Shortest code wins!
303 has identical files to [305, 606]
instead of303 has identical files to 305,606
? \$\endgroup\$