Generic puzzle solver