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.
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
solutions "../../solutions"
|
|
|
|
"github.com/01-edu/z01"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
f := []func(int, int) int{Add, Sub, Mul}
|
|
|
|
argInt := []int{}
|
|
|
|
|
|
|
|
type node struct {
|
|
|
|
arr []int
|
|
|
|
functions []func(int, int) int
|
|
|
|
}
|
|
|
|
|
|
|
|
table := []node{}
|
|
|
|
for i := 0; i < 4; i++ {
|
|
|
|
argInt = z01.MultRandIntBetween(0, 50)
|
|
|
|
val := node{
|
|
|
|
arr: argInt,
|
|
|
|
functions: f,
|
|
|
|
}
|
|
|
|
table = append(table, val)
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, v := range table {
|
|
|
|
for _, f := range v.functions {
|
|
|
|
z01.Challenge("ReduceInt", ReduceInt, solutions.ReduceInt, f, v.arr)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func Add(accumulator, currentValue int) int {
|
|
|
|
return accumulator + currentValue
|
|
|
|
}
|
|
|
|
|
|
|
|
func Sub(accumulator, currentValue int) int {
|
|
|
|
return accumulator - currentValue
|
|
|
|
}
|
|
|
|
|
|
|
|
func Mul(accumulator, currentValue int) int {
|
|
|
|
return currentValue * accumulator
|
|
|
|
}
|