You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
441 B
25 lines
441 B
7 months ago
|
// File: n_queens_test.go
|
||
|
// Created Time: 2023-05-14
|
||
|
// Author: Reanon (793584285@qq.com)
|
||
|
|
||
|
package chapter_backtracking
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestNQueens(t *testing.T) {
|
||
|
n := 4
|
||
|
res := nQueens(n)
|
||
|
|
||
|
fmt.Println("輸入棋盤長寬為 ", n)
|
||
|
fmt.Println("皇后放置方案共有 ", len(res), " 種")
|
||
|
for _, state := range res {
|
||
|
fmt.Println("--------------------")
|
||
|
for _, row := range state {
|
||
|
fmt.Println(row)
|
||
|
}
|
||
|
}
|
||
|
}
|