export function getRandomElement(arr: readonly T[]): T { if (arr.length === 0) { throw new Error("Cannot get random element from empty array"); } return arr[Math.floor(Math.random() * arr.length)]; } export function shuffleArray(arr: T[]): T[] { const shuffled = [...arr]; for (let i = shuffled.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)); [shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]]; } return shuffled; }