Mission 13: "Cracking the Final Lock" 🔐
The core of any recursive algorithm is its base case. For N-Queens, the base case is when you have successfully placed a queen in every single row.
00:00
Mission Objective
Inside the `backtrack` function, add the base case: if the current row `r` is equal to the board size `n`, it means a solution has been found. Call the provided `solutionFound()` function.
Step 1 / 4
1. The Story: The Mission Briefing
"The Labyrinth's final security door is protected by a combinatorial lock modeled on the ancient N-Queens puzzle. You must find a valid placement of 'energy queens' on a grid, but most sequences will overload the system."
2. The Problem
Solving the N-Queens puzzle using backtracking.
3. The Task
You will write a recursive Backtracking function that tries one step of a solution (e.g., placing a queen in a row), then calls itself to try the next. If a path violates the rules, it will undo the step and try a different option.
4. Concepts Applied
Implementing a Backtracking algorithm.