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.
32 lines
673 B
32 lines
673 B
5 years ago
|
package main
|
||
5 years ago
|
|
||
|
import (
|
||
5 years ago
|
"strconv"
|
||
|
"strings"
|
||
|
|
||
5 years ago
|
student "student"
|
||
|
|
||
4 years ago
|
"github.com/01-edu/public/go/tests/lib"
|
||
5 years ago
|
)
|
||
|
|
||
5 years ago
|
func itoaBase(value, base int) string {
|
||
|
if base < 2 || base > 16 {
|
||
|
return ""
|
||
|
}
|
||
|
|
||
|
return strings.ToUpper(strconv.FormatInt(int64(value), base))
|
||
|
}
|
||
|
|
||
5 years ago
|
func main() {
|
||
5 years ago
|
for i := 0; i < 30; i++ {
|
||
5 years ago
|
value := lib.RandIntBetween(-1000000, 1000000)
|
||
|
base := lib.RandIntBetween(2, 16)
|
||
5 years ago
|
lib.Challenge("ItoaBase", student.ItoaBase, itoaBase, value, base)
|
||
5 years ago
|
}
|
||
|
for i := 0; i < 5; i++ {
|
||
5 years ago
|
base := lib.RandIntBetween(2, 16)
|
||
5 years ago
|
lib.Challenge("ItoaBase", student.ItoaBase, itoaBase, lib.MaxInt, base)
|
||
|
lib.Challenge("ItoaBase", student.ItoaBase, itoaBase, lib.MinInt, base)
|
||
5 years ago
|
}
|
||
|
}
|