Sobes.tech
Intern — Middle

Creating a slice from unique random numbers

livecode

Task condition

It is necessary to implement the function uniqRandn, which returns a slice of length n consisting of unique random integers.

import (
        "fmt"
        "math/rand"
        )

func main() {
    fmt.Println(uniqRandn(10))
}

func uniqRandn(n int) []int {
    
}

The function should guarantee the absence of duplicate elements in the resulting slice, using a random number generator to obtain each value.