Refactor with invariants
Refactor this code while keeping behavior identical. Constraints: - Do not change public API. - Keep runtime complexity <= current. - Prefer small functions + clearer names. Code: """[paste]""" Return: 1) brief rationale 2) diff/snippet (only changed parts) 3) test checklist (what to cover)
Opens on home with the prompt prefilled.
Open in Promptea