Randomize a spawn position without repition

How can I randomize an x and z coordinate from 1 to 10 and then remove that x and z coordinate from the 100 possible combinations? like if i do this

 public List<int> xSpawn = new List<int>();
    public List<int> zSpawn = new List<int>();

    public Rigidbody fallingBlockPrefab;
    private Rigidbody fallingBlockInstance;

    void Start()
    {
        StartCoroutine("SpawningBlocks");

        for (int a = 0; a < 10; a++)
        {
            xSpawn.Add(a);
            zSpawn.Add(a);
        }
    }

    IEnumerator SpawningBlocks()
    {

        yield return new WaitForSeconds(SpawnTime);
        int randX, randZ;
        randX = Random.RandomRange(0, xSpawn.Count);
        randZ = Random.RandomRange(0, zSpawn.Count);

        xSpawn.RemoveAt(randX);
        zSpawn.RemoveAt(randZ);

        fallingBlockInstance = Instantiate(fallingBlockPrefab, new Vector3(randX, 20, randZ), transform.rotation);
        fallingBlockInstance.name = "FallingBlock " + numberSpawned;

        StartCoroutine("SpawningBlocks");

    }

but it still spawn duplicates in. So basically say once a cube has spawn at position x=2 and z=3 I don’t want it to spawn at position x=2 and z=3 but still be possible to spawn at x=2 and say z=2 if it makes sense.

  1. Create one single list with all possible positions.
  2. Shuffle the list
  3. Create a queue from the shuffled list
  4. Dequeue a position when spawning
  5. Recreate a new queue if needed

You are using the index of the list for the position. Instead, you should use the value that you are removing in the coroutine.

I made a for loop from 10 to 110 to and then split it into x and z according to the position

for (int a = 10; a < 110; a++)
        {
            string spawnLocation = a.ToString();
            if (spawnLocation.Length == 2)
            {
                spawnPosition.Add(new SpawnPos((int.Parse(spawnLocation[0].ToString())), (int.Parse(spawnLocation[1].ToString()))));
            }
            if (spawnLocation.Length == 3)
            {
                spawnPosition.Add(new SpawnPos(int.Parse(spawnLocation[0].ToString() + spawnLocation[1].ToString()), int.Parse(spawnLocation[2].ToString())));
            }
        }

then just random a number from 0 to 110 and use that number of the list then just remove it afterwards

int randX, randZ, index;
        index = Random.RandomRange(0, 110);

        Debug.Log(spawnPosition[index].xPos + ";" + spawnPosition[index].zPos + "Number : " + index);
        randX = spawnPosition[index].xPos;
        randZ = spawnPosition[index].zPos;

        spawnPosition.RemoveAt(index);