mirror of https://github.com/01-edu/public.git
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.
71 lines
1.1 KiB
71 lines
1.1 KiB
5 years ago
|
package main
|
||
5 years ago
|
|
||
|
import (
|
||
5 years ago
|
student "student"
|
||
|
|
||
4 years ago
|
"github.com/01-edu/public/go/tests/lib"
|
||
|
"github.com/01-edu/public/go/tests/lib/is"
|
||
5 years ago
|
)
|
||
|
|
||
5 years ago
|
func any(f func(string) bool, a []string) bool {
|
||
|
for _, el := range a {
|
||
5 years ago
|
if f(el) {
|
||
|
return true
|
||
|
}
|
||
|
}
|
||
|
return false
|
||
|
}
|
||
|
|
||
5 years ago
|
func main() {
|
||
5 years ago
|
functions := []func(string) bool{is.Digit, is.Lower, is.Upper}
|
||
5 years ago
|
|
||
|
type node struct {
|
||
5 years ago
|
f func(string) bool
|
||
|
a []string
|
||
5 years ago
|
}
|
||
|
|
||
|
table := []node{}
|
||
|
|
||
|
for i := 0; i < 5; i++ {
|
||
5 years ago
|
function := functions[lib.RandIntBetween(0, len(functions)-1)]
|
||
5 years ago
|
table = append(table, node{
|
||
|
f: function,
|
||
5 years ago
|
a: lib.MultRandWords(),
|
||
5 years ago
|
})
|
||
5 years ago
|
}
|
||
|
for i := 0; i < 5; i++ {
|
||
5 years ago
|
table = append(table, node{
|
||
5 years ago
|
f: is.Digit,
|
||
5 years ago
|
a: lib.MultRandDigit(),
|
||
5 years ago
|
})
|
||
5 years ago
|
}
|
||
|
|
||
|
for i := 0; i < 5; i++ {
|
||
5 years ago
|
table = append(table, node{
|
||
5 years ago
|
f: is.Lower,
|
||
5 years ago
|
a: lib.MultRandLower(),
|
||
5 years ago
|
})
|
||
5 years ago
|
}
|
||
|
for i := 0; i < 5; i++ {
|
||
5 years ago
|
table = append(table, node{
|
||
5 years ago
|
f: is.Upper,
|
||
5 years ago
|
a: lib.MultRandUpper(),
|
||
5 years ago
|
})
|
||
5 years ago
|
}
|
||
|
|
||
|
table = append(table,
|
||
|
node{
|
||
5 years ago
|
f: is.Digit,
|
||
5 years ago
|
a: []string{"Hello", "how", "are", "you"},
|
||
5 years ago
|
},
|
||
|
node{
|
||
5 years ago
|
f: is.Digit,
|
||
5 years ago
|
a: []string{"This", "is", "4", "you"},
|
||
5 years ago
|
},
|
||
|
)
|
||
|
|
||
|
for _, arg := range table {
|
||
5 years ago
|
lib.Challenge("Any", student.Any, any, arg.f, arg.a)
|
||
5 years ago
|
}
|
||
|
}
|