 var string = "Hello World Again"
 var arrayString = [Character](string.characters)
 
-replaceSpaces(arrayString, length: arrayString.count-1)
-print(arrayString)
+//replaceSpaces(string: arrayString, length: arrayString.count-1)
+//print(arrayString)
 
 //: 4. Implement a method to perform a basic string compression using the counts of repeated characters. For example, the string aabccccaaa would become a2b1c4a3. If the compressed string would not become smaller than the original string, your method should return the original string.
 

    return (subSet1, subSet2)
}

var finalResult = try split(&testInput)
print(finalResult.0)
print(finalResult.1)

var finalResult2 = try split(&input2)
for i in 0..<finalResult2.0.count {
    Swift.print(finalResult2.0[i])
}


//: # Strings

var array5 = [1,1,2,3,4,5]
var array6 = [1,2,3,4,5,5]

func swap( array: inout [Int], index1:Int, index2: Int) {
    let temp = array[index1]
    array[index1] = array[index2]
    array[index2] = temp
}

func findDuplicateElement( array: inout [Int]) -> Int {
    let lastIndex = array.count-1
    
    while array[array[lastIndex]-1] != array[lastIndex] {
        swap(array: &array, index1: array[array[lastIndex]-1], index2: array[lastIndex])
    }
    return array[array[lastIndex]-1]
}

//print("The duplicated element in an array with elements from 1 to n-1: \(findDuplicateElement(array: &array5))")
//print("The duplicated element in an array with elements from 1 to n-1: \(findDuplicateElement(array: &array6))")

//: Solution with mathematical formula.

