Document shingle count
Your task
A help centre deduplicator measures how alike two articles are by cutting each one into shingles. A shingle is a run of exactly width consecutive characters, taken at every starting position, so neighbouring runs overlap in all but one character. A run holding a space is not a shingle, because the tool never lets one straddle a word break, and that run is dropped. Given document and width, return how many distinct shingles the document yields. A shingle that turns up in ten places still counts once, and shingles are compared exactly, so case matters. Return 0 when width is zero or negative, and 0 when width is longer than the document, since no run that size exists. This count is the denominator the tool divides shared shingles by.
Examples
unique_shingle_count(document: str, width: int) -> intExample 1
Input
unique_shingle_count("banana", 3)Output
3Example 2
Input
unique_shingle_count("hot pot", 3)Output
2Example 3
Input
unique_shingle_count("aaaa", 2)Output
1