Solution to Two Sigma's online coding challenge.