ios - Comparing arrays, sets & their elements in SWIFT -
i'm new coding in , find answers on here. on occasion i've been trying find method in swift allow me identify pairs of numbers, in array of unpaired numbers within array example in image attached 1 can see index 7 & 8 in numbers array matches elements in numpr2...
import uikit
var numpr1 = [7,4]
var numpr2 = [3,1]
var numpr3 = [5,3]
var numpr4 = [1,7]
var numpr5 = [2,7]
var numpr6 = [4,5]
var numpr7 = [4,6]
var arrayofpairs = [numpr1,numpr2,numpr4,numpr7,numpr5,numpr6,numpr3] var numbersarray = [1,5,7,6,2,4,6,3,1,7,4,5,3]
do wanna this?
for(var = 0;i < numbersarray.count - 1;i++){ for(var index = 0;index < arrayofpairs.count;index++){ if(numbersarray[i] == arrayofpairs[index][0] && numbersarray[i+1] == arrayofpairs[index][1]){ println(arrayofpairs[index]) } } }
Comments
Post a Comment