Useing an array to draw an even number of gameObjects

While trying to learn more about about arrays I have made a small memory game where the player clicks on books and if they match the books are destroyed, a problem I am having is that the array will always draw an odd number of random books, thus the game can never be completed, I have looked over the documentation and cant find any examples, can anyone offer advice as to how to create the array that it always draws an even number of random books.

here is my array code.

void Start () 
    {

        for (int y = 0; y < gridY; y++)
        {
            for (int x = 0; x < gridX; x++)
            {
                //Vector3 pos = new Vector3(x, 0, y) * spacing;
                int amount = Random.Range(0, books.Length);
                Instantiate(books[amount], new Vector3(y * 2 * books[amount].transform.localScale.x * spacing, 10, x * 2 * books[amount].transform.localScale.z * spacing), Quaternion.identity);
            }
        }
        allow = true;
	}

I’m guessing books is an array of multiple pair of books, something like [A, A, B, B, C …] you instatiate one of them at each grid point.

Problem is, you can each of them can be instatiated never, once or gridY * gridX times. I guess you could keep track of the books already instatiated and keep re seeding the random until you get what you want.

But let me give you another direction. Use a List<> (from System.Collections.Generics). Initialize it with those pairs, and then instantiate randomly like you’re doing right now. The trick will be to remove that index from the list afterwards, something like :

int amount = Random.Range(0, books.Length);
Instantiate(books[amount], ...);
books.RemoveAt(amount);