Saildrone interview question

A coding question that requires optimizing the given solution in Python.