Content-defined chunk deduplication
Your task
A backup system uses content-defined chunking to deduplicate a byte stream. Given a string data, split it into chunks using this deterministic boundary rule: scan left to right; a chunk boundary ends right AFTER index i (0-based) whenever ((ord(data[i]) * 31 + i) mod divisor) == 0, OR when the chunk reaches max_len bytes (whichever comes first), and the final partial chunk ends at end-of-string. Each chunk is the substring between boundaries. Deduplicate identical chunk strings: count how many DISTINCT chunk strings result. Return that distinct-chunk count. divisor >= 1, max_len >= 1; len(data) <= 10^5.
Examples
cdc_distinct_chunks(data: str, divisor: int, max_len: int) -> intExample 1
Input
cdc_distinct_chunks("aaaa", 1, 10)Output
1