THOR: An Algorithm for Cadence-independent Asteroid Discovery