Get random values from an Array
<p>I'm trying to change the elements of an array randomly, by changing the indexes. Thats ok. Now the problem is that as the random is always random, I can get two results that are the same.</p>

<blockquote>
  <p>for example:</p>
  
  <p>Monday: </p>
  
  <p>song 1 </p>
  
  <p>song 2 </p>
  
  <p>song 3</p>
  
  <p>Tuesday: </p>
  
  <p>song 2 </p>
  
  <p>song 1 </p>
  
  <p>song 3</p>
  
  <p>Wednesday: </p>
  
  <p>song 1 </p>
  
  <p>song 2 </p>
  
  <p>song 3</p>
</blockquote>

<p>And so on...</p>

<p>And the list from </p>

<blockquote>
  <p>Monday</p>
</blockquote>

<p>and</p>

<blockquote>
  <p>Wednesday</p>
</blockquote>

<p>in this case is the same. I need to control that, but as you can see on the code, once I get the list from one day, I just print it. I thought about putting it on an array or Tuples and check if that tuple exists, but I think its too complicated. I thought that maybe I can make my own random function. But still, I'm not sure about that solution either. Any ideas of how can I solve this situation? Thanks!</p>

<p>Here is the code I have so far:</p>

<pre><code>    static string[] songs = new string[] { "song1", "song2", "song3" };
    static string[] days = new string[] { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };
    private static Random random = new Random();

/* Random number between lower and higher, inclusive */
    public static int rand(int lower, int higher)
    {
        int r = lower + (int)(random.Next(0, 2) * (higher - lower));

        return r;
    }

    /* pick M elements from original array. Clone original array so that
   7 * we don’t destroy the input. */
    public static string[] pickMRandomly()
    {
        string[] subset = new string[songs.Length];
        string[] array = (string[])songs.Clone();
        for (int j = 0; j &lt; songs.Length; j++)
        {
            int index = rand(j, array.Length - 1);
            subset[j] = array[index];
            array[index] = array[j]; // array[j] is now “dead”
        }
        return subset;
    }

    public static void playListCreation()
    {
        for (int j = 0; j &lt; days.Length; j++)
        {
            var result =pickMRandomly();
            System.Console.WriteLine(days[j]);
            foreach (var i in result)
            {
                System.Console.WriteLine(i + " ");
            }
            System.Console.WriteLine("/n");
        }
    }
}
</code></pre>