jeudi 30 avril 2020

Sets of random numbers with no duplicates

I want to write a program that can make random seats at my school in our diner.

I know this much

import Foundation

var randomNumbers: [Int] = []

for _ in 0...5 {
    let randomInt = Int.random(in: 0...160)
    randomNumbers.append(randomInt)
}

print(randomNumbers)

This prints 6 numbers between 1 and 160. I want to do this lets say 4 times. How would you make it so you can't sit together with people who you sat with before




Aucun commentaire:

Enregistrer un commentaire