Consider changing this to take X and Y as arguments and moving this function to Solve.java rather than XY.java.