for an interview, adapted from https://github.com/olpotkin/CeleraOne-Solution/blob/master/Solution.ipynb