Documentation
¶
Index ¶
- func Init()
- func RandomElementFromArray[T any](arr []T) T
- func RandomElementsFromArray[T any](arr []T, count int) []T
- func RandomFloat64(min, max float64) float64
- func RandomFloat64s(min, max float64, count int) []float64
- func RandomInt(min, max int) int
- func RandomInts(min, max int, count int) []int
- func RandomString() string
- func RandomStrings(n int) []string
- func RandomWord() string
- func RandomWords(n int) []string
- func ShuffleArray[T any](arr []T) []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Init ¶
func Init()
Init must be called at the start of every program.
If CODECRAFTERS_RANDOM_SEED is set, it will be used to generate predictable random numbers.
func RandomElementFromArray ¶ added in v0.2.32
func RandomElementFromArray[T any](arr []T) T
func RandomElementsFromArray ¶ added in v0.2.32
func RandomFloat64 ¶ added in v0.4.7
RandomFloat64 returns a random float64 number between [min, max)
func RandomFloat64s ¶ added in v0.4.7
RandomFloat64s returns an array of `count` random Float64 values between [min, max).
func RandomInts ¶ added in v0.2.39
RandomInts returns an array of `count` unique random integers between [min, max). It panics if count is greater than the range of possible values.
func RandomStrings ¶
RandomStrings returns a random list of n strings.
func ShuffleArray ¶ added in v0.4.3
func ShuffleArray[T any](arr []T) []T
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.