Solution to Palantir's Rainfall problem