-
Notifications
You must be signed in to change notification settings - Fork 0
/
math_functions.go
80 lines (69 loc) · 1.56 KB
/
math_functions.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package main
import (
"fmt"
)
func fillzeros(n int) [][]int {
endofunctions := [][]int{}
for i := 0; i < power(n, n); i++ {
endofunction := make([]int, n)
temp := i
for j := 0; j < n; j++ {
endofunction[j] = temp + 1%n
temp /= n
}
endofunctions = append(endofunctions, endofunction)
}
return endofunctions
}
func power(base, power int) int {
var result int = 1
for i := 0; i < power; i++ {
result *= base
}
return result
}
func find(array [][]int, element int) [][]int {
output := make([][]int, len(array))
for i := range output {
output[i] = make([]int, INDEX)
}
for i := 0; i < len(array); i++ {
for j := 0; j < len(array[i]); j++ {
if array[i][j] == element {
output[i][j] = 1
} else if output[i][j] == 1 {
output[i][j] = 1
} else {
output[i][j] = 0
}
}
}
return output
}
func table(array [][]int, message ...string) {
if message == nil {
message = append(message, "")
}
fmt.Println("\n", message[0], "\t")
for i := 0; i < len(array); i++ {
fmt.Printf("[%3d] = ", i)
for j := 0; j < len(array[i]); j++ {
fmt.Print(array[i][j])
}
fmt.Println()
}
}
func compost(array1 [][]int, array2 [][]int) [][]int {
output := make([][]int, len(array1)*len(array2))
for i := 0; i < len(output); i++ {
output[i] = make([]int, INDEX)
}
for rowsA := 0; rowsA < len(array2); rowsA++ {
for i := 0; i < INDEX; i++ {
newX := (array1[rowsA][i]) - 1
fmt.Println("array: ", array1[rowsA][i], "sender: ", array2[rowsA][newX])
/* output[rowsA*len(array2)][i] = array2[rowsB][newX] */
}
}
return output
}