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.
62 lines
1.0 KiB
62 lines
1.0 KiB
5 years ago
|
package main
|
||
5 years ago
|
|
||
5 years ago
|
import (
|
||
5 years ago
|
student "student"
|
||
|
|
||
|
"lib"
|
||
5 years ago
|
)
|
||
5 years ago
|
|
||
|
func makeRange(min, max int) []int {
|
||
|
size := max - min
|
||
|
|
||
|
if size <= 0 {
|
||
|
return nil
|
||
|
}
|
||
|
answer := make([]int, size)
|
||
|
for i := range answer {
|
||
|
answer[i] = min
|
||
|
min++
|
||
|
}
|
||
|
return answer
|
||
|
}
|
||
5 years ago
|
|
||
5 years ago
|
func main() {
|
||
5 years ago
|
type node struct {
|
||
|
min int
|
||
|
max int
|
||
|
}
|
||
5 years ago
|
|
||
5 years ago
|
table := []node{}
|
||
|
|
||
5 years ago
|
// 15 random pairs of ints for a Valid Range
|
||
5 years ago
|
for i := 0; i < 15; i++ {
|
||
5 years ago
|
minVal := lib.RandIntBetween(-10000000, 1000000)
|
||
|
gap := lib.RandIntBetween(1, 20)
|
||
5 years ago
|
val := node{
|
||
|
min: minVal,
|
||
|
max: minVal + gap,
|
||
|
}
|
||
|
table = append(table, val)
|
||
|
}
|
||
5 years ago
|
// 15 random pairs of ints with ||invalid range||
|
||
5 years ago
|
for i := 0; i < 15; i++ {
|
||
5 years ago
|
minVal := lib.RandIntBetween(-10000000, 1000000)
|
||
|
gap := lib.RandIntBetween(1, 20)
|
||
5 years ago
|
val := node{
|
||
|
min: minVal,
|
||
|
max: minVal - gap,
|
||
|
}
|
||
|
table = append(table, val)
|
||
|
}
|
||
|
|
||
|
table = append(table,
|
||
|
node{min: 0, max: 1},
|
||
|
node{min: 0, max: 0},
|
||
|
node{min: 5, max: 10},
|
||
|
node{min: 10, max: 5},
|
||
|
)
|
||
|
for _, arg := range table {
|
||
5 years ago
|
lib.Challenge("MakeRange", student.MakeRange, makeRange, arg.min, arg.max)
|
||
5 years ago
|
}
|
||
|
}
|