A general strategy for solving Pell's equations (ft. @octopuskeng )