mirror of
https://github.com/krahets/hello-algo.git
synced 2024-12-26 22:56:28 +08:00
a6b3f72826
* feat(go/backtracking): add go code * feat(backtracking): add n_queens in go * feat(backtracking): add /preorder_traversal_i_compact in go * feat(backtracking): add /preorder_traversal_ii_compact in go * feat(backtracking): add /preorder_traversal_ii_template in go * feat(backtracking): add preorder_traversal_iii_compact in go * feat(backtracking): add preorder_traversal_test in go * feat(backtracking): add permutations_i in go * feat(backtracking): add permutations_ii in go * feat(backtracking): add permutation_test in go * feat(backtracking): fix bug in go * Update permutations_i.go --------- Co-authored-by: Yudong Jin <krahets@163.com>
24 lines
441 B
Go
24 lines
441 B
Go
// 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)
|
|
}
|
|
}
|
|
}
|