Find the Duplicates

A local artist has been creating digital art for years, amassing thousands of files saved across multiple directories. Over time, duplicate copies of the same art pieces have been saved with different names, causing clutter and taking up precious storage space. To help manage this situation, your task is to develop a program that identifies these duplicate files based on their content.
Given a single line of input, the name of the directory, the program should scan through all files within that directory (we are not interested in subdirectories for this task) and print a list of duplicate files grouped together. Files are considered duplicates if their content is identical. The output should consist of multiple lines, each line containing the names of duplicate files separated by spaces. If a file does not have a duplicate, just print the filename on a single line.
artwork1.txt copy_of_artwork1.txt another_copy_of_artwork1.txt drawing1.png duplicate_drawing1.png photo1.jpg photo_copy.jpg unique_file.txt
Note: In the example above, drawing1.png and duplicate_drawing1.png are duplicates, as well as artwork1.txt, copy_of_artwork1.txt and another_copy_of_artwork1.txt, and photo1.jpg and photo_copy.jpg.


Time limit: 2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue