GEICO interview question

Leetcode Hamsters problem medium level - python code