All problems
Duplicate Image Detection
Problem
Find duplicate images in a list by exact pixel hash.
Return the indices of the first occurrence of each distinct image, in order. Two images are duplicates when every pixel is equal; an empty list returns [].
Hint
A tuple of tuples is hashable, so it can key a dictionary.
Test cases
case 1
in: [[[[1,2]],[[1,2]],[[3,4]]]]
expected: [0,2]
case 2
in: [[[[1,2]],[[3,4]],[[5,6]]]]
expected: [0,1,2]
case 3
in: [[[[1,2]],[[1,2]],[[1,2]]]]
expected: [0]
case 4
in: [[]]
expected: []
Starter codePython
def duplicate_hash(images):
# Your code here
pass4 test cases · run your code against them in the editor