For a very short time I entertained the idea to write a program that would solve this for all combinations of sizes X Y Z and emount of moves N but then I thought "stop getting so distracted by stuff"..