Satisficing and Optimal Generalised Planning via Goal Regression (Extended Version)