Exemple #1
0
func sign(n int) {
	fmt.Println(factorial(n) * (1 << uint8(n)))

	a := make([]int, n)
	for k := range a {
		a[k] = k + 1
	}

	signPerm(a)
	for permutable.NextPermutation(permutable.PermInts(a)) {
		signPerm(a)
	}
}
Exemple #2
0
func Perm() {
	n := 0

	if _, err := fmt.Scanf("%d", &n); err != nil {
		log.Fatal(err)
	}

	fmt.Println(factorial(n))

	a := make([]int, n)
	for k := range a {
		a[k] = k + 1
	}

	printPerm(a)
	for permutable.NextPermutation(permutable.PermInts(a)) {
		printPerm(a)
	}
}