A BACKTRACKING APPROACH FOR SOLVING PATH PUZZLES - Sakti, Joshua Erlangga; Arzaki, Muhammad; Wulandari, Gia Septiana (Diponegoro University, 2023)
We study algorithmic aspects of the Path puzzle–a logic puzzle created in 2013 and confirmed NP-complete (Non-deterministic Polynomial-time-complete) in 2020. We propose a polynomial time algorithm for verifying an arbitrary Path puzzle solution and a backtracking-based method for finding a solution to an arbitrary Path puzzle instance.To our knowledge, our study is the first rigorous investigation of an imperative algorithmic approach for solving Path puzzles. We prove that the asymptotic running time of our proposed method in solving an arbitrary Path puzzle instance of size m × n is O(3^mn). Despite this exponential upper bound, experimental results imply that a C++ implementation of our algorithm can quickly solve 6 × 6 Path puzzle instances in less than 30 milliseconds with an average of 3.02 milliseconds for 26 test cases. We finally prove that an m × n Path puzzle instance without row and column constraints is polynomially solvable in O({m,n}) time.