MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / printboard

Function printboard

backtracking/n_queens.py:92–102  ·  view source on GitHub ↗

Prints the boards that have a successful combination.

(board: list[list[int]])

Source from the content-addressed store, hash-verified

90
91
92def printboard(board: list[list[int]]) -> None:
93 """
94 Prints the boards that have a successful combination.
95 """
96 for i in range(len(board)):
97 for j in range(len(board)):
98 if board[i][j] == 1:
99 print("Q", end=" ") # Queen is present
100 else:
101 print(".", end=" ") # Empty cell
102 print()
103
104
105# Number of queens (e.g., n=8 for an 8x8 board)

Callers 1

solveFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected