How I can get random math symbol from array and change the type from string?? and then use in my code? its giving me error because I used it as string in xxl valuable
let arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]
let arr1 = ["+", "-", "*"]
for _ in 1...100{
let x = 0
if x < 100{
var aa = arr1.randomElement()
var bb = arr1.randomElement()
var cc = arr1.randomElement()
var dd = arr1.randomElement()
var ee = arr1.randomElement()
var ff = arr1.randomElement()
var gg = arr1.randomElement()
var hh = arr1.randomElement()
var a1 = arr[0]
var a2 = arr[1]
var a3 = arr[2]
var a4 = arr[3]
var a5 = arr[4]
var a6 = arr[5]
var a7 = arr[6]
var a8 = arr[7]
var a9 = arr[8]
var xxl = a1 + aa + a2 + bb + a3 + cc + a4 + dd + a5 + ee + a6 + ff + a7 + gg + a8 + hh + a9
print("OMG symbol is \(xxl)")
}else{
print(x)
}
}
Aucun commentaire:
Enregistrer un commentaire