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.
57 lines
1017 B
57 lines
1017 B
5 years ago
|
package main
|
||
|
|
||
|
import (
|
||
5 years ago
|
"strings"
|
||
|
|
||
5 years ago
|
"./student"
|
||
5 years ago
|
)
|
||
|
|
||
5 years ago
|
func doppelGanger(s, substr string) int {
|
||
|
return strings.LastIndex(s, substr)
|
||
|
}
|
||
|
|
||
5 years ago
|
type node struct {
|
||
|
big, little string
|
||
|
}
|
||
|
|
||
5 years ago
|
func main() {
|
||
5 years ago
|
table := []node{}
|
||
|
|
||
|
table = append(table,
|
||
|
node{"aaaaaaa", "a"},
|
||
|
node{"qwerty", "t"},
|
||
|
node{"a", "b"},
|
||
|
)
|
||
|
|
||
|
for i := 0; i < 10; i++ {
|
||
5 years ago
|
l := lib.RandIntBetween(5, 30)
|
||
|
big := lib.RandStr(l, "qwertyuiopasdfghjklzxcvbnm")
|
||
|
start := lib.RandIntBetween(0, l-1)
|
||
|
end := lib.RandIntBetween(start+1, l-1)
|
||
5 years ago
|
little := big[start:end]
|
||
|
|
||
|
value := node{
|
||
|
big: big,
|
||
|
little: little,
|
||
|
}
|
||
|
|
||
|
table = append(table, value)
|
||
|
}
|
||
|
|
||
|
for i := 0; i < 10; i++ {
|
||
5 years ago
|
big := lib.RandStr(lib.RandIntBetween(5, 30), "qwertyuiopasdfghjklzxcvbnm")
|
||
|
little := lib.RandStr(lib.RandIntBetween(1, 29), "qwertyuiopasdfghjklzxcvbnm")
|
||
5 years ago
|
|
||
|
value := node{
|
||
|
big: big,
|
||
|
little: little,
|
||
|
}
|
||
|
|
||
|
table = append(table, value)
|
||
|
}
|
||
|
|
||
|
for _, arg := range table {
|
||
5 years ago
|
lib.Challenge("DoppelGanger", student.DoppelGanger, doppelGanger, arg.big, arg.little)
|
||
5 years ago
|
}
|
||
|
}
|