Tower Research Capital | Online Assessment | Find cheaters of the class

You have been hired as TA of Python, 101. Students have turned in their first assignments, but unfortunately there has been a lot of plagiarism. Your college provides a service that runs against all assignments and gives you pairs of assignments that appear to have been copied. Your job as TA, is to identify groups of people who copied from each other or from the same source and call them for questioning:

Input
Any number of lines having pairs of input representing roll number of the student who copied from the next student. For eg.
305641, 305581
305641, 305051
305051, 305581
305051, 305021
305021, 305051
306532, 305111
306532, 205121
305641, 205874
305532, 305182

Output:
205121, 305111, 306532
205874, 305021, 305051, 305581, 305641
305182, 305532

Note: The group of students who cheated should have roll numbers in sorted order as shown above.

Explanation:

  1. Find minimum roll number in the list (since we want to go in ascending order): 205121
  2. See who copied from this student or whom this student copied from : 205121 was copied by 306532 and 305632 copied from 305111. This sequence ends here since 305111 did not copy from anyone.
  3. Therefore, take those three roll numbers in ascending order and add them to answer. Hence the first row 205121, 305111, 306532
  4. Similarly, go to the next roll number in the remaining list i.e. 205874 and do 2nd step onwards ..
Comments (10)