I am generating numbers from 1-52 (to deal out random playing cards), however I want to make sure that none of them are the same. In total a max of 17 cards will be dealt out, and they must be different. This is not a duplicate, as no question answers how to check for repetitions in random numbers of more that 2 different values.
Here is a shortened version of the code for convenience:
let randomPlayerCard1 = Int(arc4random() % 52) // Generates random numbers
let randomPlayerCard2 = Int(arc4random() % 52)
let randomCentreCard1 = Int(arc4random() % 52)
let randomCentreCard2 = Int(arc4random() % 52)
let randomCentreCard3 = Int(arc4random() % 52)
let randomCentreCard4 = Int(arc4random() % 52)
let randomCentreCard5 = Int(arc4random() % 52)
while randomPlayerCard1 == randomPlayerCard2 { /* I don't want to create "while"
statement for every combination of 2 of the eventual 17 random values being equal*/
}
playerCard1.image = mapping[randomPlayerCard1]
playerCard2.image = mapping[randomPlayerCard2]
I also tried something like:
while randomPlayerCard1 == randomPlayerCard2 == randomCentreCard5 == randomCentreCard3
But your not allowed to do that, as I expected.
Thank you for any help!