23/40
Part 4 of 7 · DigestsLearn and do
Count the sizes, then key the rest by size and digest
Put the size and the digest together. Here are eight small files, with the content shown so you can check the answer:
FILES = {
"photos/beach.jpg": b"sunset over water",
"photos/beach-copy.jpg": b"sunset over water",
"backup/beach.jpg": b"sunset over water",
"docs/notes.txt": b"milk, eggs",
"docs/todo.txt": b"call home!",
"backup/notes.txt": b"milk, eggs",
"video/trip.mov": b"v" * 9000,
"tmp/empty.log": b"",
}
The size counts are {17: 3, 10: 3, 9000: 1, 0: 1}. So the movie and the empty log are never opened. The six others get a key of (size, digest):
docs/notes.txt and docs/todo.txt are both 10 bytes. Are they duplicates?
Pick an answer above to see the rest