package main import "math/rand/v2" func generatePassword(sets [][]int, length int) []int { password := make([]int, length) // Ensure at least one character from each set for i, charSet := range sets { password[i] = charSet[rand.IntN(len(charSet))] } // Fill the remaining positions with characters from all sets for i := range password[len(sets):] { charSetIndex := rand.IntN(len(sets)) charSet := sets[charSetIndex] password[len(sets)+i] = charSet[rand.IntN(len(charSet))] } // Shuffle rand.Shuffle(len(password), func(i, j int) { password[i], password[j] = password[j], password[i] }) return password }