mirror of
https://github.com/krahets/hello-algo.git
synced 2026-07-13 07:46:06 +00:00
772183705e
* Add Russian docs site baseline * Add Russian localized codebase * Polish Russian code wording * Update ru code translation. * Update code translation and chapter covers. * Fix pythontutor extraction. * Add README and landing page. * placeholder of profiles * Use figures of English version * Remove chapter paperbook
41 lines
797 B
Go
41 lines
797 B
Go
// File: hanota_test.go
|
|
// Created Time: 2023-07-21
|
|
// Author: hongyun-robot (1836017030@qq.com)
|
|
|
|
package chapter_divide_and_conquer
|
|
|
|
import (
|
|
"container/list"
|
|
"fmt"
|
|
"testing"
|
|
|
|
. "github.com/krahets/hello-algo/pkg"
|
|
)
|
|
|
|
func TestHanota(t *testing.T) {
|
|
// Хвост списка соответствует вершине столбца
|
|
A := list.New()
|
|
for i := 5; i > 0; i-- {
|
|
A.PushBack(i)
|
|
}
|
|
B := list.New()
|
|
C := list.New()
|
|
fmt.Println("Исходное состояние:")
|
|
fmt.Print("A = ")
|
|
PrintList(A)
|
|
fmt.Print("B = ")
|
|
PrintList(B)
|
|
fmt.Print("C = ")
|
|
PrintList(C)
|
|
|
|
solveHanota(A, B, C)
|
|
|
|
fmt.Println("После завершения перемещения дисков:")
|
|
fmt.Print("A = ")
|
|
PrintList(A)
|
|
fmt.Print("B = ")
|
|
PrintList(B)
|
|
fmt.Print("C = ")
|
|
PrintList(C)
|
|
}
|