Match dot and star patterns
Match the whole text against a valid pattern with lowercase literals, dot for any one character, and star for zero or more of the preceding atom. No leading or repeated star occurs.
pattern = 'a*b'
j = 0
print(pattern[j+1] == '*')
print(pattern[j+2:]) # skip a*Reason about the state
Memoize text and pattern positions. A star either skips its atom or consumes one matching character while staying at the same pattern position. Before writing code, identify what each variable means after one iteration. Walk through the example and explain why the next transition preserves that meaning. Then check the smallest permitted input and a case with repeated values. A correct answer follows the contract for every input, including the boundary cases in the checks. Keep any input mutation within the stated rules; return a fresh result when the task asks for one.
Your task
Match the whole text against a valid pattern with lowercase literals, dot for any one character, and star for zero or more of the preceding atom. No leading or repeated star occurs.
The explanation opens here once every check passes.