I came across the answer to solving a quadratic diophantine equation on this site by @Willjagy:
[General method for determining if $Ax^2 + Bx + C$ is square](https://math.stackexchange.com/questions/1496083/general-method-for-determining-if-ax2-bx-c-is-square)
I wish to know how the four seed solutions were obtained. Is it by trial and error or was there some algorithm that was followed?

As an aside, is the process reversible? i.e. knowing integer solutions to $X^2-DY^2=k^2$ for some $k$, is it possible to find solutions to $X^2-DY^2=1$?