dimanche 24 octobre 2021

Two Random Numbers Without Repeating

I'm looking to make a set of two random numbers (e.g., [1,2], [3,12]) with the first number between 1-12, and the second between 1-4. I know how to sample the two numbers independently using:

sample(1:12, 1, replace = T)
sample(1:4, 1, replace = T)

but don't know how to create a system to determine if the pairing of the two numbers has already been rolled, and if so, roll again. Any tips!?

Thanks :)




Aucun commentaire:

Enregistrer un commentaire