mardi 18 août 2020

How can we generate some amount of random numbers and link them to each other without getting a number linked to itself?

I am writing a program where I need to shuffle a list of persons and link them to another person from the list. But the problem is with odd numbers, because 1 person can be linked to themself. (I made that impossible so then nothing happens.)

For example, if there are 3 persons called 'Bill', 'John' and 'Jonas'. If 'Bill' gets 'Jonas' and 'Jonas' gets 'Bill', then 'John' is getting linked to 'John', but I made that impossible (to get themself) so nothing happens then.

Does anyone know how I can fix this?




Aucun commentaire:

Enregistrer un commentaire