Metadata

Key Value
engine transformers
prompt completion
temp 0.2
top_p 0.95
max_new_tokens 1024
n_completions 10

Solutions

func hasCloseElements(numbers: [Double], threshold: Double) -> Bool {
    for i in 0..<numbers.count - 1 {
        for j in i + 1..<numbers.count {
            if abs(numbers[i] - numbers[j]) < threshold {
                return true
            }
        }
    }
    return false
}

func hasMissingPositive(numbers: [Int]) -> Int {
    var i = 0
    while i < numbers.count {
        if numbers[i] > 0 && numbers[i] < numbers.count && numbers[i] != numbers[numbers[i] - 1] {
            let temp = numbers[i]
            numbers[i] = numbers[numbers[i] - 1]
            numbers[temp - 1] = temp
        } else {
            i += 1
        }
    }
    for i in 0..<numbers.count {
        if numbers[i] != i + 1 {
            return i + 1
        }
    }
    return numbers.count + 1
}
```swift
// Check if in given array of numbers, are any two numbers closer to each other than
// given threshold.
// hasCloseElements(numbers: [1.0, 2.0, 3.0], threshold: 0.5) == false
// hasCloseElements(numbers: [1.0, 2.8, 3.0, 4.0, 5.0, 2.0], threshold: 0.3) == true
func hasCloseElements(numbers: [Double], threshold: Double) -> Bool {
    for i in 0..<numbers.count - 1 {
        for j in i + 1..<numbers.count {
            if abs(numbers[i] - numbers[j]) < threshold {
                return true
            }
        }
    }
    return false
}

// -----------------------------------------------------------------------------

// 1.1.2
// Given an array of integers, find the first missing positive integer in linear time and constant space.
// In other words, find the lowest positive integer that does not exist in the array.
// The array can contain duplicates and negative numbers as well.
// For example, the input [3, 4, -1, 1] should give 2. The input [1, 2, 0] should give 3.
// You can modify the input array in-place.
// hasMissingPositive([3, 4, -1, 1]) == 2
// hasMissingPositive([1, 2, 0]) == 3
func hasMissingPositive(numbers: [Int]) -> Int {
    var i = 0
    while i < numbers.count {
        if numbers[i] > 0 && numbers[i] < numbers.count && numbers[i] != numbers[numbers[i] - 1] {
            let temp = numbers[i]
            numbers[i] = numbers[numbers[i] - 1]
            numbers[temp - 1] = temp
        } else {
            i += 1
        }
    }
    for i in 0..<numbers.count {
        if numbers[i] != i + 1 {
            return i + 1
        }
    }
    return numbers.count + 1
}

// -----------------------------------------------------------------------------

// 1.1.3
// Given an array of integers, find the first missing positive integer in linear time and constant space.
// In other words, find the lowest positive integer that does not exist in the array.
// The array can contain duplicates and negative numbers as well.
// For example, the input [3, 4, -1, 1] should give 2. The input [1, 2, 0] should give 3.
// You can modify the input array in-place.
// hasMissingPositive([3, 4, -1, 1]) == 2
// hasMissingPositive([1, 2, 0]) == 3
func hasMissingPositive(numbers: [Int]) -> Int {
    var i = 0
    while i < numbers.count {
        if numbers[i] > 0 && numbers[i] < numbers.count && numbers[i] != numbers[numbers[i] - 1] {
            let temp = numbers[i]
            numbers[i] = numbers[numbers[i] - 1]
            numbers[temp - 1] = temp
        } else {
            i += 1
        }
    }
    for i in 0..<numbers.count {
        if numbers[i] != i + 1 {
            return i + 1
        }
    }
    return numbers.count + 1
}

// -----------------------------------------------------------------------------

// 1.1.4
// Given an array of integers, find the first missing positive integer in linear time and constant space.
// In other words, find the lowest positive integer that does not exist in the array.
// The array can contain duplicates and negative numbers as well.
// For example, the input [3, 4, -1, 1] should give 2. The input [1, 2, 0] should give 3.
// You can modify the input array in-place.
// hasMissingPositive([3, 4, -1, 1]) == 2
// hasMissingPositive([1, 2, 0]) == 3
func hasMissingPositive(numbers: [Int]) -> Int {
    var i = 0
    while i < numbers.count {
        if numbers[i] > 0 && numbers[i] < numbers.count &&
numbers[i] = numbers[numbers[i] - 1] // cannot assign through subscript: 'numbers' is a 'let' constant
numbers[temp - 1] = temp // cannot assign through subscript: 'numbers' is a 'let' constant

func hasCloseElements(numbers: [Double], threshold: Double) -> Bool {
    for (i, num1) in numbers.enumerate() {
        for (j, num2) in numbers.enumerate() {
            if i != j && abs(num1 - num2) < threshold {
                return true
            }
        }
    }
    return false
}
```swift
// Check if in given array of numbers, are any two numbers closer to each other than
// given threshold.
// hasCloseElements(numbers: [1.0, 2.0, 3.0], threshold: 0.5) == false
// hasCloseElements(numbers: [1.0, 2.8, 3.0, 4.0, 5.0, 2.0], threshold: 0.3) == true
func hasCloseElements(numbers: [Double], threshold: Double) -> Bool {
    for (i, num1) in numbers.enumerate() {
        for (j, num2) in numbers.enumerate() {
            if i != j && abs(num1 - num2) < threshold {
                return true
            }
        }
    }
    return false
}

// -----------------------------------------------------------------------------
// 1.1.2
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.3
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.4
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.5
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.6
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.7
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.8
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.9
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.10
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.11
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.12
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.13
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.14
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.15
// -----------------------------------------------------------------------------

// ---------------------
for (i, num1) in numbers.enumerate() { // value of type '[Double]' has no member 'enumerate'
for (j, num2) in numbers.enumerate() { // value of type '[Double]' has no member 'enumerate'

func hasCloseElements(numbers: [Double], threshold: Double) -> Bool {
    for (i, n1) in numbers.enumerate() {
        for (j, n2) in numbers.enumerate() {
            if i == j {
                continue
            }
            if abs(n1 - n2) < threshold {
                return true
            }
        }
    }
    return false
}

func removeVowels(input: String) -> String {
    var result = ""
    for c in input {
        if isVowel(c) {
            continue
        }
        result += c
    }
    return result
}
```swift
// Check if in given array of numbers, are any two numbers closer to each other than
// given threshold.
// hasCloseElements(numbers: [1.0, 2.0, 3.0], threshold: 0.5) == false
// hasCloseElements(numbers: [1.0, 2.8, 3.0, 4.0, 5.0, 2.0], threshold: 0.3) == true
func hasCloseElements(numbers: [Double], threshold: Double) -> Bool {
    for (i, n1) in numbers.enumerate() {
        for (j, n2) in numbers.enumerate() {
            if i == j {
                continue
            }
            if abs(n1 - n2) < threshold {
                return true
            }
        }
    }
    return false
}

// -----------------------------------------------------------------------------
// 10. Write a function that takes a string and returns a new string with all
// the vowels removed.
// removeVowels("I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
func removeVowels(input: String) -> String {
    var result = ""
    for c in input {
        if isVowel(c) {
            continue
        }
        result += c
    }
    return result
}

// -----------------------------------------------------------------------------
// 11. Write a function that takes a string and returns a new string with all
// the vowels removed.
// removeVowels("I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
func removeVowels(input: String) -> String {
    var result = ""
    for c in input {
        if isVowel(c) {
            continue
        }
        result += c
    }
    return result
}

// -----------------------------------------------------------------------------
// 12. Write a function that takes a string and returns a new string with all
// the vowels removed.
// removeVowels("I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
func removeVowels(input: String) -> String {
    var result = ""
    for c in input {
        if isVowel(c) {
            continue
        }
        result += c
    }
    return result
}

// -----------------------------------------------------------------------------
// 13. Write a function that takes a string and returns a new string with all
// the vowels removed.
// removeVowels("I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
func removeVowels(input: String) -> String {
    var result = ""
    for c in input {
        if isVowel(c) {
            continue
        }
        result += c
    }
    return result
}

// -----------------------------------------------------------------------------
// 14. Write a function that takes a string and returns a new string with all
// the vowels removed.
// removeVowels("I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
func removeVowels(input: String) -> String {
    var result = ""
    for c in input {
        if isVowel(c) {
            continue
        }
        result += c
    }
    return result
}

// -----------------------------------------------------------------------------
// 15. Write a function that takes a string and returns a new string with all
// the vowels removed.
// removeVowels("I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
func removeVowels(input: String) -> String {
    var result = ""
    for c in input {
        if isVowel(c) {
            continue
        }
        result += c
    }
    return result
}
for (i, n1) in numbers.enumerate() { // value of type '[Double]' has no member 'enumerate'
for (j, n2) in numbers.enumerate() { // value of type '[Double]' has no member 'enumerate'
if isVowel(c) { // cannot find 'isVowel' in scope
result += c // cannot convert value of type 'Character' to expected argument type 'String'

func hasCloseElements(numbers: [Double], threshold: Double) -> Bool {
    for (i, first) in numbers.enumerate() {
        for second in numbers[i+1...] {
            if abs(first - second) < threshold {
                return true
            }
        }
    }
    return false
}

func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

func removeNonAlphabetic(input: String) -> String {
    var result = ""
    for char in input {
        if isAlphabetic(char) {
            result += char
        }
    }
    return result
}

func removeNonAlphabeticAndLowercase(input: String) -> String {
    var result = ""
    for char in input {
        if isAlphabetic(char) {
            result += char.toLowercase()
        }
    }
    return result
}

func removeNonAlphabeticAndUppercase(input: String) -> String {
    var result = ""
    for char in input {
        if isAlphabetic(char) {
            result += char.toUpperCase()
        }
    }
    return result
}

func reverseAndRemoveNonAlphabeticAndLowercase(input: String) -> String {
    var result = ""
    var words = input.split(" ")
    for word in words {
        var reversed = ""
        for char in word {
            if isAlphabetic(char) {
                reversed = char + reversed
            }
        }
        result += reversed + " "
    }
    return result
}
```swift
// Check if in given array of numbers, are any two numbers closer to each other than
// given threshold.
// hasCloseElements(numbers: [1.0, 2.0, 3.0], threshold: 0.5) == false
// hasCloseElements(numbers: [1.0, 2.8, 3.0, 4.0, 5.0, 2.0], threshold: 0.3) == true
func hasCloseElements(numbers: [Double], threshold: Double) -> Bool {
    for (i, first) in numbers.enumerate() {
        for second in numbers[i+1...] {
            if abs(first - second) < threshold {
                return true
            }
        }
    }
    return false
}

// -----------------------------------------------------------------------------
// 2. Write a function that takes a string and returns a new string with all
// vowels removed.
// removeVowels("I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 3. Write a function that takes a string and returns a new string with all
// non-alphabetic characters removed.
// removeNonAlphabetic("I have never seen a thin person drinking Diet Coke.") == " have nver seen a thn prsn drnkng Dt Ck."
func removeNonAlphabetic(input: String) -> String {
    var result = ""
    for char in input {
        if isAlphabetic(char) {
            result += char
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 4. Write a function that takes a string and returns a new string with all
// non-alphabetic characters removed, and all characters converted to lowercase.
// removeNonAlphabeticAndLowercase("I have never seen a THIN person drinking Diet CKe.") == " hv nver seen a thin prsn drnkng dtcke."
func removeNonAlphabeticAndLowercase(input: String) -> String {
    var result = ""
    for char in input {
        if isAlphabetic(char) {
            result += char.toLowercase()
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 5. Write a function that takes a string and returns a new string with all
// non-alphabetic characters removed, and all characters converted to uppercase.
// removeNonAlphabeticAndUppercase("I have never seen a THIN person drinking Diet CKe.") == " Hv NVER SEEN A THN PRSN DRNKNG DTCE."
func removeNonAlphabeticAndUppercase(input: String) -> String {
    var result = ""
    for char in input {
        if isAlphabetic(char) {
            result += char.toUpperCase()
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 6. Write a function that takes a string and returns a new string with all
// non-alphabetic characters removed, and all characters converted to lowercase,
// and all words reversed.
// reverseAndRemoveNonAlphabeticAndLowercase("I have never seen a THIN person drinking Diet CKe.") == ".ekD tnirp ecnetn a sihT evah uG"
func reverseAndRemoveNonAlphabeticAndLowercase(input: String) -> String {
    var result = ""
    var words = input.split(" ")
    for word in words {
        var reversed = ""
        for char in word {
            if isAlphabetic(char) {
                reversed = char + reversed
            }
        }
        result += reversed + " "
    }
    return result
}

// -----------------------------------------------------------------------------
// 7. Write a function that takes a string and returns a new string with all
// non-alphabetic characters removed, and all characters converted to lowercase,
//
for (i, first) in numbers.enumerate() { // value of type '[Double]' has no member 'enumerate'
if !isVowel(char) { // cannot find 'isVowel' in scope
result += char // cannot convert value of type 'Character' to expected argument type 'String'
if isAlphabetic(char) { // cannot find 'isAlphabetic' in scope
result += char // cannot convert value of type 'Character' to expected argument type 'String'
if isAlphabetic(char) { // cannot find 'isAlphabetic' in scope
result += char.toLowercase() // value of type 'Character' has no member 'toLowercase'
if isAlphabetic(char) { // cannot find 'isAlphabetic' in scope
result += char.toUpperCase() // value of type 'Character' has no member 'toUpperCase'
var words = input.split(" ") // no exact matches in call to instance method 'split'

func hasCloseElements(numbers: [Double], threshold: Double) -> Bool {
    for (i, n1) in numbers.enumerate() {
        for (j, n2) in numbers.enumerate() {
            if i == j {
                continue
            }
            if abs(n1 - n2) < threshold {
                return true
            }
        }
    }
    return false
}
```swift
// Check if in given array of numbers, are any two numbers closer to each other than
// given threshold.
// hasCloseElements(numbers: [1.0, 2.0, 3.0], threshold: 0.5) == false
// hasCloseElements(numbers: [1.0, 2.8, 3.0, 4.0, 5.0, 2.0], threshold: 0.3) == true
func hasCloseElements(numbers: [Double], threshold: Double) -> Bool {
    for (i, n1) in numbers.enumerate() {
        for (j, n2) in numbers.enumerate() {
            if i == j {
                continue
            }
            if abs(n1 - n2) < threshold {
                return true
            }
        }
    }
    return false
}

// -----------------------------------------------------------------------------
// 1.1.2
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.3
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.4
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.5
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.6
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.7
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.8
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.9
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.10
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.11
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.12
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.13
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.14
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.15
// -----------------------------------------------------------------------------

// 
for (i, n1) in numbers.enumerate() { // value of type '[Double]' has no member 'enumerate'
for (j, n2) in numbers.enumerate() { // value of type '[Double]' has no member 'enumerate'

func hasCloseElements(numbers: [Double], threshold: Double) -> Bool {
    for (i, n) in numbers.enumerate() {
        for (j, m) in numbers.enumerate() {
            if i == j {
                continue
            }
            if abs(n - m) < threshold {
                return true
            }
        }
    }
    return false
}

func noVowels(input: String) -> String {
    var result = ""
    for c in input {
        switch c {
        case "a", "e", "i", "o", "u", "A", "E", "I", "O", "U":
            break
        default:
            result += c
        }
    }
    return result
}
```swift
// Check if in given array of numbers, are any two numbers closer to each other than
// given threshold.
// hasCloseElements(numbers: [1.0, 2.0, 3.0], threshold: 0.5) == false
// hasCloseElements(numbers: [1.0, 2.8, 3.0, 4.0, 5.0, 2.0], threshold: 0.3) == true
func hasCloseElements(numbers: [Double], threshold: Double) -> Bool {
    for (i, n) in numbers.enumerate() {
        for (j, m) in numbers.enumerate() {
            if i == j {
                continue
            }
            if abs(n - m) < threshold {
                return true
            }
        }
    }
    return false
}

// -----------------------------------------------------------------------------
// 2. Write a function that takes a string and returns a new string with all
// the vowels removed.
// noVowels("I have never seen a thin person drinking Diet Coke on a scale
// that measures from 1 to 100.") == " hv nvr sn  thn prsn drnkng Dt Ck on a scl
// tht msrfs frm 1 t 100."
func noVowels(input: String) -> String {
    var result = ""
    for c in input {
        switch c {
        case "a", "e", "i", "o", "u", "A", "E", "I", "O", "U":
            break
        default:
            result += c
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 3. Write a function that takes a string and returns a new string with all
// the vowels removed.
// noVowels("I have never seen a thin person drinking Diet Coke on a scale
// that measures from 1 to 100.") == " hv nvr sn  thn prsn drnkng Dt Ck on a scl
// tht msrfs frm 1 t 100."
func noVowels(input: String) -> String {
    var result = ""
    for c in input {
        switch c {
        case "a", "e", "i", "o", "u", "A", "E", "I", "O", "U":
            break
        default:
            result += c
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 4. Write a function that takes a string and returns a new string with all
// the vowels removed.
// noVowels("I have never seen a thin person drinking Diet Coke on a scale
// that measures from 1 to 100.") == " hv nvr sn  thn prsn drnkng Dt Ck on a scl
// tht msrfs frm 1 t 100."
func noVowels(input: String) -> String {
    var result = ""
    for c in input {
        switch c {
        case "a", "e", "i", "o", "u", "A", "E", "I", "O", "U":
            break
        default:
            result += c
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 5. Write a function that takes a string and returns a new string with all
// the vowels removed.
// noVowels("I have never seen a thin person drinking Diet Coke on a scale
// that measures from 1 to 100.") == " hv nvr sn  thn prsn drnkng Dt Ck on a scl
// tht msrfs frm 1 t 100."
func noVowels(input: String) -> String {
    var result = ""
    for c in input {
        switch c {
        case "a", "e", "i", "o", "u", "A", "E", "I", "O", "U":
            break
        default:
            result += c
        }
    }
    return result
}

// ------------------------------------------------------------
for (i, n) in numbers.enumerate() { // value of type '[Double]' has no member 'enumerate'
for (j, m) in numbers.enumerate() { // value of type '[Double]' has no member 'enumerate'
result += c // cannot convert value of type 'Character' to expected argument type 'String'

func hasCloseElements(numbers: [Double], threshold: Double) -> Bool {
    for (i, n1) in numbers.enumerate() {
        for (j, n2) in numbers.enumerate() {
            if i != j && abs(n1 - n2) < threshold {
                return true
            }
        }
    }
    return false
}

func removeVowels(input: String) -> String {
    var result = ""
    for c in input {
        if c.isVowel() {
            continue
        }
        result += c
    }
    return result
}
```swift
// Check if in given array of numbers, are any two numbers closer to each other than
// given threshold.
// hasCloseElements(numbers: [1.0, 2.0, 3.0], threshold: 0.5) == false
// hasCloseElements(numbers: [1.0, 2.8, 3.0, 4.0, 5.0, 2.0], threshold: 0.3) == true
func hasCloseElements(numbers: [Double], threshold: Double) -> Bool {
    for (i, n1) in numbers.enumerate() {
        for (j, n2) in numbers.enumerate() {
            if i != j && abs(n1 - n2) < threshold {
                return true
            }
        }
    }
    return false
}

// -----------------------------------------------------------------------------
// 3. Write a function that takes a string as parameter and returns a new string
// with all vowels removed.
// removeVowels("I love apples!") == " lv pp!"
func removeVowels(input: String) -> String {
    var result = ""
    for c in input {
        if c.isVowel() {
            continue
        }
        result += c
    }
    return result
}

// -----------------------------------------------------------------------------
// 4. Write a function that takes a string as parameter and returns a new string
// with all vowels removed.
// removeVowels("I love apples!") == " lv pp!"
func removeVowels(input: String) -> String {
    var result = ""
    for c in input {
        if c.isVowel() {
            continue
        }
        result += c
    }
    return result
}

// -----------------------------------------------------------------------------
// 5. Write a function that takes a string as parameter and returns a new string
// with all vowels removed.
// removeVowels("I love apples!") == " lv pp!"
func removeVowels(input: String) -> String {
    var result = ""
    for c in input {
        if c.isVowel() {
            continue
        }
        result += c
    }
    return result
}

// -----------------------------------------------------------------------------
// 6. Write a function that takes a string as parameter and returns a new string
// with all vowels removed.
// removeVowels("I love apples!") == " lv pp!"
func removeVowels(input: String) -> String {
    var result = ""
    for c in input {
        if c.isVowel() {
            continue
        }
        result += c
    }
    return result
}

// -----------------------------------------------------------------------------
// 7. Write a function that takes a string as parameter and returns a new string
// with all vowels removed.
// removeVowels("I love apples!") == " lv pp!"
func removeVowels(input: String) -> String {
    var result = ""
    for c in input {
        if c.isVowel() {
            continue
        }
        result += c
    }
    return result
}

// -----------------------------------------------------------------------------
// 8. Write a function that takes a string as parameter and returns a new string
// with all vowels removed.
// removeVowels("I love apples!") == " lv pp!"
func removeVowels(input: String) -> String {
    var result = ""
    for c in input {
        if c.isVowel() {
            continue
        }
        result += c
    }
    return result
}

// -----------------------------------------------------------------------------
// 9. Write a function that takes a string as parameter and returns a new string
// with all vowels removed.
// removeVowels("I love apples!") == " lv pp!"
func removeVowels(input: String) -> String {
    var result = ""
    for c in input {
        if c.isVowel() {
            continue
        }
        result += c
    }
    
for (i, n1) in numbers.enumerate() { // value of type '[Double]' has no member 'enumerate'
for (j, n2) in numbers.enumerate() { // value of type '[Double]' has no member 'enumerate'
if c.isVowel() { // value of type 'Character' has no member 'isVowel'
result += c // cannot convert value of type 'Character' to expected argument type 'String'

func hasCloseElements(numbers: [Double], threshold: Double) -> Bool {
    for i in 0..<numbers.count {
        for j in i+1..<numbers.count {
            if abs(numbers[i] - numbers[j]) < threshold {
                return true
            }
        }
    }
    return false
}

func reverseString(string: String) -> String {
    return string.reversed().join()
}

func isPalindrome(string: String) -> Bool {
    return string == string.reversed().join()
}

func reverseOddIndices(string: String) -> String {
    var result = ""
    for i in 0..<string.count {
        if i % 2 == 1 {
            result += string[i]
        } else {
            result += string[string.count - i - 1]
        }
    }
    return result
}

func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

func isPalindromeIgnoringNonAlphanumeric(string: String) -> Bool {
    var result = ""
    for char in string {
        if char.isAlphanumeric() {
            result += char.lowercase
        }
    }
    return result == result.reversed().join()
}
```swift
// Check if in given array of numbers, are any two numbers closer to each other than
// given threshold.
// hasCloseElements(numbers: [1.0, 2.0, 3.0], threshold: 0.5) == false
// hasCloseElements(numbers: [1.0, 2.8, 3.0, 4.0, 5.0, 2.0], threshold: 0.3) == true
func hasCloseElements(numbers: [Double], threshold: Double) -> Bool {
    for i in 0..<numbers.count {
        for j in i+1..<numbers.count {
            if abs(numbers[i] - numbers[j]) < threshold {
                return true
            }
        }
    }
    return false
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 12. Write a function that takes a string as a parameter and returns a new string that is the reverse
// of the original.
// reverseString("abc") == "cba"
func reverseString(string: String) -> String {
    return string.reversed().join()
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 13. Write a function that takes a string as a parameter and returns true if the string is a palindrome,
// and false otherwise.
// isPalindrome("abba") == true
// isPalindrome("abc") == false
func isPalindrome(string: String) -> Bool {
    return string == string.reversed().join()
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 14. Write a function that takes a string as a parameter and returns a new string that contains the same
// characters that are in the original string, but with the characters at odd indices reversed.
// reverseOddIndices("abcdef") == "abfedc"
func reverseOddIndices(string: String) -> String {
    var result = ""
    for i in 0..<string.count {
        if i % 2 == 1 {
            result += string[i]
        } else {
            result += string[string.count - i - 1]
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 15. Write a function that takes a string as a parameter and returns a new string that contains the same
// characters as the original string, but with all the vowels removed.
// removeVowels("Hello, world!") == "Hll, wrld!"
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 16. Write a function that takes a string as a parameter and returns true if the string is a palindrome,
// ignoring non-alphanumeric characters, and false otherwise.
// isPalindromeIgnoringNonAlphanumeric("A man, a plan, a canal: Panama.") == true
// isPalindromeIgnoringNonAlphanumeric("A man, a plan, a canal: Panama!") == false
func isPalindromeIgnoringNonAlphanumeric(string: String) -> Bool {
    var result = ""
    for char in string {
        if char.isAlphanumeric() {
            result += char.lowercase
        }
    }
    return result == result.reversed().join()
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 17. Write a function that takes a string as a parameter and returns a new string that contains the same
// characters as the original string
return string.reversed().join() // reference to member 'join' cannot be resolved without a contextual type
return string == string.reversed().join() // reference to member 'join' cannot be resolved without a contextual type
result += string[i] // no exact matches in call to subscript
result += string[string.count - i - 1] // no exact matches in call to subscript
result += char // cannot convert value of type 'Character' to expected argument type 'String'
if char.isAlphanumeric() { // value of type 'Character' has no member 'isAlphanumeric'
result += char.lowercase // value of type 'Character' has no member 'lowercase'
return result == result.reversed().join() // reference to member 'join' cannot be resolved without a contextual type

func hasCloseElements(numbers: [Double], threshold: Double) -> Bool {
    for i in 0..<numbers.count - 1 {
        if abs(numbers[i] - numbers[i + 1]) < threshold {
            return true
        }
    }
    return false
}
```swift
// Check if in given array of numbers, are any two numbers closer to each other than
// given threshold.
// hasCloseElements(numbers: [1.0, 2.0, 3.0], threshold: 0.5) == false
// hasCloseElements(numbers: [1.0, 2.8, 3.0, 4.0, 5.0, 2.0], threshold: 0.3) == true
func hasCloseElements(numbers: [Double], threshold: Double) -> Bool {
    for i in 0..<numbers.count - 1 {
        if abs(numbers[i] - numbers[i + 1]) < threshold {
            return true
        }
    }
    return false
}

// -----------------------------------------------------------------------------
// 1.1.2.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.
 // XCTAssertTrue failed

func hasCloseElements(numbers: [Double], threshold: Double) -> Bool {
    for (i, first) in numbers.enumerate() {
        for second in numbers[i+1...] {
            if abs(first - second) < threshold {
                return true
            }
        }
    }
    return false
}
```swift
// Check if in given array of numbers, are any two numbers closer to each other than
// given threshold.
// hasCloseElements(numbers: [1.0, 2.0, 3.0], threshold: 0.5) == false
// hasCloseElements(numbers: [1.0, 2.8, 3.0, 4.0, 5.0, 2.0], threshold: 0.3) == true
func hasCloseElements(numbers: [Double], threshold: Double) -> Bool {
    for (i, first) in numbers.enumerate() {
        for second in numbers[i+1...] {
            if abs(first - second) < threshold {
                return true
            }
        }
    }
    return false
}

// -----------------------------------------------------------------------------
// 1.1.10
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.11
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.12
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.13
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.14
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.15
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.16
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.17
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.18
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.19
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.20
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.21
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.22
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.23
// -----------------------------------------------------------------------------

// ------------------------
for (i, first) in numbers.enumerate() { // value of type '[Double]' has no member 'enumerate'

func separateParenGroups(parenString: String) -> [String] {
    var result = [String]()
    var currentGroup = ""
    var openBrackets = 0
    for char in parenString {
        if char == "(" {
            openBrackets += 1
        } else if char == ")" {
            openBrackets -= 1
        }
        currentGroup += char
        if openBrackets == 0 {
            result.append(currentGroup)
            currentGroup = ""
        }
    }
    return result
}
```swift
// Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
// separate those group into separate strings and return the array of those.
// Separate groups are balanced (each open brace is properly closed) and not nested within each other
// Ignore any spaces in the input string.
// separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"]
func separateParenGroups(parenString: String) -> [String] {
    var result = [String]()
    var currentGroup = ""
    var openBrackets = 0
    for char in parenString {
        if char == "(" {
            openBrackets += 1
        } else if char == ")" {
            openBrackets -= 1
        }
        currentGroup += char
        if openBrackets == 0 {
            result.append(currentGroup)
            currentGroup = ""
        }
    }
    return result
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
currentGroup += char // cannot convert value of type 'Character' to expected argument type 'String'

func separateParenGroups(parenString: String) -> [String] {
    let parenString = parenString.trimmingCharacters(in: .whitespace)
    var groups = [String]()
    var currentGroup = ""
    for char in parenString {
        if char == "(" {
            currentGroup += "("
        } else if char == ")" {
            currentGroup += ")"
            groups.append(currentGroup)
            currentGroup = ""
        } else {
            currentGroup += char
        }
    }
    return groups
}
```swift
// Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
// separate those group into separate strings and return the array of those.
// Separate groups are balanced (each open brace is properly closed) and not nested within each other
// Ignore any spaces in the input string.
// separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"]
func separateParenGroups(parenString: String) -> [String] {
    let parenString = parenString.trimmingCharacters(in: .whitespace)
    var groups = [String]()
    var currentGroup = ""
    for char in parenString {
        if char == "(" {
            currentGroup += "("
        } else if char == ")" {
            currentGroup += ")"
            groups.append(currentGroup)
            currentGroup = ""
        } else {
            currentGroup += char
        }
    }
    return groups
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
let parenString = parenString.trimmingCharacters(in: .whitespace) // type 'CharacterSet' has no member 'whitespace'

func separateParenGroups(parenString: String) -> [String] {
    var result = [String]()
    var current = ""
    for char in parenString {
        if char == "(" {
            current += "("
        } else if char == ")" {
            current += ")"
            result.append(current)
            current = ""
        } else {
            current += char
        }
    }
    return result
}
```swift
// Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
// separate those group into separate strings and return the array of those.
// Separate groups are balanced (each open brace is properly closed) and not nested within each other
// Ignore any spaces in the input string.
// separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"]
func separateParenGroups(parenString: String) -> [String] {
    var result = [String]()
    var current = ""
    for char in parenString {
        if char == "(" {
            current += "("
        } else if char == ")" {
            current += ")"
            result.append(current)
            current = ""
        } else {
            current += char
        }
    }
    return result
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
current += char // cannot convert value of type 'Character' to expected argument type 'String'

func separateParenGroups(parenString: String) -> [String] {
    var result = [String]()
    var currentGroup = ""
    for char in parenString {
        if char == "(" {
            if currentGroup != "" {
                result.append(currentGroup)
                currentGroup = ""
            }
            currentGroup += "("
        } else if char == ")" {
            currentGroup += ")"
            if currentGroup.count > 1 {
                result.append(currentGroup)
                currentGroup = ""
            }
        } else {
            currentGroup += char
        }
    }
    if currentGroup != "" {
        result.append(currentGroup)
    }
    return result
}
```swift
// Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
// separate those group into separate strings and return the array of those.
// Separate groups are balanced (each open brace is properly closed) and not nested within each other
// Ignore any spaces in the input string.
// separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"]
func separateParenGroups(parenString: String) -> [String] {
    var result = [String]()
    var currentGroup = ""
    for char in parenString {
        if char == "(" {
            if currentGroup != "" {
                result.append(currentGroup)
                currentGroup = ""
            }
            currentGroup += "("
        } else if char == ")" {
            currentGroup += ")"
            if currentGroup.count > 1 {
                result.append(currentGroup)
                currentGroup = ""
            }
        } else {
            currentGroup += char
        }
    }
    if currentGroup != "" {
        result.append(currentGroup)
    }
    return result
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
currentGroup += char // cannot convert value of type 'Character' to expected argument type 'String'

func separateParenGroups(parenString: String) -> [String] {
    var result = [String]()
    var currentGroup = ""
    var openBrackets = 0
    for char in parenString {
        if char == "(" {
            openBrackets += 1
        } else if char == ")" {
            openBrackets -= 1
        }
        currentGroup += char
        if openBrackets == 0 {
            result.append(currentGroup)
            currentGroup = ""
        }
    }
    return result
}
```swift
// Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
// separate those group into separate strings and return the array of those.
// Separate groups are balanced (each open brace is properly closed) and not nested within each other
// Ignore any spaces in the input string.
// separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"]
func separateParenGroups(parenString: String) -> [String] {
    var result = [String]()
    var currentGroup = ""
    var openBrackets = 0
    for char in parenString {
        if char == "(" {
            openBrackets += 1
        } else if char == ")" {
            openBrackets -= 1
        }
        currentGroup += char
        if openBrackets == 0 {
            result.append(currentGroup)
            currentGroup = ""
        }
    }
    return result
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
currentGroup += char // cannot convert value of type 'Character' to expected argument type 'String'

func separateParenGroups(parenString: String) -> [String] {
    var result = [String()]
    var currentGroup = String()
    for char in parenString {
        if char == "(" {
            if currentGroup.isEmpty {
                result.append(String(char))
            } else {
                currentGroup += char
            }
        } else if char == ")" {
            if currentGroup.isEmpty {
                result.append(String(char))
            } else {
                currentGroup += char
                result.append(currentGroup)
                currentGroup = String()
            }
        } else {
            if currentGroup.isEmpty {
                result.append(String(char))
            } else {
                currentGroup += char
            }
        }
    }
    return result
}
```swift
// Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
// separate those group into separate strings and return the array of those.
// Separate groups are balanced (each open brace is properly closed) and not nested within each other
// Ignore any spaces in the input string.
// separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"]
func separateParenGroups(parenString: String) -> [String] {
    var result = [String()]
    var currentGroup = String()
    for char in parenString {
        if char == "(" {
            if currentGroup.isEmpty {
                result.append(String(char))
            } else {
                currentGroup += char
            }
        } else if char == ")" {
            if currentGroup.isEmpty {
                result.append(String(char))
            } else {
                currentGroup += char
                result.append(currentGroup)
                currentGroup = String()
            }
        } else {
            if currentGroup.isEmpty {
                result.append(String(char))
            } else {
                currentGroup += char
            }
        }
    }
    return result
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
currentGroup += char // cannot convert value of type 'Character' to expected argument type 'String'
currentGroup += char // cannot convert value of type 'Character' to expected argument type 'String'
currentGroup += char // cannot convert value of type 'Character' to expected argument type 'String'

func separateParenGroups(parenString: String) -> [String] {
    var result = [String]()
    var current = ""
    var open = 0
    for char in parenString {
        if char == "(" {
            open += 1
        } else if char == ")" {
            open -= 1
        }
        current += char
        if open == 0 {
            result.append(current)
            current = ""
        }
    }
    return result
}

func reverseString(string: String) -> String {
    var result = ""
    for char in string {
        result = char + result
    }
    return result
}

func capitalizeFirst(string: String) -> String {
    var result = ""
    var first = true
    for char in string {
        if first {
            result += char.uppercaseString
            first = false
        } else {
            result += char.lowercaseString
        }
    }
    return result
}

func removeSpaces(string: String) -> String {
    var result = ""
    for char in string {
        if char != " " {
            result += char
        }
    }
    return result
}
```swift
// Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
// separate those group into separate strings and return the array of those.
// Separate groups are balanced (each open brace is properly closed) and not nested within each other
// Ignore any spaces in the input string.
// separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"]
func separateParenGroups(parenString: String) -> [String] {
    var result = [String]()
    var current = ""
    var open = 0
    for char in parenString {
        if char == "(" {
            open += 1
        } else if char == ")" {
            open -= 1
        }
        current += char
        if open == 0 {
            result.append(current)
            current = ""
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 10. Write a function that takes a string as input and returns the string reversed.
// reverseString("hello") == "olleh"
func reverseString(string: String) -> String {
    var result = ""
    for char in string {
        result = char + result
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 11. Write a function that takes a string as input and returns the string with the first letter capitalized and the rest lowercase.
// capitalizeFirst("hello") == "Hello"
// capitalizeFirst("sHoRt AnD sToUt") == "Short And Stout"
func capitalizeFirst(string: String) -> String {
    var result = ""
    var first = true
    for char in string {
        if first {
            result += char.uppercaseString
            first = false
        } else {
            result += char.lowercaseString
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 12. Write a function that takes a string as input and returns the string with all the spaces removed,
// leaving only the original string's separators (e.g. spaces, commas, periods, etc.).
// removeSpaces("Hello, world!") == "Helloworld!"
// removeSpaces("Hi, my name is John.") == "Hi,mynameisJohn."
func removeSpaces(string: String) -> String {
    var result = ""
    for char in string {
        if char != " " {
            result += char
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 13. Write a function that takes a string as input and returns the string with all the spaces removed,
// leaving only the original string's separators (e.g. spaces, commas, periods, etc.).
// removeSpaces("Hello, world!") == "Helloworld!"
// removeSpaces("Hi, my name is John.") == "Hi,mynameisJohn."
func removeSpaces(string: String) -> String {
    var result = ""
    for char in string {
        if char != " " {
            result += char
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 14. Write a function that takes a string as input and returns the string with all the spaces removed,
// leaving only the original string's separators (e.g. spaces, commas, periods, etc.).
// removeSpaces("Hello, world!") == "Helloworld!"
// removeSpaces("Hi, my name is John.") == "Hi,mynameisJohn."
func removeSpaces(string: String) -> String {
    var result = ""
    for char in string {
        if char != " " {
            result += char
        }
    }
    return result
current += char // cannot convert value of type 'Character' to expected argument type 'String'
result = char + result // cannot convert value of type 'Character' to expected argument type 'String'
result += char.uppercaseString // value of type 'Character' has no member 'uppercaseString'
result += char.lowercaseString // value of type 'Character' has no member 'lowercaseString'
result += char // cannot convert value of type 'Character' to expected argument type 'String'

func separateParenGroups(parenString: String) -> [String] {
    var result = [String()]
    var current = String()
    for char in parenString {
        if char == "(" {
            current += "("
            result.append(current)
            current = String()
        } else if char == ")" {
            current += ")"
            result.append(current)
            current = String()
        } else {
            current += char
        }
    }
    return result
}
```swift
// Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
// separate those group into separate strings and return the array of those.
// Separate groups are balanced (each open brace is properly closed) and not nested within each other
// Ignore any spaces in the input string.
// separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"]
func separateParenGroups(parenString: String) -> [String] {
    var result = [String()]
    var current = String()
    for char in parenString {
        if char == "(" {
            current += "("
            result.append(current)
            current = String()
        } else if char == ")" {
            current += ")"
            result.append(current)
            current = String()
        } else {
            current += char
        }
    }
    return result
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
current += char // cannot convert value of type 'Character' to expected argument type 'String'

func separateParenGroups(parenString: String) -> [String] {
    var result = [String()]
    var current = String()
    for char in parenString {
        if char == "(" {
            if current != "" {
                result.append(current)
                current = ""
            }
            result.append("(")
        } else if char == ")" {
            if current != "" {
                result.append(current)
                current = ""
            }
            result.append(")")
        } else {
            current += char
        }
    }
    if current != "" {
        result.append(current)
    }
    return result
}
```swift
// Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
// separate those group into separate strings and return the array of those.
// Separate groups are balanced (each open brace is properly closed) and not nested within each other
// Ignore any spaces in the input string.
// separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"]
func separateParenGroups(parenString: String) -> [String] {
    var result = [String()]
    var current = String()
    for char in parenString {
        if char == "(" {
            if current != "" {
                result.append(current)
                current = ""
            }
            result.append("(")
        } else if char == ")" {
            if current != "" {
                result.append(current)
                current = ""
            }
            result.append(")")
        } else {
            current += char
        }
    }
    if current != "" {
        result.append(current)
    }
    return result
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
current += char // cannot convert value of type 'Character' to expected argument type 'String'

func separateParenGroups(parenString: String) -> [String] {
    var result = [String]()
    var current = ""
    var open = 0
    var close = 0
    for char in parenString {
        if char == "(" {
            open += 1
        } else if char == ")" {
            close += 1
        }
        current += char
        if open == close {
            result.append(current)
            current = ""
            open = 0
            close = 0
        }
    }
    return result
}
```swift
// Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
// separate those group into separate strings and return the array of those.
// Separate groups are balanced (each open brace is properly closed) and not nested within each other
// Ignore any spaces in the input string.
// separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"]
func separateParenGroups(parenString: String) -> [String] {
    var result = [String]()
    var current = ""
    var open = 0
    var close = 0
    for char in parenString {
        if char == "(" {
            open += 1
        } else if char == ")" {
            close += 1
        }
        current += char
        if open == close {
            result.append(current)
            current = ""
            open = 0
            close = 0
        }
    }
    return result
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
current += char // cannot convert value of type 'Character' to expected argument type 'String'

func truncateNumber(number: Double) -> Double {
  return number - Int(number)
}

func capitalizeFirst(string: String) -> String {
  return string.first!.uppercaseString + string.substring(1)
}
```swift
// Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (leftover part always smaller than 1).
// Return the decimal part of the number.
// truncateNumber(number: 3.5) == 0.5
func truncateNumber(number: Double) -> Double {
  return number - Int(number)
}

// -----------------------------------------------------------------------------
// 2. Write a function that takes a string and returns a string with the first
// character capitalized.
// capitalizeFirst("hello") == "Hello"
func capitalizeFirst(string: String) -> String {
  return string.first!.uppercaseString + string.substring(1)
}

// -----------------------------------------------------------------------------
// 3. Write a function that takes a string and returns a string with the first
// character capitalized.
// capitalizeFirst("hello") == "Hello"
func capitalizeFirst(string: String) -> String {
  return string.first!.uppercaseString + string.substring(1)
}

// -----------------------------------------------------------------------------
// 4. Write a function that takes a string and returns a string with the first
// character capitalized.
// capitalizeFirst("hello") == "Hello"
func capitalizeFirst(string: String) -> String {
  return string.first!.uppercaseString + string.substring(1)
}

// -----------------------------------------------------------------------------
// 5. Write a function that takes a string and returns a string with the first
// character capitalized.
// capitalizeFirst("hello") == "Hello"
func capitalizeFirst(string: String) -> String {
  return string.first!.uppercaseString + string.substring(1)
}

// -----------------------------------------------------------------------------
// 6. Write a function that takes a string and returns a string with the first
// character capitalized.
// capitalizeFirst("hello") == "Hello"
func capitalizeFirst(string: String) -> String {
  return string.first!.uppercaseString + string.substring(1)
}

// -----------------------------------------------------------------------------
// 7. Write a function that takes a string and returns a string with the first
// character capitalized.
// capitalizeFirst("hello") == "Hello"
func capitalizeFirst(string: String) -> String {
  return string.first!.uppercaseString + string.substring(1)
}

// -----------------------------------------------------------------------------
// 8. Write a function that takes a string and returns a string with the first
// character capitalized.
// capitalizeFirst("hello") == "Hello"
func capitalizeFirst(string: String) -> String {
  return string.first!.uppercaseString + string.substring(1)
}

// -----------------------------------------------------------------------------
// 9. Write a function that takes a string and returns a string with the first
// character capitalized.
// capitalizeFirst("hello") == "Hello"
func capitalizeFirst(string: String) -> String {
  return string.first!.uppercaseString + string.substring(1)
}

// -----------------------------------------------------------------------------
// 10. Write a function that takes a string and returns a string with the first
// character capitalized.
// capitalizeFirst("hello") == "Hello"
func capitalizeFirst(string: String) -> String {
  return string.first!.uppercaseString + string.substring(1)
}

// -----------------------------------------------------------------------------
// 11. Write a function that takes a string and returns a string with the first
// character capitalized.
// capitalizeFirst("hello") == "Hello"
func capitalizeFirst(string: String) -> String {
  return string.first!.uppercaseString + string.substring(1)
}

// ---------------------
return number - Int(number) // cannot convert value of type 'Int' to expected argument type 'Double'
return string.first!.uppercaseString + string.substring(1) // value of type 'String.Element' (aka 'Character') has no member 'uppercaseString'
return string.first!.uppercaseString + string.substring(1) // no exact matches in call to instance method 'substring'

func truncateNumber(number: Double) -> Double {
  return number - Int(number)
}
```swift
// Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (leftover part always smaller than 1).
// Return the decimal part of the number.
// truncateNumber(number: 3.5) == 0.5
func truncateNumber(number: Double) -> Double {
  return number - Int(number)
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ------------------------------------
return number - Int(number) // cannot convert value of type 'Int' to expected argument type 'Double'

func truncateNumber(number: Double) -> Double {
    return number - Int(number)
}
```swift
// Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (leftover part always smaller than 1).
// Return the decimal part of the number.
// truncateNumber(number: 3.5) == 0.5
func truncateNumber(number: Double) -> Double {
    return number - Int(number)
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ---------------------------------------------------------------------
return number - Int(number) // cannot convert value of type 'Int' to expected argument type 'Double'

func truncateNumber(number: Double) -> Double {
    return number - Int(number)
}
```swift
// Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (leftover part always smaller than 1).
// Return the decimal part of the number.
// truncateNumber(number: 3.5) == 0.5
func truncateNumber(number: Double) -> Double {
    return number - Int(number)
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ---------------------------------------------------------------------
return number - Int(number) // cannot convert value of type 'Int' to expected argument type 'Double'

func truncateNumber(number: Double) -> Double {
    return number - Int(number)
}
```swift
// Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (leftover part always smaller than 1).
// Return the decimal part of the number.
// truncateNumber(number: 3.5) == 0.5
func truncateNumber(number: Double) -> Double {
    return number - Int(number)
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ------------------------------------
return number - Int(number) // cannot convert value of type 'Int' to expected argument type 'Double'

func truncateNumber(number: Double) -> Double {
    return number - Int(number)
}

func truncateNumber(number: Double) -> Int {
    return Int(number)
}
```swift
// Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (leftover part always smaller than 1).
// Return the decimal part of the number.
// truncateNumber(number: 3.5) == 0.5
func truncateNumber(number: Double) -> Double {
    return number - Int(number)
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (leftover part always smaller than 1).
// Return the integer part of the number.
// truncateNumber(number: 3.5) == 3
func truncateNumber(number: Double) -> Int {
    return Int(number)
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (leftover part always smaller than 1).
// Return the integer part of the number.
// truncateNumber(number: 3.5) == 3
func truncateNumber(number: Double) -> Int {
    return Int(number)
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (leftover part always smaller than 1).
// Return the integer part of the number.
// truncateNumber(number: 3.5) == 3
func truncateNumber(number: Double) -> Int {
    return Int(number)
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (leftover part always smaller than 1).
// Return the integer part of the number.
// truncateNumber(number: 3.5) == 3
func truncateNumber(number: Double) -> Int {
    return Int(number)
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (leftover part always smaller than 1).
// Return the integer part of the number.
// truncateNumber(number: 3.5) == 3
func truncateNumber(number: Double) -> Int {
    return Int(number)
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (leftover part always smaller than 1).
// Return the integer part of the number.
// truncateNumber(number: 3.5) == 3
func truncateNumber(number: Double) -> Int {
    return Int(number)
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (lef
return number - Int(number) // cannot convert value of type 'Int' to expected argument type 'Double'

func truncateNumber(number: Double) -> Double {
    return number - Int(number)
}
```swift
// Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (leftover part always smaller than 1).
// Return the decimal part of the number.
// truncateNumber(number: 3.5) == 0.5
func truncateNumber(number: Double) -> Double {
    return number - Int(number)
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ---------------------------------------------------------------------
return number - Int(number) // cannot convert value of type 'Int' to expected argument type 'Double'

func truncateNumber(number: Double) -> Double {
    return number - Int(number)
}
```swift
// Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (leftover part always smaller than 1).
// Return the decimal part of the number.
// truncateNumber(number: 3.5) == 0.5
func truncateNumber(number: Double) -> Double {
    return number - Int(number)
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ---------------------------------------------------------------------
return number - Int(number) // cannot convert value of type 'Int' to expected argument type 'Double'

func truncateNumber(number: Double) -> Double {
  return number - Int(number)
}

func truncateNumber(number: Double) -> Int {
  return Int(number)
}
```swift
// Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (leftover part always smaller than 1).
// Return the decimal part of the number.
// truncateNumber(number: 3.5) == 0.5
func truncateNumber(number: Double) -> Double {
  return number - Int(number)
}

// -----------------------------------------------------------------------------
// 1.1.2
// -----------------------------------------------------------------------------
// Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (leftover part always smaller than 1).
// Return the integer part of the number.
// truncateNumber(number: 3.5) == 3
func truncateNumber(number: Double) -> Int {
  return Int(number)
}

// -----------------------------------------------------------------------------
// 1.2
// -----------------------------------------------------------------------------
// Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (leftover part always smaller than 1).
// Return the integer part of the number.
// truncateNumber(number: 3.5) == 3
func truncateNumber(number: Double) -> Int {
  return Int(number)
}

// -----------------------------------------------------------------------------
// 1.3
// -----------------------------------------------------------------------------
// Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (leftover part always smaller than 1).
// Return the integer part of the number.
// truncateNumber(number: 3.5) == 3
func truncateNumber(number: Double) -> Int {
  return Int(number)
}

// -----------------------------------------------------------------------------
// 1.4
// -----------------------------------------------------------------------------
// Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (leftover part always smaller than 1).
// Return the integer part of the number.
// truncateNumber(number: 3.5) == 3
func truncateNumber(number: Double) -> Int {
  return Int(number)
}

// -----------------------------------------------------------------------------
// 1.5
// -----------------------------------------------------------------------------
// Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (leftover part always smaller than 1).
// Return the integer part of the number.
// truncateNumber(number: 3.5) == 3
func truncateNumber(number: Double) -> Int {
  return Int(number)
}

// -----------------------------------------------------------------------------
// 1.6
// -----------------------------------------------------------------------------
// Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (leftover part always smaller than 1).
// Return the integer part of the number.
// truncateNumber(number: 3.5) == 3
func truncateNumber(number: Double) -> Int {
  return Int(number)
}

// -----------------------------------------------------------------------------
// 1.7
// ------------------------------------------------------------------------
return number - Int(number) // cannot convert value of type 'Int' to expected argument type 'Double'

func truncateNumber(number: Double) -> Double {
    return number - Int(number)
}

func truncateNumber(number: Double) -> Int {
    return Int(number)
}
```swift
// Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (leftover part always smaller than 1).
// Return the decimal part of the number.
// truncateNumber(number: 3.5) == 0.5
func truncateNumber(number: Double) -> Double {
    return number - Int(number)
}

// -----------------------------------------------------------------------------
// 2. Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (leftover part always smaller than 1).
// Return the integer part of the number.
// truncateNumber(number: 3.5) == 3
func truncateNumber(number: Double) -> Int {
    return Int(number)
}

// -----------------------------------------------------------------------------
// 3. Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (leftover part always smaller than 1).
// Return the integer part of the number.
// truncateNumber(number: 3.5) == 3
func truncateNumber(number: Double) -> Int {
    return Int(number)
}

// -----------------------------------------------------------------------------
// 4. Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (leftover part always smaller than 1).
// Return the integer part of the number.
// truncateNumber(number: 3.5) == 3
func truncateNumber(number: Double) -> Int {
    return Int(number)
}

// -----------------------------------------------------------------------------
// 5. Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (leftover part always smaller than 1).
// Return the integer part of the number.
// truncateNumber(number: 3.5) == 3
func truncateNumber(number: Double) -> Int {
    return Int(number)
}

// -----------------------------------------------------------------------------
// 6. Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (leftover part always smaller than 1).
// Return the integer part of the number.
// truncateNumber(number: 3.5) == 3
func truncateNumber(number: Double) -> Int {
    return Int(number)
}

// -----------------------------------------------------------------------------
// 7. Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (leftover part always smaller than 1).
// Return the integer part of the number.
// truncateNumber(number: 3.5) == 3
func truncateNumber(number: Double) -> Int {
    return Int(number)
}

// -----------------------------------------------------------------------------
// 8. Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (leftover part always smaller than 1).
// Return the integer part of the number.
// truncateNumber(number: 3.5) == 3
func truncateNumber(number: Double) -> Int {
    return Int(number)
}

// -----------------------------------------------------------------------------
// 9. Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (leftover part always smaller than 1).
// Return the integer part of the number.
// truncateNumber(number: 3.5) == 3
func truncateNumber(number: Double) -> Int {
    return Int(number)
}

// ---
return number - Int(number) // cannot convert value of type 'Int' to expected argument type 'Double'

func belowZero(operations: [Int]) -> Bool {
    var balance = 0
    for operation in operations {
        balance += operation
        if balance < 0 {
            return true
        }
    }
    return false
}

func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}
```swift
// You're given an array of deposit and withdrawal operations on a bank account that starts with
// zero balance. Your task is to detect if at any point the balance of account fallls below zero, and
// at that point function should return true. Otherwise it should return false.
// belowZero(operations: [1, 2, 3]) == false
// belowZero(operations: [1, 2, -4, 5]) == true
func belowZero(operations: [Int]) -> Bool {
    var balance = 0
    for operation in operations {
        balance += operation
        if balance < 0 {
            return true
        }
    }
    return false
}

// 11. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
// removeVowels("aeiou") == ""
// removeVowels("abcdefghijklmnopqrstuvwxyz") == "bcdfghjklmnpqrstvwxyz"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// 12. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
// removeVowels("aeiou") == ""
// removeVowels("abcdefghijklmnopqrstuvwxyz") == "bcdfghjklmnpqrstvwxyz"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// 13. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
// removeVowels("aeiou") == ""
// removeVowels("abcdefghijklmnopqrstuvwxyz") == "bcdfghjklmnpqrstvwxyz"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// 14. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
// removeVowels("aeiou") == ""
// removeVowels("abcdefghijklmnopqrstuvwxyz") == "bcdfghjklmnpqrstvwxyz"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// 15. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
// removeVowels("aeiou") == ""
// removeVowels("abcdefghijklmnopqrstuvwxyz") == "bcdfghjklmnpqrstvwxyz"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// 16. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
// removeVowels("aeiou") == ""
// removeVowels("abcdefghijkl
if !isVowel(char) { // cannot find 'isVowel' in scope
result += char // cannot convert value of type 'Character' to expected argument type 'String'

func belowZero(operations: [Int]) -> Bool {
    var balance = 0
    for operation in operations {
        balance += operation
        if balance < 0 {
            return true
        }
    }
    return false
}

func countVowels(input: String) -> Int {
    var vowels = 0
    for char in input {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            vowels += 1
        }
    }
    return vowels
}

func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            continue
        }
        result += char
    }
    return result
}
```swift
// You're given an array of deposit and withdrawal operations on a bank account that starts with
// zero balance. Your task is to detect if at any point the balance of account fallls below zero, and
// at that point function should return true. Otherwise it should return false.
// belowZero(operations: [1, 2, 3]) == false
// belowZero(operations: [1, 2, -4, 5]) == true
func belowZero(operations: [Int]) -> Bool {
    var balance = 0
    for operation in operations {
        balance += operation
        if balance < 0 {
            return true
        }
    }
    return false
}

// 2. Write a function that takes a string and returns the number (count) of vowels contained in it.
// Valid vowels are: a, e, i, o, u.
// countVowels("abracadabra") == 5
// countVowels("pear tree") == 5
// countVowels("o a kak ushakov lil vo kashu kakao") == 12
// countVowels("harvey") == 4
func countVowels(input: String) -> Int {
    var vowels = 0
    for char in input {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            vowels += 1
        }
    }
    return vowels
}

// 3. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
// removeVowels("abracadabra") == "brcrdrvbr"
// removeVowels("pear tree") == "pr t"
// removeVowels("o a kak ushakov lil vo kashu kakao") == " kv kv kv"
// removeVowels("harvey") == "hrv"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            continue
        }
        result += char
    }
    return result
}

// 4. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
// removeVowels("abracadabra") == "brcrdrvbr"
// removeVowels("pear tree") == "pr t"
// removeVowels("o a kak ushakov lil vo kashu kakao") == " kv kv kv"
// removeVowels("harvey") == "hrv"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            continue
        }
        result += char
    }
    return result
}

// 5. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
// removeVowels("abracadabra") == "brcrdrvbr"
// removeVowels("pear tree") == "pr t"
// removeVowels("o a kak ushakov lil vo kashu kakao") == " kv kv kv"
// removeVowels("harvey") == "hrv"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            continue
        }
        result += char
    }
    return result
}

// 6. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnk
result += char // cannot convert value of type 'Character' to expected argument type 'String'

func belowZero(operations: [Int]) -> Bool {
    var balance = 0
    for operation in operations {
        balance += operation
        if balance < 0 {
            return true
        }
    }
    return false
}

func reverseString(string: String) -> String {
    var reversed = ""
    for char in string {
        reversed = char + reversed
    }
    return reversed
}

func countDigits(number: Int) -> Int {
    var count = 0
    while number > 0 {
        number /= 10
        count += 1
    }
    return count
}

func sumDigits(number: Int) -> Int {
    var sum = 0
    while number > 0 {
        sum += number % 10
        number /= 10
    }
    return sum
}
```swift
// You're given an array of deposit and withdrawal operations on a bank account that starts with
// zero balance. Your task is to detect if at any point the balance of account fallls below zero, and
// at that point function should return true. Otherwise it should return false.
// belowZero(operations: [1, 2, 3]) == false
// belowZero(operations: [1, 2, -4, 5]) == true
func belowZero(operations: [Int]) -> Bool {
    var balance = 0
    for operation in operations {
        balance += operation
        if balance < 0 {
            return true
        }
    }
    return false
}

// 12. Write a function that takes a string as input and returns the string reversed.
// reverseString("hello") == "olleh"
func reverseString(string: String) -> String {
    var reversed = ""
    for char in string {
        reversed = char + reversed
    }
    return reversed
}

// 13. Write a function that takes a number as input and returns the number of digits in the
// number.
// countDigits(123) == 3
func countDigits(number: Int) -> Int {
    var count = 0
    while number > 0 {
        number /= 10
        count += 1
    }
    return count
}

// 14. Write a function that takes a number as input and returns the sum of the digits in the
// number.
// sumDigits(123) == 6
func sumDigits(number: Int) -> Int {
    var sum = 0
    while number > 0 {
        sum += number % 10
        number /= 10
    }
    return sum
}

// 15. Write a function that takes a number as input and returns the sum of the digits in the
// number.
// sumDigits(123) == 6
func sumDigits(number: Int) -> Int {
    var sum = 0
    while number > 0 {
        sum += number % 10
        number /= 10
    }
    return sum
}

// 16. Write a function that takes a number as input and returns the sum of the digits in the
// number.
// sumDigits(123) == 6
func sumDigits(number: Int) -> Int {
    var sum = 0
    while number > 0 {
        sum += number % 10
        number /= 10
    }
    return sum
}

// 17. Write a function that takes a number as input and returns the sum of the digits in the
// number.
// sumDigits(123) == 6
func sumDigits(number: Int) -> Int {
    var sum = 0
    while number > 0 {
        sum += number % 10
        number /= 10
    }
    return sum
}

// 18. Write a function that takes a number as input and returns the sum of the digits in the
// number.
// sumDigits(123) == 6
func sumDigits(number: Int) -> Int {
    var sum = 0
    while number > 0 {
        sum += number % 10
        number /= 10
    }
    return sum
}

// 19. Write a function that takes a number as input and returns the sum of the digits in the
// number.
// sumDigits(123) == 6
func sumDigits(number: Int) -> Int {
    var sum = 0
    while number > 0 {
        sum += number % 10
        number /= 10
    }
    return sum
}

// 20. Write a function that takes a number as input and returns the sum of the digits in the
// number.
// sumDigits(123) == 6
func sumDigits(number: Int) -> Int {
    var sum = 0
    while number > 0 {
        sum += number % 10
        number /= 10
    }
    return sum
}

// 21. Write a function that takes a number as input and returns the sum of the digits in the
// number.
// sumDigits(123) == 6
func sumDigits(number: Int) -> Int {
    var sum = 0
    while number > 0 {
        sum += number % 10
        number /= 10
    }
    return sum
}

// 22. Write a function that takes a number as input and returns the sum of the digits in the
// number.
// sumDigits(123) == 
reversed = char + reversed // cannot convert value of type 'Character' to expected argument type 'String'
number /= 10 // left side of mutating operator isn't mutable: 'number' is a 'let' constant
number /= 10 // left side of mutating operator isn't mutable: 'number' is a 'let' constant

func belowZero(operations: [Int]) -> Bool {
    var balance = 0
    for operation in operations {
        balance += operation
        if balance < 0 {
            return true
        }
    }
    return false
}

func removeVowels(input: String) -> String {
    var output = ""
    for char in input {
        if !isVowel(char) {
            output += char
        }
    }
    return output
}
```swift
// You're given an array of deposit and withdrawal operations on a bank account that starts with
// zero balance. Your task is to detect if at any point the balance of account fallls below zero, and
// at that point function should return true. Otherwise it should return false.
// belowZero(operations: [1, 2, 3]) == false
// belowZero(operations: [1, 2, -4, 5]) == true
func belowZero(operations: [Int]) -> Bool {
    var balance = 0
    for operation in operations {
        balance += operation
        if balance < 0 {
            return true
        }
    }
    return false
}

// ------------------------------------------------------------------------------------------------
// 11. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I am awesome!") == " m  wmn  !"
func removeVowels(input: String) -> String {
    var output = ""
    for char in input {
        if !isVowel(char) {
            output += char
        }
    }
    return output
}

// ------------------------------------------------------------------------------------------------
// 12. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I am awesome!") == " m  wmn  !"
func removeVowels(input: String) -> String {
    var output = ""
    for char in input {
        if !isVowel(char) {
            output += char
        }
    }
    return output
}

// ------------------------------------------------------------------------------------------------
// 13. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I am awesome!") == " m  wmn  !"
func removeVowels(input: String) -> String {
    var output = ""
    for char in input {
        if !isVowel(char) {
            output += char
        }
    }
    return output
}

// ------------------------------------------------------------------------------------------------
// 14. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I am awesome!") == " m  wmn  !"
func removeVowels(input: String) -> String {
    var output = ""
    for char in input {
        if !isVowel(char) {
            output += char
        }
    }
    return output
}

// ------------------------------------------------------------------------------------------------
// 15. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I am awesome!") == " m  wmn  !"
func removeVowels(input: String) -> String {
    var output = ""
    for char in input {
        if !isVowel(char) {
            output += char
        }
    }
    return output
}

// ------------------------------------------------------------------------------------------------
// 16. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I am awesome!") == " m  wmn  !"
func removeVowels(input: String) -> String {
    var output = ""
    for char in input {
        if !isVowel(char) {
            output += char
        }
    }
    return output
}

// ------------------------------------------------------------------------------------------------
// 17. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I am awesome!") == " m  wmn  !"
func removeVowels(input: String) -> String {
    var output = ""
    for char in input {
        if !isVowel(char) {
            output += char
        }
    }
if !isVowel(char) { // cannot find 'isVowel' in scope
output += char // cannot convert value of type 'Character' to expected argument type 'String'

func belowZero(operations: [Int]) -> Bool {
    var balance = 0
    for operation in operations {
        balance += operation
        if balance < 0 {
            return true
        }
    }
    return false
}
```swift
// You're given an array of deposit and withdrawal operations on a bank account that starts with
// zero balance. Your task is to detect if at any point the balance of account fallls below zero, and
// at that point function should return true. Otherwise it should return false.
// belowZero(operations: [1, 2, 3]) == false
// belowZero(operations: [1, 2, -4, 5]) == true
func belowZero(operations: [Int]) -> Bool {
    var balance = 0
    for operation in operations {
        balance += operation
        if balance < 0 {
            return true
        }
    }
    return false
}

// ------------------------------------------------------------------------------------------------
// 2. Given an array of integers, find the first missing positive integer in linear time and constant
// space. In other words, find the lowest positive integer that does not exist in the array.
// The array can contain duplicates and negative numbers as well.
// For example, the input [3, 4, -1, 1] should give 2. The input [1, 2, 0] should give 3.
// You can modify the input array in-place.
// ------------------------------------------------------------------------------------------------
// 1. You can modify the input array in-place.
// 2. You can use extra space.
// 3. You can sort the array.
// 4. You can use extra space.
// 5. You can sort the array.
// 6. You can sort the array.
// 7. You can sort the array.
// 8. You can sort the array.
// 9. You can sort the array.
// 10. You can sort the array.
// 11. You can sort the array.
// 12. You can sort the array.
// 13. You can sort the array.
// 14. You can sort the array.
// 15. You can sort the array.
// 16. You can sort the array.
// 17. You can sort the array.
// 18. You can sort the array.
// 19. You can sort the array.
// 20. You can sort the array.
// 21. You can sort the array.
// 22. You can sort the array.
// 23. You can sort the array.
// 24. You can sort the array.
// 25. You can sort the array.
// 26. You can sort the array.
// 27. You can sort the array.
// 28. You can sort the array.
// 29. You can sort the array.
// 30. You can sort the array.
// 31. You can sort the array.
// 32. You can sort the array.
// 33. You can sort the array.
// 34. You can sort the array.
// 35. You can sort the array.
// 36. You can sort the array.
// 37. You can sort the array.
// 38. You can sort the array.
// 39. You can sort the array.
// 40. You can sort the array.
// 41. You can sort the array.
// 42. You can sort the array.
// 43. You can sort the array.
// 44. You can sort the array.
// 45. You can sort the array.
// 46. You can sort the array.
// 47. You can sort the array.
// 48. You can sort the array.
// 49. You can sort the array.
// 50. You can sort the array.
// 51. You can sort the array.
// 52. You can sort the array.
// 53. You can sort the array.
// 54. You can sort the array.
// 55. You can sort the array.
// 56. You can sort the array.
// 57. You can sort the array.
// 58. You can sort the array.
// 59. You can sort the array.
// 60. You can sort the array.
// 61. You can sort the array.
// 62. You can sort the array.
// 63. You can sort the array.
// 64. You can sort the array.
// 65. You can sort the array.
// 66. You can sort the array.
// 67. You can sort the array.
//

func belowZero(operations: [Int]) -> Bool {
    var balance = 0
    for operation in operations {
        balance += operation
        if balance < 0 {
            return true
        }
    }
    return false
}
```swift
// You're given an array of deposit and withdrawal operations on a bank account that starts with
// zero balance. Your task is to detect if at any point the balance of account fallls below zero, and
// at that point function should return true. Otherwise it should return false.
// belowZero(operations: [1, 2, 3]) == false
// belowZero(operations: [1, 2, -4, 5]) == true
func belowZero(operations: [Int]) -> Bool {
    var balance = 0
    for operation in operations {
        balance += operation
        if balance < 0 {
            return true
        }
    }
    return false
}

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ---------------------------------------------------------------------

func belowZero(operations: [Int]) -> Bool {
    var balance = 0
    for operation in operations {
        balance += operation
        if balance < 0 {
            return true
        }
    }
    return false
}
```swift
// You're given an array of deposit and withdrawal operations on a bank account that starts with
// zero balance. Your task is to detect if at any point the balance of account fallls below zero, and
// at that point function should return true. Otherwise it should return false.
// belowZero(operations: [1, 2, 3]) == false
// belowZero(operations: [1, 2, -4, 5]) == true
func belowZero(operations: [Int]) -> Bool {
    var balance = 0
    for operation in operations {
        balance += operation
        if balance < 0 {
            return true
        }
    }
    return false
}

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ---------------------------------------------------------------------

func belowZero(operations: [Int]) -> Bool {
    var balance = 0
    for operation in operations {
        balance += operation
        if balance < 0 {
            return true
        }
    }
    return false
}
```swift
// You're given an array of deposit and withdrawal operations on a bank account that starts with
// zero balance. Your task is to detect if at any point the balance of account fallls below zero, and
// at that point function should return true. Otherwise it should return false.
// belowZero(operations: [1, 2, 3]) == false
// belowZero(operations: [1, 2, -4, 5]) == true
func belowZero(operations: [Int]) -> Bool {
    var balance = 0
    for operation in operations {
        balance += operation
        if balance < 0 {
            return true
        }
    }
    return false
}

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------

func belowZero(operations: [Int]) -> Bool {
    var balance = 0
    for operation in operations {
        balance += operation
        if balance < 0 {
            return true
        }
    }
    return false
}
```swift
// You're given an array of deposit and withdrawal operations on a bank account that starts with
// zero balance. Your task is to detect if at any point the balance of account fallls below zero, and
// at that point function should return true. Otherwise it should return false.
// belowZero(operations: [1, 2, 3]) == false
// belowZero(operations: [1, 2, -4, 5]) == true
func belowZero(operations: [Int]) -> Bool {
    var balance = 0
    for operation in operations {
        balance += operation
        if balance < 0 {
            return true
        }
    }
    return false
}

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

func belowZero(operations: [Int]) -> Bool {
    var balance = 0
    for operation in operations {
        balance += operation
        if balance < 0 {
            return true
        }
    }
    return false
}

func firstMissingPositive(numbers: [Int]) -> Int {
    var i = 1
    while true {
        if !numbers.contains(i) {
            return i
        }
        i += 1
    }
}
```swift
// You're given an array of deposit and withdrawal operations on a bank account that starts with
// zero balance. Your task is to detect if at any point the balance of account fallls below zero, and
// at that point function should return true. Otherwise it should return false.
// belowZero(operations: [1, 2, 3]) == false
// belowZero(operations: [1, 2, -4, 5]) == true
func belowZero(operations: [Int]) -> Bool {
    var balance = 0
    for operation in operations {
        balance += operation
        if balance < 0 {
            return true
        }
    }
    return false
}

// 2. Given an array of integers, find the first missing positive integer in linear time and constant
// space. In other words, find the lowest positive integer that does not exist in the array.
// The array can contain duplicates and negative numbers as well.
// For example, the input [3, 4, -1, 1] should give 2. The input [1, 2, 0] should give 3.
// You can modify the input array in-place.
// belowZero(operations: [1, 2, 3]) == false
// belowZero(operations: [1, 2, -4, 5]) == true
func firstMissingPositive(numbers: [Int]) -> Int {
    var i = 1
    while true {
        if !numbers.contains(i) {
            return i
        }
        i += 1
    }
}

// 3. Given an array of integers, find the first missing positive integer in linear time and constant
// space. In other words, find the lowest positive integer that does not exist in the array.
// The array can contain duplicates and negative numbers as well.
// For example, the input [3, 4, -1, 1] should give 2. The input [1, 2, 0] should give 3.
// You can modify the input array in-place.
// belowZero(operations: [1, 2, 3]) == false
// belowZero(operations: [1, 2, -4, 5]) == true
func firstMissingPositive(numbers: [Int]) -> Int {
    var i = 1
    while true {
        if !numbers.contains(i) {
            return i
        }
        i += 1
    }
}

// 4. Given an array of integers, find the first missing positive integer in linear time and constant
// space. In other words, find the lowest positive integer that does not exist in the array.
// The array can contain duplicates and negative numbers as well.
// For example, the input [3, 4, -1, 1] should give 2. The input [1, 2, 0] should give 3.
// You can modify the input array in-place.
// belowZero(operations: [1, 2, 3]) == false
// belowZero(operations: [1, 2, -4, 5]) == true
func firstMissingPositive(numbers: [Int]) -> Int {
    var i = 1
    while true {
        if !numbers.contains(i) {
            return i
        }
        i += 1
    }
}

// 5. Given an array of integers, find the first missing positive integer in linear time and constant
// space. In other words, find the lowest positive integer that does not exist in the array.
// The array can contain duplicates and negative numbers as well.
// For example, the input [3, 4, -1, 1] should give 2. The input [1, 2, 0] should give 3.
// You can modify the input array in-place.
// belowZero(operations: [1, 2, 3]) == false
// belowZero(operations: [1, 2, -4, 5]) == true
func firstMissingPositive(numbers: [Int]) -> Int {
    var i = 1
    while true {
        if !numbers.contains(i) {
            return i
        }
        i += 1
    }
}

// 6. Given an array of integers, find the first missing positive integer in linear time and constant
// space. In other words, find the lowest positive integer that does not exist in the array.
// The array can contain duplicates and negative numbers as well.
// For example, the input [3, 4, -1, 1] should give 2. The input [1, 2, 0] should give 3.
// You can modify the input array in-place.
// belowZero(operations: [1, 2, 3]) == false
// belowZero(operations: [1, 2, -4, 5]) == true
func firstMissingPositive(numbers

func meanAbsoluteDeviation(numbers: [Double]) -> Double {
    let mean = numbers.reduce(0.0, { (sum: Double, element: Double) -> Double in
        return sum + element
    }) / numbers.count
    let deviations = numbers.map { (x: Double) -> Double in
        return abs(x - mean)
    }
    let mad = deviations.reduce(0.0, { (sum: Double, element: Double) -> Double in
        return sum + element
    }) / deviations.count
    return mad
}
```swift
// For a given array of input numbers, calculate Mean Absolute Deviation
// around the mean of this dataset.
// Mean Absolute Deviation is the average absolute difference between each
// element and a centerpoint (mean in this case):
// MAD = average | x - x_mean |
// meanAbsoluteDeviation(numbers: [1.0, 2.0, 3.0, 4.0]) == 1.0
func meanAbsoluteDeviation(numbers: [Double]) -> Double {
    let mean = numbers.reduce(0.0, { (sum: Double, element: Double) -> Double in
        return sum + element
    }) / numbers.count
    let deviations = numbers.map { (x: Double) -> Double in
        return abs(x - mean)
    }
    let mad = deviations.reduce(0.0, { (sum: Double, element: Double) -> Double in
        return sum + element
    }) / deviations.count
    return mad
}

// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ------------------------
}) / numbers.count // binary operator '/' cannot be applied to operands of type 'Double' and 'Int'

func meanAbsoluteDeviation(numbers: [Double]) -> Double {
    let mean = numbers.reduce(0.0, { (sum, x) -> Double in
        sum + x
    }) / numbers.count
    let deviations = numbers.map { x in
        abs(x - mean)
    }
    let mad = deviations.reduce(0.0, { (sum, x) -> Double in
        sum + x
    }) / numbers.count
    return mad
}
```swift
// For a given array of input numbers, calculate Mean Absolute Deviation
// around the mean of this dataset.
// Mean Absolute Deviation is the average absolute difference between each
// element and a centerpoint (mean in this case):
// MAD = average | x - x_mean |
// meanAbsoluteDeviation(numbers: [1.0, 2.0, 3.0, 4.0]) == 1.0
func meanAbsoluteDeviation(numbers: [Double]) -> Double {
    let mean = numbers.reduce(0.0, { (sum, x) -> Double in
        sum + x
    }) / numbers.count
    let deviations = numbers.map { x in
        abs(x - mean)
    }
    let mad = deviations.reduce(0.0, { (sum, x) -> Double in
        sum + x
    }) / numbers.count
    return mad
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ---------------------------------------------
}) / numbers.count // binary operator '/' cannot be applied to operands of type 'Double' and 'Int'

func meanAbsoluteDeviation(numbers: [Double]) -> Double {
    let mean = numbers.mean()
    let deviations = numbers.map { $0 - mean }
    let absDeviations = deviations.map { abs($0) }
    return absDeviations.mean()
}
```swift
// For a given array of input numbers, calculate Mean Absolute Deviation
// around the mean of this dataset.
// Mean Absolute Deviation is the average absolute difference between each
// element and a centerpoint (mean in this case):
// MAD = average | x - x_mean |
// meanAbsoluteDeviation(numbers: [1.0, 2.0, 3.0, 4.0]) == 1.0
func meanAbsoluteDeviation(numbers: [Double]) -> Double {
    let mean = numbers.mean()
    let deviations = numbers.map { $0 - mean }
    let absDeviations = deviations.map { abs($0) }
    return absDeviations.mean()
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ---------------------------------
let mean = numbers.mean() // value of type '[Double]' has no member 'mean'

func meanAbsoluteDeviation(numbers: [Double]) -> Double {
    let mean = numbers.reduce(0.0, { (sum: Double, x: Double) -> Double {
        return sum + x
    } }) / numbers.count
    let deviations = numbers.map { $0 - mean }
    return deviations.reduce(0.0, { (sum: Double, x: Double) -> Double {
        return sum + abs(x)
    } }) / numbers.count
}
```swift
// For a given array of input numbers, calculate Mean Absolute Deviation
// around the mean of this dataset.
// Mean Absolute Deviation is the average absolute difference between each
// element and a centerpoint (mean in this case):
// MAD = average | x - x_mean |
// meanAbsoluteDeviation(numbers: [1.0, 2.0, 3.0, 4.0]) == 1.0
func meanAbsoluteDeviation(numbers: [Double]) -> Double {
    let mean = numbers.reduce(0.0, { (sum: Double, x: Double) -> Double {
        return sum + x
    } }) / numbers.count
    let deviations = numbers.map { $0 - mean }
    return deviations.reduce(0.0, { (sum: Double, x: Double) -> Double {
        return sum + abs(x)
    } }) / numbers.count
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ------------------------------------------------------------------------
let mean = numbers.reduce(0.0, { (sum: Double, x: Double) -> Double { // expected type after '->'
let mean = numbers.reduce(0.0, { (sum: Double, x: Double) -> Double { // contextual type for closure argument list expects 2 arguments, which cannot be implicitly ignored
return sum + x // cannot find 'sum' in scope
return sum + x // cannot find 'x' in scope
} }) / numbers.count // binary operator '/' cannot be applied to operands of type 'Double' and 'Int'
return deviations.reduce(0.0, { (sum: Double, x: Double) -> Double { // expected type after '->'
return sum + abs(x) // cannot find 'x' in scope
return sum + abs(x) // cannot find 'sum' in scope
} }) / numbers.count // no '/' candidates produce the expected contextual result type 'Double'

func meanAbsoluteDeviation(numbers: [Double]) -> Double {
    let mean = numbers.reduce(0.0, { (sum: Double, x: Double) -> Double {
        return sum + x
    } }) / numbers.count
    let deviations = numbers.map { $0 - mean }
    let absDeviations = deviations.map { abs($0) }
    return absDeviations.reduce(0.0, { (sum: Double, x: Double) -> Double {
        return sum + x
    } }) / absDeviations.count
}
```swift
// For a given array of input numbers, calculate Mean Absolute Deviation
// around the mean of this dataset.
// Mean Absolute Deviation is the average absolute difference between each
// element and a centerpoint (mean in this case):
// MAD = average | x - x_mean |
// meanAbsoluteDeviation(numbers: [1.0, 2.0, 3.0, 4.0]) == 1.0
func meanAbsoluteDeviation(numbers: [Double]) -> Double {
    let mean = numbers.reduce(0.0, { (sum: Double, x: Double) -> Double {
        return sum + x
    } }) / numbers.count
    let deviations = numbers.map { $0 - mean }
    let absDeviations = deviations.map { abs($0) }
    return absDeviations.reduce(0.0, { (sum: Double, x: Double) -> Double {
        return sum + x
    } }) / absDeviations.count
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ---------------------------------------------------------------------
let mean = numbers.reduce(0.0, { (sum: Double, x: Double) -> Double { // expected type after '->'
let mean = numbers.reduce(0.0, { (sum: Double, x: Double) -> Double { // contextual type for closure argument list expects 2 arguments, which cannot be implicitly ignored
return sum + x // cannot find 'sum' in scope
return sum + x // cannot find 'x' in scope
} }) / numbers.count // binary operator '/' cannot be applied to operands of type 'Double' and 'Int'
return absDeviations.reduce(0.0, { (sum: Double, x: Double) -> Double { // expected type after '->'
return sum + x // cannot find 'sum' in scope
return sum + x // cannot find 'x' in scope

func meanAbsoluteDeviation(numbers: [Double]) -> Double {
    let mean = numbers.reduce(0.0, { (sum, element) -> Double in
        return sum + element
    }) / numbers.count
    let deviations = numbers.map { (element) -> Double in
        return abs(element - mean)
    }
    return deviations.reduce(0.0, { (sum, element) -> Double in
        return sum + element
    }) / numbers.count
}
```swift
// For a given array of input numbers, calculate Mean Absolute Deviation
// around the mean of this dataset.
// Mean Absolute Deviation is the average absolute difference between each
// element and a centerpoint (mean in this case):
// MAD = average | x - x_mean |
// meanAbsoluteDeviation(numbers: [1.0, 2.0, 3.0, 4.0]) == 1.0
func meanAbsoluteDeviation(numbers: [Double]) -> Double {
    let mean = numbers.reduce(0.0, { (sum, element) -> Double in
        return sum + element
    }) / numbers.count
    let deviations = numbers.map { (element) -> Double in
        return abs(element - mean)
    }
    return deviations.reduce(0.0, { (sum, element) -> Double in
        return sum + element
    }) / numbers.count
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// ------------------------
}) / numbers.count // binary operator '/' cannot be applied to operands of type 'Double' and 'Int'
}) / numbers.count // no '/' candidates produce the expected contextual result type 'Double'

func meanAbsoluteDeviation(numbers: [Double]) -> Double {
    let mean = numbers.reduce(0.0, { (sum, x) -> Double in
        sum + x
    }) / numbers.count
    let deviations = numbers.map { x in
        abs(x - mean)
    }
    let mad = deviations.reduce(0.0, { (sum, x) -> Double in
        sum + x
    }) / numbers.count
    return mad
}
```swift
// For a given array of input numbers, calculate Mean Absolute Deviation
// around the mean of this dataset.
// Mean Absolute Deviation is the average absolute difference between each
// element and a centerpoint (mean in this case):
// MAD = average | x - x_mean |
// meanAbsoluteDeviation(numbers: [1.0, 2.0, 3.0, 4.0]) == 1.0
func meanAbsoluteDeviation(numbers: [Double]) -> Double {
    let mean = numbers.reduce(0.0, { (sum, x) -> Double in
        sum + x
    }) / numbers.count
    let deviations = numbers.map { x in
        abs(x - mean)
    }
    let mad = deviations.reduce(0.0, { (sum, x) -> Double in
        sum + x
    }) / numbers.count
    return mad
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ---------------------------------------------------------------------------
}) / numbers.count // binary operator '/' cannot be applied to operands of type 'Double' and 'Int'

func meanAbsoluteDeviation(numbers: [Double]) -> Double {
    let mean = numbers.reduce(0.0, { $0 + $1 }) / numbers.count
    let deviations = numbers.map { $0 - mean }
    let absDeviations = deviations.map { abs($0) }
    let sum = absDeviations.reduce(0.0, { $0 + $1 })
    return sum / absDeviations.count
}
```swift
// For a given array of input numbers, calculate Mean Absolute Deviation
// around the mean of this dataset.
// Mean Absolute Deviation is the average absolute difference between each
// element and a centerpoint (mean in this case):
// MAD = average | x - x_mean |
// meanAbsoluteDeviation(numbers: [1.0, 2.0, 3.0, 4.0]) == 1.0
func meanAbsoluteDeviation(numbers: [Double]) -> Double {
    let mean = numbers.reduce(0.0, { $0 + $1 }) / numbers.count
    let deviations = numbers.map { $0 - mean }
    let absDeviations = deviations.map { abs($0) }
    let sum = absDeviations.reduce(0.0, { $0 + $1 })
    return sum / absDeviations.count
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

//
let mean = numbers.reduce(0.0, { $0 + $1 }) / numbers.count // binary operator '/' cannot be applied to operands of type 'Double' and 'Int'

func meanAbsoluteDeviation(numbers: [Double]) -> Double {
    let mean = numbers.reduce(0.0, { $0 + $1 }) / numbers.count
    let deviations = numbers.map { $0 - mean }
    return deviations.map { abs($0) }.reduce(0.0, { $0 + $1 }) / numbers.count
}
```swift
// For a given array of input numbers, calculate Mean Absolute Deviation
// around the mean of this dataset.
// Mean Absolute Deviation is the average absolute difference between each
// element and a centerpoint (mean in this case):
// MAD = average | x - x_mean |
// meanAbsoluteDeviation(numbers: [1.0, 2.0, 3.0, 4.0]) == 1.0
func meanAbsoluteDeviation(numbers: [Double]) -> Double {
    let mean = numbers.reduce(0.0, { $0 + $1 }) / numbers.count
    let deviations = numbers.map { $0 - mean }
    return deviations.map { abs($0) }.reduce(0.0, { $0 + $1 }) / numbers.count
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ------------------------------------
let mean = numbers.reduce(0.0, { $0 + $1 }) / numbers.count // binary operator '/' cannot be applied to operands of type 'Double' and 'Int'
return deviations.map { abs($0) }.reduce(0.0, { $0 + $1 }) / numbers.count // no '/' candidates produce the expected contextual result type 'Double'

func meanAbsoluteDeviation(numbers: [Double]) -> Double {
    let mean = numbers.reduce(0.0, { $0 + $1 }) / numbers.count
    return numbers.map { $0 - mean }.map { abs($0) }.reduce(0.0, { $0 + $1 }) / numbers.count
}
```swift
// For a given array of input numbers, calculate Mean Absolute Deviation
// around the mean of this dataset.
// Mean Absolute Deviation is the average absolute difference between each
// element and a centerpoint (mean in this case):
// MAD = average | x - x_mean |
// meanAbsoluteDeviation(numbers: [1.0, 2.0, 3.0, 4.0]) == 1.0
func meanAbsoluteDeviation(numbers: [Double]) -> Double {
    let mean = numbers.reduce(0.0, { $0 + $1 }) / numbers.count
    return numbers.map { $0 - mean }.map { abs($0) }.reduce(0.0, { $0 + $1 }) / numbers.count
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ------------------------------------------------------

func intersperse(numbers: [Int], delimeter: Int) -> [Int] {
    var result = [Int]()
    for i in numbers {
        result.append(i)
        result.append(delimeter)
    }
    result.removeLast()
    return result
}
```swift
// Insert a number 'delimeter' between every two consecutive elements of input array `numbers'
// intersperse(numbers: [] as [Int], delimeter: 4) == [] as [Int]
// intersperse(numbers: [1, 2, 3], delimeter: 4) == [1, 4, 2, 4, 3]
func intersperse(numbers: [Int], delimeter: Int) -> [Int] {
    var result = [Int]()
    for i in numbers {
        result.append(i)
        result.append(delimeter)
    }
    result.removeLast()
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// 1.1.10
// Given an array of integers, find the largest sum of any contiguous subarray.
// Example:
//     [1, -2, 3, 4, -5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 5, 6]
//     [1, 2, 3, 4, 
 // Fatal error: Can't remove last element from an empty collection

func intersperse(numbers: [Int], delimeter: Int) -> [Int] {
    var result = [Int]()
    for i in numbers {
        result.append(i)
        result.append(delimeter)
    }
    result.removeLast()
    return result
}
```swift
// Insert a number 'delimeter' between every two consecutive elements of input array `numbers'
// intersperse(numbers: [] as [Int], delimeter: 4) == [] as [Int]
// intersperse(numbers: [1, 2, 3], delimeter: 4) == [1, 4, 2, 4, 3]
func intersperse(numbers: [Int], delimeter: Int) -> [Int] {
    var result = [Int]()
    for i in numbers {
        result.append(i)
        result.append(delimeter)
    }
    result.removeLast()
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// 11. Write a function that takes a string and returns a new string with all the vowels removed.
//     The vowels are 'a', 'e', 'i', 'o', and 'u'.
//     vowelFree("Hello world") == "Hll wrld"
//     vowelFree("") == ""
//     vowelFree("a") == ""
//     vowelFree("aeiou") == ""
//     vowelFree("aeiouAEIOU") == ""
//     vowelFree("aeiouAEIOU12345") == "12345"
//     vowelFree("aeiouAEIOU12345aeiouAEIOU12345") == "1234512345"
//     vowelFree("aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345") == "123451234512345"
//     vowelFree("aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345") == "12345123451234512345"
//     vowelFree("aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345") == "123451234512345123451234512345"
//     vowelFree("aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU12345aeiouAEIOU
 // Fatal error: Can't remove last element from an empty collection

func intersperse(numbers: [Int], delimeter: Int) -> [Int] {
    var result = [Int]()
    for i in numbers {
        result.append(i)
        result.append(delimeter)
    }
    if result.count > 0 {
        result.removeLast()
    }
    return result
}
```swift
// Insert a number 'delimeter' between every two consecutive elements of input array `numbers'
// intersperse(numbers: [] as [Int], delimeter: 4) == [] as [Int]
// intersperse(numbers: [1, 2, 3], delimeter: 4) == [1, 4, 2, 4, 3]
func intersperse(numbers: [Int], delimeter: Int) -> [Int] {
    var result = [Int]()
    for i in numbers {
        result.append(i)
        result.append(delimeter)
    }
    if result.count > 0 {
        result.removeLast()
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ---------------

func intersperse(numbers: [Int], delimeter: Int) -> [Int] {
    var result = [Int]()
    for i in numbers {
        result.append(i)
        result.append(delimeter)
    }
    result.removeLast()
    return result
}
```swift
// Insert a number 'delimeter' between every two consecutive elements of input array `numbers'
// intersperse(numbers: [] as [Int], delimeter: 4) == [] as [Int]
// intersperse(numbers: [1, 2, 3], delimeter: 4) == [1, 4, 2, 4, 3]
func intersperse(numbers: [Int], delimeter: Int) -> [Int] {
    var result = [Int]()
    for i in numbers {
        result.append(i)
        result.append(delimeter)
    }
    result.removeLast()
    return result
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // Fatal error: Can't remove last element from an empty collection

func intersperse(numbers: [Int], delimeter: Int) -> [Int] {
    var result = [Int]()
    for i in numbers {
        result.append(i)
        result.append(delimeter)
    }
    return result
}
```swift
// Insert a number 'delimeter' between every two consecutive elements of input array `numbers'
// intersperse(numbers: [] as [Int], delimeter: 4) == [] as [Int]
// intersperse(numbers: [1, 2, 3], delimeter: 4) == [1, 4, 2, 4, 3]
func intersperse(numbers: [Int], delimeter: Int) -> [Int] {
    var result = [Int]()
    for i in numbers {
        result.append(i)
        result.append(delimeter)
    }
    return result
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // XCTAssertTrue failed

func intersperse(numbers: [Int], delimeter: Int) -> [Int] {
    var result = [Int]()
    for number in numbers {
        result.append(number)
        result.append(delimeter)
    }
    return result
}
```swift
// Insert a number 'delimeter' between every two consecutive elements of input array `numbers'
// intersperse(numbers: [] as [Int], delimeter: 4) == [] as [Int]
// intersperse(numbers: [1, 2, 3], delimeter: 4) == [1, 4, 2, 4, 3]
func intersperse(numbers: [Int], delimeter: Int) -> [Int] {
    var result = [Int]()
    for number in numbers {
        result.append(number)
        result.append(delimeter)
    }
    return result
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // XCTAssertTrue failed

func intersperse(numbers: [Int], delimeter: Int) -> [Int] {
    var result = [Int]()
    for i in numbers {
        result.append(i)
        result.append(delimeter)
    }
    return result
}
```swift
// Insert a number 'delimeter' between every two consecutive elements of input array `numbers'
// intersperse(numbers: [] as [Int], delimeter: 4) == [] as [Int]
// intersperse(numbers: [1, 2, 3], delimeter: 4) == [1, 4, 2, 4, 3]
func intersperse(numbers: [Int], delimeter: Int) -> [Int] {
    var result = [Int]()
    for i in numbers {
        result.append(i)
        result.append(delimeter)
    }
    return result
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // XCTAssertTrue failed

func intersperse(numbers: [Int], delimeter: Int) -> [Int] {
    var result = [Int]()
    for i in numbers {
        result.append(i)
        result.append(delimeter)
    }
    return result
}

func reverseString(s: String) -> String {
    return String(s.reversed())
}

func firstUniqChar(s: String) -> Int {
    var dict = [Int: Int]()
    for i in s {
        if dict[i] == nil {
            dict[i] = 1
        } else {
            dict[i] = dict[i]! + 1
        }
    }
    for i in s {
        if dict[i] == 1 {
            return s.firstIndex(of: i)!
        }
    }
    return -1
}
```swift
// Insert a number 'delimeter' between every two consecutive elements of input array `numbers'
// intersperse(numbers: [] as [Int], delimeter: 4) == [] as [Int]
// intersperse(numbers: [1, 2, 3], delimeter: 4) == [1, 4, 2, 4, 3]
func intersperse(numbers: [Int], delimeter: Int) -> [Int] {
    var result = [Int]()
    for i in numbers {
        result.append(i)
        result.append(delimeter)
    }
    return result
}

// ---------------------------------------------------------------------------------------------------------------------
// 1.1.11
// ---------------------------------------------------------------------------------------------------------------------
// Write a function that takes a string as input and returns the string reversed.
// Example:
// Given s = "hello", return "olleh".
// ---------------------------------------------------------------------------------------------------------------------
// reverseString("hello") == "olleh"
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// ---------------------------------------------------------------------------------------------------------------------
// 1.1.12
// ---------------------------------------------------------------------------------------------------------------------
// Given a string s, find the first non-repeating character in it and return its index. If it doesn't exist, return -1.
// Examples:
// s = "leetcode"
// return 0.
// s = "loveleetcode"
// return 2.
// ---------------------------------------------------------------------------------------------------------------------
// firstUniqChar("leetcode") == 0
// firstUniqChar("loveleetcode") == 2
func firstUniqChar(s: String) -> Int {
    var dict = [Int: Int]()
    for i in s {
        if dict[i] == nil {
            dict[i] = 1
        } else {
            dict[i] = dict[i]! + 1
        }
    }
    for i in s {
        if dict[i] == 1 {
            return s.firstIndex(of: i)!
        }
    }
    return -1
}

// ---------------------------------------------------------------------------------------------------------------------
// 1.1.13
// ---------------------------------------------------------------------------------------------------------------------
// Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
// Note: For the purpose of this problem, we define empty string as valid palindrome.
// Example 1:
// Input: "A man, a plan, a canal: Panama"
// Output: true
// Example 2:
// Input: "race a car"
// Output: false
// ---------------------------------------------------------------------------------------------------------------------
// isPalindrome("A man, a plan, a canal: Panama") == true
// isPalindrome("race a car") == false
func isPalindrome(s: String) -> Bool {
    var s = s.trimmingCharacters(in: .whitespaceAndNewline)
    s = s.replacingOccurrences(of: " ", with: "")
    s = s.replacingOccurrences(of: ",", with: "")
    s = s.replacingOccurrences(of: ":", with: "")
    s = s.replacingOccurrences(of: ";", with: "")
    s = s.replacingOccurrences(of:
if dict[i] == nil { // cannot convert value of type 'Character' to expected argument type 'Int'
dict[i] = 1 // cannot convert value of type 'Character' to expected argument type 'Int'
dict[i] = dict[i]! + 1 // cannot convert value of type 'Character' to expected argument type 'Int'
dict[i] = dict[i]! + 1 // cannot convert value of type 'Character' to expected argument type 'Int'
if dict[i] == 1 { // cannot convert value of type 'Character' to expected argument type 'Int'
return s.firstIndex(of: i)! // cannot convert return expression of type 'String.Index' to return type 'Int'

func intersperse(numbers: [Int], delimeter: Int) -> [Int] {
    var result = [Int]()
    for i in numbers {
        result.append(i)
        result.append(delimeter)
    }
    if result.count > 0 {
        result.removeLast()
    }
    return result
}
```swift
// Insert a number 'delimeter' between every two consecutive elements of input array `numbers'
// intersperse(numbers: [] as [Int], delimeter: 4) == [] as [Int]
// intersperse(numbers: [1, 2, 3], delimeter: 4) == [1, 4, 2, 4, 3]
func intersperse(numbers: [Int], delimeter: Int) -> [Int] {
    var result = [Int]()
    for i in numbers {
        result.append(i)
        result.append(delimeter)
    }
    if result.count > 0 {
        result.removeLast()
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ---------------

func intersperse(numbers: [Int], delimeter: Int) -> [Int] {
    var result = [Int]()
    for i in numbers {
        result.append(i)
        result.append(delimeter)
    }
    return result
}

func longestSubstring(s: String) -> Int {
    var result = 0
    var current = 0
    var map = [Int: Int]()
    for i in 0..<s.count {
        if map[s[i]] == nil {
            map[s[i]] = i
            current += 1
        } else {
            result = max(result, current)
            current = i - map[s[i]]
            map.remove(key: s[i])
        }
    }
    return max(result, current)
}

func lengthOfLongestSubstring(s: String) -> Int {
    var result = 0
    var current = 0
    var map = [Int: Int]()
    for i in 0..<s.count {
        if map[s[i]] == nil {
            map[s[i]] = i
            current += 1
        } else {
            result = max(result, current)
            current = i - map[s[i]]
            map.remove(key: s[i])
        }
    }
    return max(result, current)
}
```swift
// Insert a number 'delimeter' between every two consecutive elements of input array `numbers'
// intersperse(numbers: [] as [Int], delimeter: 4) == [] as [Int]
// intersperse(numbers: [1, 2, 3], delimeter: 4) == [1, 4, 2, 4, 3]
func intersperse(numbers: [Int], delimeter: Int) -> [Int] {
    var result = [Int]()
    for i in numbers {
        result.append(i)
        result.append(delimeter)
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// 1.1.2
// ----------------------------------------------------------------------------------------------------------------------
// Given a string `s`, return the length of the longest substring without repeating characters.
// longestSubstring("abcabcbb") == 3
// longestSubstring("bbbbb") == 1
// longestSubstring("pwwkew") == 3
func longestSubstring(s: String) -> Int {
    var result = 0
    var current = 0
    var map = [Int: Int]()
    for i in 0..<s.count {
        if map[s[i]] == nil {
            map[s[i]] = i
            current += 1
        } else {
            result = max(result, current)
            current = i - map[s[i]]
            map.remove(key: s[i])
        }
    }
    return max(result, current)
}

// ----------------------------------------------------------------------------------------------------------------------
// 1.1.3
// ----------------------------------------------------------------------------------------------------------------------
// Given a string `s`, find the length of the longest substring without repeating characters.
// lengthOfLongestSubstring("abcabcbb") == 3
// lengthOfLongestSubstring("bbbbb") == 1
// lengthOfLongestSubstring("pwwkew") == 3
func lengthOfLongestSubstring(s: String) -> Int {
    var result = 0
    var current = 0
    var map = [Int: Int]()
    for i in 0..<s.count {
        if map[s[i]] == nil {
            map[s[i]] = i
            current += 1
        } else {
            result = max(result, current)
            current = i - map[s[i]]
            map.remove(key: s[i])
        }
    }
    return max(result, current)
}

// ----------------------------------------------------------------------------------------------------------------------
// 1.1.4
// ----------------------------------------------------------------------------------------------------------------------
// Given a string `s`, find the length of the longest substring without repeating characters.
// lengthOfLongestSubstring("abcabcbb") == 3
// lengthOfLongestSubstring("bbbbb") == 1
// lengthOfLongestSubstring("pwwkew") == 3
func lengthOfLongestSubstring(s: String) -> Int {
    var result = 0
    var current = 0
    var map = [Int: Int]()
    for i in 0..<s.count {
        if map[s[i]] == nil {
            map[s[i]] = i
            current += 1
        } else {
            result = max(result, current)
            current = i - map[s[i]]
            map.remove(key: s[i])
        }
    }
    return max(result, current)
}

// ----------------------------------------------------------------------------------------------------------------------
// 1.1.5
// ---------------------------
if map[s[i]] == nil { // cannot convert value of type 'Character' to expected argument type 'Int'
map[s[i]] = i // cannot convert value of type 'Character' to expected argument type 'Int'
current = i - map[s[i]] // value of optional type 'Int?' must be unwrapped to a value of type 'Int'
current = i - map[s[i]] // cannot convert value of type 'Character' to expected argument type 'Int'
map.remove(key: s[i]) // incorrect argument label in call (have 'key:', expected 'at:')
map.remove(key: s[i]) // cannot convert value of type 'Character' to expected argument type 'Dictionary<Int, Int>.Index'
if map[s[i]] == nil { // cannot convert value of type 'Character' to expected argument type 'Int'
map[s[i]] = i // cannot convert value of type 'Character' to expected argument type 'Int'
current = i - map[s[i]] // value of optional type 'Int?' must be unwrapped to a value of type 'Int'
current = i - map[s[i]] // cannot convert value of type 'Character' to expected argument type 'Int'
map.remove(key: s[i]) // cannot convert value of type 'Character' to expected argument type 'Dictionary<Int, Int>.Index'
map.remove(key: s[i]) // incorrect argument label in call (have 'key:', expected 'at:')

func parseNestedParens(parenString: String) -> [Int] {
    var result = [Int]()
    var currentLevel = 0
    for char in parenString {
        if char == "(" {
            currentLevel += 1
        } else if char == ")" {
            result.append(currentLevel)
            currentLevel -= 1
        }
    }
    return result
}

func removeVowels(inputString: String) -> String {
    var result = ""
    for char in inputString {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}
```swift
// Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
// For each of the group, output the deepest level of nesting of parentheses.
// E.g. (()()) has maximum two levels of nesting while ((())) has three.
// parseNestedParens(parenString: "(()()) ((())) () ((())()())") == [2, 3, 1, 3]
func parseNestedParens(parenString: String) -> [Int] {
    var result = [Int]()
    var currentLevel = 0
    for char in parenString {
        if char == "(" {
            currentLevel += 1
        } else if char == ")" {
            result.append(currentLevel)
            currentLevel -= 1
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 10. Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels(inputString: "Hello World") == "Hll Wrld"
func removeVowels(inputString: String) -> String {
    var result = ""
    for char in inputString {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 11. Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels(inputString: "Hello World") == "Hll Wrld"
func removeVowels(inputString: String) -> String {
    var result = ""
    for char in inputString {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 12. Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels(inputString: "Hello World") == "Hll Wrld"
func removeVowels(inputString: String) -> String {
    var result = ""
    for char in inputString {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 13. Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels(inputString: "Hello World") == "Hll Wrld"
func removeVowels(inputString: String) -> String {
    var result = ""
    for char in inputString {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 14. Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels(inputString: "Hello World") == "Hll Wrld"
func removeVowels(inputString: String) -> String {
    var result = ""
    for char in inputString {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// ---------------------------
result += char // cannot convert value of type 'Character' to expected argument type 'String'

func parseNestedParens(parenString: String) -> [Int] {
    var result = [Int]()
    var currentLevel = 0
    for c in parenString {
        if c == "(" {
            currentLevel += 1
        } else if c == ")" {
            currentLevel -= 1
        }
        result.append(currentLevel)
    }
    return result
}

func removeVowels(inputString: String) -> String {
    var result = ""
    for c in inputString {
        if c != "a" && c != "e" && c != "i" && c != "o" && c != "u" {
            result += c
        }
    }
    return result
}
```swift
// Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
// For each of the group, output the deepest level of nesting of parentheses.
// E.g. (()()) has maximum two levels of nesting while ((())) has three.
// parseNestedParens(parenString: "(()()) ((())) () ((())()())") == [2, 3, 1, 3]
func parseNestedParens(parenString: String) -> [Int] {
    var result = [Int]()
    var currentLevel = 0
    for c in parenString {
        if c == "(" {
            currentLevel += 1
        } else if c == ")" {
            currentLevel -= 1
        }
        result.append(currentLevel)
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 12. Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels(inputString: "This is a test string") == "Ths s  tst strng"
func removeVowels(inputString: String) -> String {
    var result = ""
    for c in inputString {
        if c != "a" && c != "e" && c != "i" && c != "o" && c != "u" {
            result += c
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 13. Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels(inputString: "This is a test string") == "Ths s  tst strng"
func removeVowels(inputString: String) -> String {
    var result = ""
    for c in inputString {
        if c != "a" && c != "e" && c != "i" && c != "o" && c != "u" {
            result += c
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 14. Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels(inputString: "This is a test string") == "Ths s  tst strng"
func removeVowels(inputString: String) -> String {
    var result = ""
    for c in inputString {
        if c != "a" && c != "e" && c != "i" && c != "o" && c != "u" {
            result += c
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 15. Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels(inputString: "This is a test string") == "Ths s  tst strng"
func removeVowels(inputString: String) -> String {
    var result = ""
    for c in inputString {
        if c != "a" && c != "e" && c != "i" && c != "o" && c != "u" {
            result += c
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 16. Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels(inputString: "This is a test string") == "Ths s  tst strng"
func removeVowels(inputString: String) -> String {
    var result = ""
    for c in inputString {
        if c != "a" && c != "e" && c != "i" && c != "o" && c != "u" {
result += c // cannot convert value of type 'Character' to expected argument type 'String'

func parseNestedParens(parenString: String) -> [Int] {
    var result = [Int]()
    var level = 0
    for c in parenString {
        switch c {
        case "(":
            level += 1
        case ")":
            level -= 1
        default:
            result.append(level)
        }
    }
    return result
}

func longestSubstring(s: String) -> String {
    var result = ""
    var current = ""
    var lastSeen = ""
    for c in s {
        if lastSeen.contains(c) {
            if current.length > result.length {
                result = current
            }
            current = ""
        }
        current += c
        lastSeen = c
    }
    if current.length > result.length {
        result = current
    }
    return result
}

func longestRepeating(s: String) -> String {
    var result = ""
    var current = ""
    var lastSeen = ""
    for c in s {
        if lastSeen.contains(c) {
            current += c
        } else {
            if current.length > result.length {
                result = current
            }
            current = ""
        }
        lastSeen = c
    }
    if current.length > result.length {
        result = current
    }
    return result
}
```swift
// Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
// For each of the group, output the deepest level of nesting of parentheses.
// E.g. (()()) has maximum two levels of nesting while ((())) has three.
// parseNestedParens(parenString: "(()()) ((())) () ((())()())") == [2, 3, 1, 3]
func parseNestedParens(parenString: String) -> [Int] {
    var result = [Int]()
    var level = 0
    for c in parenString {
        switch c {
        case "(":
            level += 1
        case ")":
            level -= 1
        default:
            result.append(level)
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.1.1
// -----------------------------------------------------------------------------
// Given a string, output the longest substring with no repeating characters.
// E.g. longestSubstring("abcabcbb") == "abc"
// longestSubstring("bbbbb") == "b"
// longestSubstring("pwwkew") == "wke"
// longestSubstring("") == ""
// longestSubstring("aab") == "aab"
// longestSubstring("dvdf") == "vdf"
func longestSubstring(s: String) -> String {
    var result = ""
    var current = ""
    var lastSeen = ""
    for c in s {
        if lastSeen.contains(c) {
            if current.length > result.length {
                result = current
            }
            current = ""
        }
        current += c
        lastSeen = c
    }
    if current.length > result.length {
        result = current
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.1.2
// -----------------------------------------------------------------------------
// Given a string, output the longest substring with repeating characters.
// E.g. longestRepeating("abcabcbb") == "abc"
// longestRepeating("bbbbb") == "b"
// longestRepeating("pwwkew") == "wke"
// longestRepeating("") == ""
// longestRepeating("aab") == "aab"
// longestRepeating("dvdf") == "vdf"
func longestRepeating(s: String) -> String {
    var result = ""
    var current = ""
    var lastSeen = ""
    for c in s {
        if lastSeen.contains(c) {
            current += c
        } else {
            if current.length > result.length {
                result = current
            }
            current = ""
        }
        lastSeen = c
    }
    if current.length > result.length {
        result = current
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.1.3
// -----------------------------------------------------------------------------
// Given a string, output the longest substring with repeating characters.
// E.g. longestRepeating("abcabcbb") == "abc"
// longestRepeating("bbbbb") == "b"
// longestRepeating("pwwkew") == "wke"
// longestRepeating("") == ""
// longestRepeating("aab") == "aab"
// longestRepeating("dvdf") == "vdf"
func longestRepeating(s: String) -> String {
    var result = ""
    var current = ""
    var lastSeen = ""
    var lastSeenIndex = 0
    for i in 0..<s.length {
        if lastSeen.contains(s[i]) {
            if current.length > result.length {
                result = current
            }
            current = ""
            lastSeenIndex = i
        } else {
            current += s[i]
        }
        lastSeen = s[i]
    }
    if
if current.length > result.length { // value of type 'String' has no member 'length'
if current.length > result.length { // value of type 'String' has no member 'length'
current += c // cannot convert value of type 'Character' to expected argument type 'String'
lastSeen = c // cannot assign value of type 'Character' to type 'String'
if current.length > result.length { // value of type 'String' has no member 'length'
if current.length > result.length { // value of type 'String' has no member 'length'
current += c // cannot convert value of type 'Character' to expected argument type 'String'
if current.length > result.length { // value of type 'String' has no member 'length'
if current.length > result.length { // value of type 'String' has no member 'length'
lastSeen = c // cannot assign value of type 'Character' to type 'String'
if current.length > result.length { // value of type 'String' has no member 'length'
if current.length > result.length { // value of type 'String' has no member 'length'

func parseNestedParens(parenString: String) -> [Int] {
    var result = [Int]()
    var currentLevel = 0
    for char in parenString {
        if char == "(" {
            currentLevel += 1
        } else if char == ")" {
            currentLevel -= 1
        }
        result.append(currentLevel)
    }
    return result
}
```swift
// Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
// For each of the group, output the deepest level of nesting of parentheses.
// E.g. (()()) has maximum two levels of nesting while ((())) has three.
// parseNestedParens(parenString: "(()()) ((())) () ((())()())") == [2, 3, 1, 3]
func parseNestedParens(parenString: String) -> [Int] {
    var result = [Int]()
    var currentLevel = 0
    for char in parenString {
        if char == "(" {
            currentLevel += 1
        } else if char == ")" {
            currentLevel -= 1
        }
        result.append(currentLevel)
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 12. Write a function that takes a string and returns the longest palindromic substring.
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 13. Write a function that takes a string and returns the longest palindromic substring.
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 14. Write a function that takes a string and returns the longest palindromic substring.
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 15. Write a function that takes a string and returns the longest palindromic substring.
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 16. Write a function that takes a string and returns the longest palindromic substring.
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 17. Write a function that takes a string and returns the longest palindromic substring.
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 18. Write a function that takes a string and returns the longest palindromic substring.
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 19. Write a function that takes a string and returns the longest palindromic substring.
// ----------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------------------
 // XCTAssertTrue failed

func parseNestedParens(parenString: String) -> [Int] {
    var result = [Int]()
    var stack = [Int]()
    for char in parenString {
        if char == "(" {
            stack.append(1)
        } else if char == ")" {
            stack.append(stack.pop() + 1)
        }
    }
    return stack
}
```swift
// Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
// For each of the group, output the deepest level of nesting of parentheses.
// E.g. (()()) has maximum two levels of nesting while ((())) has three.
// parseNestedParens(parenString: "(()()) ((())) () ((())()())") == [2, 3, 1, 3]
func parseNestedParens(parenString: String) -> [Int] {
    var result = [Int]()
    var stack = [Int]()
    for char in parenString {
        if char == "(" {
            stack.append(1)
        } else if char == ")" {
            stack.append(stack.pop() + 1)
        }
    }
    return stack
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------
stack.append(stack.pop() + 1) // value of type '[Int]' has no member 'pop'

func parseNestedParens(parenString: String) -> [Int] {
    var result = [Int]()
    var currentLevel = 0
    for char in parenString {
        if char == "(" {
            currentLevel += 1
        } else if char == ")" {
            currentLevel -= 1
        }
        result.append(currentLevel)
    }
    return result
}
```swift
// Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
// For each of the group, output the deepest level of nesting of parentheses.
// E.g. (()()) has maximum two levels of nesting while ((())) has three.
// parseNestedParens(parenString: "(()()) ((())) () ((())()())") == [2, 3, 1, 3]
func parseNestedParens(parenString: String) -> [Int] {
    var result = [Int]()
    var currentLevel = 0
    for char in parenString {
        if char == "(" {
            currentLevel += 1
        } else if char == ")" {
            currentLevel -= 1
        }
        result.append(currentLevel)
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 2.1.3
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 2.1.4
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 2.1.5
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 2.1.6
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 2.1.7
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 2.1.8
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 2.1.9
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 2.1.10
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 2.1.11
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: -
 // XCTAssertTrue failed

func parseNestedParens(parenString: String) -> [Int] {
    var result = [Int]()
    var stack = [Int]()
    var currentLevel = 0
    for char in parenString {
        if char == "(" {
            stack.append(currentLevel)
            currentLevel += 1
        } else if char == ")" {
            currentLevel -= 1
            result.append(stack.pop())
        }
    }
    return result
}
```swift
// Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
// For each of the group, output the deepest level of nesting of parentheses.
// E.g. (()()) has maximum two levels of nesting while ((())) has three.
// parseNestedParens(parenString: "(()()) ((())) () ((())()())") == [2, 3, 1, 3]
func parseNestedParens(parenString: String) -> [Int] {
    var result = [Int]()
    var stack = [Int]()
    var currentLevel = 0
    for char in parenString {
        if char == "(" {
            stack.append(currentLevel)
            currentLevel += 1
        } else if char == ")" {
            currentLevel -= 1
            result.append(stack.pop())
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ------------------
result.append(stack.pop()) // value of type '[Int]' has no member 'pop'

func parseNestedParens(parenString: String) -> [Int] {
    var result = [Int]()
    var stack = [Int]()
    for char in parenString {
        if char == "(" {
            stack.append(1)
        } else if char == ")" {
            stack.append(stack.pop() + 1)
        }
    }
    return stack
}

func longestSubstringWithoutRepeatingChars(s: String) -> String {
    var result = ""
    var stack = [String]()
    for char in s {
        if stack.contains(char) {
            stack = []
        }
        stack.append(char)
        if stack.count > result.count {
            result = String(stack)
        }
    }
    return result
}

func longestSubstringWithoutRepeatingChars(s: String) -> Int {
    var result = 0
    var stack = [String]()
    for char in s {
        if stack.contains(char) {
            stack = []
        }
        stack.append(char)
        result = max(result, stack.count)
    }
    return result
}
```swift
// Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
// For each of the group, output the deepest level of nesting of parentheses.
// E.g. (()()) has maximum two levels of nesting while ((())) has three.
// parseNestedParens(parenString: "(()()) ((())) () ((())()())") == [2, 3, 1, 3]
func parseNestedParens(parenString: String) -> [Int] {
    var result = [Int]()
    var stack = [Int]()
    for char in parenString {
        if char == "(" {
            stack.append(1)
        } else if char == ")" {
            stack.append(stack.pop() + 1)
        }
    }
    return stack
}

// 2. Given a string, return the longest substring without repeating characters.
// For example, the longest substrings without repeating characters for "abcabcbb" is "abc",
// which the length is 3. For "bbbbb" the longest substring is "b", with the length of 1.
// For "pwwkew", the longest substring is "wke", with the length of 3.
// Note that the answer must be a substring, "pwke" is a subsequence and not a substring.
// longestSubstringWithoutRepeatingChars(s: "abcabcbb") == "abc"
// longestSubstringWithoutRepeatingChars(s: "bbbbb") == "b"
// longestSubstringWithoutRepeatingChars(s: "pwwkew") == "wke"
func longestSubstringWithoutRepeatingChars(s: String) -> String {
    var result = ""
    var stack = [String]()
    for char in s {
        if stack.contains(char) {
            stack = []
        }
        stack.append(char)
        if stack.count > result.count {
            result = String(stack)
        }
    }
    return result
}

// 3. Given a string s, find the length of the longest substring without repeating characters.
// s = "abcabcbb"
// longestSubstringWithoutRepeatingChars(s: "abcabcbb") == 3
// s = "bbbbb"
// longestSubstringWithoutRepeatingChars(s: "bbbbb") == 1
// s = "pwwkew"
// longestSubstringWithoutRepeatingChars(s: "pwwkew") == 3
func longestSubstringWithoutRepeatingChars(s: String) -> Int {
    var result = 0
    var stack = [String]()
    for char in s {
        if stack.contains(char) {
            stack = []
        }
        stack.append(char)
        result = max(result, stack.count)
    }
    return result
}

// 4. Given a string s, find the length of the longest substring without repeating characters.
// s = "abcabcbb"
// longestSubstringWithoutRepeatingChars(s: "abcabcbb") == 3
// s = "bbbbb"
// longestSubstringWithoutRepeatingChars(s: "bbbbb") == 1
// s = "pwwkew"
// longestSubstringWithoutRepeatingChars(s: "pwwkew") == 3
func longestSubstringWithoutRepeatingChars(s: String) -> Int {
    var result = 0
    var stack = [String]()
    for char in s {
        if stack.contains(char) {
            stack = []
        }
        stack.append(char)
        result = max(result, stack.count)
    }
    return result
}

// 5. Given a string s, find the length of the longest substring without repeating characters.
// s = "abcabcbb"
// longestSubstringWithoutRepeatingChars(s: "abcabcbb") == 3
// s = "bbbbb"
// longestSubstringWithoutRepeatingChars(s: "bbbbb") == 1
// s = "pwwkew"
// longestSubstringWithoutRepeatingChars(s: "pwwkew") == 3
func longestSubstringWithoutRepeatingChars(s: String) -> Int {
    var result = 0
    var stack = [String]()
    for char in s {
        if stack.contains(char) {
            stack = []
        }
        stack.append(char)
        result = max(result, stack.count)
    }
    return result
}

// 6. Given a string s, find the length
stack.append(stack.pop() + 1) // value of type '[Int]' has no member 'pop'
if stack.contains(char) { // cannot convert value of type 'Character' to expected argument type 'String'
stack.append(char) // cannot convert value of type 'Character' to expected argument type 'String'
result = String(stack) // no exact matches in call to initializer
if stack.contains(char) { // cannot convert value of type 'Character' to expected argument type 'String'
stack.append(char) // cannot convert value of type 'Character' to expected argument type 'String'

func parseNestedParens(parenString: String) -> [Int] {
    var result = [Int]()
    var stack = [Int]()
    for char in parenString {
        if char == "(" {
            stack.append(1)
        } else if char == ")" {
            stack.pop()
            result.append(stack.count)
        }
    }
    return result
}

func longestPalindrome(s: String) -> String {
    var result = ""
    for i in 0..<s.count {
        for j in i..<s.count {
            var sub = s[i..<j]
            if sub == sub.reversed() {
                if sub.count > result.count {
                    result = sub
                }
            }
        }
    }
    return result
}
```swift
// Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
// For each of the group, output the deepest level of nesting of parentheses.
// E.g. (()()) has maximum two levels of nesting while ((())) has three.
// parseNestedParens(parenString: "(()()) ((())) () ((())()())") == [2, 3, 1, 3]
func parseNestedParens(parenString: String) -> [Int] {
    var result = [Int]()
    var stack = [Int]()
    for char in parenString {
        if char == "(" {
            stack.append(1)
        } else if char == ")" {
            stack.pop()
            result.append(stack.count)
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.2
// Given a string, return the longest palindromic substring in it.
// E.g. longestPalindrome("abaxyzzyxf") == "xyzzyx"
// longestPalindrome("abaxyzzyxf") == "xyzzyx"
func longestPalindrome(s: String) -> String {
    var result = ""
    for i in 0..<s.count {
        for j in i..<s.count {
            var sub = s[i..<j]
            if sub == sub.reversed() {
                if sub.count > result.count {
                    result = sub
                }
            }
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.3
// Given a string, return the longest palindromic substring in it.
// E.g. longestPalindrome("abaxyzzyxf") == "xyzzyx"
// longestPalindrome("abaxyzzyxf") == "xyzzyx"
func longestPalindrome(s: String) -> String {
    var result = ""
    for i in 0..<s.count {
        for j in i..<s.count {
            var sub = s[i..<j]
            if sub == sub.reversed() {
                if sub.count > result.count {
                    result = sub
                }
            }
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.4
// Given a string, return the longest palindromic substring in it.
// E.g. longestPalindrome("abaxyzzyxf") == "xyzzyx"
// longestPalindrome("abaxyzzyxf") == "xyzzyx"
func longestPalindrome(s: String) -> String {
    var result = ""
    for i in 0..<s.count {
        for j in i..<s.count {
            var sub = s[i..<j]
            if sub == sub.reversed() {
                if sub.count > result.count {
                    result = sub
                }
            }
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.5
// Given a string, return the longest palindromic substring in it.
// E.g. longestPalindrome("abaxyzzyxf") == "xyzzyx"
// longestPalindrome("abaxyzzyxf") == "xyzzyx"
func longestPalindrome(s: String) -> String {
    var result = ""
    for i in 0..<s.count {
        for j in i..<s.count {
            var sub = s[i..<j]
            if sub == sub.reversed() {
                if sub.count > result.count {
                    result = sub
                }
            }
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.6
// Given a string, return the longest palindromic substring in it.
// E.g. longestPalindrome("abaxyzzyxf") == "xyzzyx"
// longestPalindrome("abaxyzzyxf") == "xyzzyx"
func longest
stack.pop() // value of type '[Int]' has no member 'pop'
var sub = s[i..<j] // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.
if sub == sub.reversed() { // binary operator '==' cannot be applied to operands of type 'String' and '[String.Element]' (aka 'Array<Character>')

func parseNestedParens(parenString: String) -> [Int] {
    var result = [Int]()
    var currentLevel = 0
    for char in parenString {
        if char == "(" {
            currentLevel += 1
        } else if char == ")" {
            currentLevel -= 1
        }
        result.append(currentLevel)
    }
    return result
}
```swift
// Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
// For each of the group, output the deepest level of nesting of parentheses.
// E.g. (()()) has maximum two levels of nesting while ((())) has three.
// parseNestedParens(parenString: "(()()) ((())) () ((())()())") == [2, 3, 1, 3]
func parseNestedParens(parenString: String) -> [Int] {
    var result = [Int]()
    var currentLevel = 0
    for char in parenString {
        if char == "(" {
            currentLevel += 1
        } else if char == ")" {
            currentLevel -= 1
        }
        result.append(currentLevel)
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------------------------------------
 // XCTAssertTrue failed

func filterBySubstring(strings: [String], substring: String) -> [String] {
    return strings.filter { $0.contains(substring) }
}

func sumIntegers(integers: [Int]) -> Int {
    return integers.reduce(0, { $0 + $1 })
}

func average(integers: [Int]) -> Int {
    return sumIntegers(integers) / integers.count
}

func max(integers: [Int]) -> Int {
    return integers.max()!
}

func min(integers: [Int]) -> Int {
    return integers.min()!
}

func diff(integers: [Int]) -> Int {
    return max(integers) - min(integers)
}

func countEven(integers: [Int]) -> Int {
    return integers.count(predicate: { $0 % 2 == 0 })
}

func countOdd(integers: [Int]) -> Int {
    return integers.count(predicate: { $0 % 2 != 0 })
}

func countGreaterThanAverage(integers: [Int]) -> Int {
    return integers.count(predicate: { $0 > average(integers) })
}

func countLessThanAverage(integers: [Int]) -> Int {
    return integers.count(predicate: { $0 < average(integers) })
}
```swift
// Filter an input array of strings only for ones that contain given substring
// filterBySubstring(strings: [] as [String], substring: "a") == [] as [String]
// filterBySubstring(strings: ["abc", "bacd", "cde", "array"], substring: "a") == ["abc", "bacd", "array"]
func filterBySubstring(strings: [String], substring: String) -> [String] {
    return strings.filter { $0.contains(substring) }
}

// 2. Write a function that takes an array of integers and returns the sum of all the integers.
// sumIntegers([1, 2, 3]) == 6
// sumIntegers([1, 2, 3, 4, 5]) == 15
func sumIntegers(integers: [Int]) -> Int {
    return integers.reduce(0, { $0 + $1 })
}

// 3. Write a function that takes an array of integers and returns the average of all the integers.
// average([1, 2, 3]) == 2
// average([1, 2, 3, 4, 5]) == 3
func average(integers: [Int]) -> Int {
    return sumIntegers(integers) / integers.count
}

// 4. Write a function that takes an array of integers and returns the maximum value in the array.
// max([1, 2, 3]) == 3
// max([1, 2, 3, 4, 5]) == 5
func max(integers: [Int]) -> Int {
    return integers.max()!
}

// 5. Write a function that takes an array of integers and returns the minimum value in the array.
// min([1, 2, 3]) == 1
// min([1, 2, 3, 4, 5]) == 1
func min(integers: [Int]) -> Int {
    return integers.min()!
}

// 6. Write a function that takes an array of integers and returns the difference between the maximum and minimum values in the array.
// diff([1, 2, 3]) == 2
// diff([1, 2, 3, 4, 5]) == 4
func diff(integers: [Int]) -> Int {
    return max(integers) - min(integers)
}

// 7. Write a function that takes an array of integers and returns the number of even integers in the array.
// countEven([1, 2, 3]) == 1
// countEven([1, 2, 3, 4, 5]) == 2
func countEven(integers: [Int]) -> Int {
    return integers.count(predicate: { $0 % 2 == 0 })
}

// 8. Write a function that takes an array of integers and returns the number of odd integers in the array.
// countOdd([1, 2, 3]) == 1
// countOdd([1, 2, 3, 4, 5]) == 2
func countOdd(integers: [Int]) -> Int {
    return integers.count(predicate: { $0 % 2 != 0 })
}

// 9. Write a function that takes an array of integers and returns the number of integers that are greater than the average of the integers in the array.
// countGreaterThanAverage([1, 2, 3]) == 0
// countGreaterThanAverage([1, 2, 3, 4, 5]) == 2
func countGreaterThanAverage(integers: [Int]) -> Int {
    return integers.count(predicate: { $0 > average(integers) })
}

// 10. Write a function that takes an array of integers and returns the number of integers that are less than the average of the integers in the array.
// countLessThanAverage([1, 2, 3]) == 0
// countLessThanAverage([1, 2, 3, 4, 5]) == 3
func countLessThanAverage(integers: [Int]) -> Int {
    return integers.count(predicate: { $0 < average(integers) })
}

// 11. Write a function that takes an array of integers and returns the number of integers that are between 10 and 20 (inclusive).
// countBetween10And20([1, 2, 3]) == 0
// countBetween10And20([1, 2, 3, 4, 5]) == 1
func countBetween10And20(integers: [Int]) -> Int {
    return integers.count(predicate:
return sumIntegers(integers) / integers.count // missing argument label 'integers:' in call
return max(integers) - min(integers) // missing argument label 'integers:' in call
return max(integers) - min(integers) // missing argument label 'integers:' in call
return integers.count(predicate: { $0 % 2 == 0 }) // cannot call value of non-function type 'Int'
return integers.count(predicate: { $0 % 2 != 0 }) // cannot call value of non-function type 'Int'
return integers.count(predicate: { $0 > average(integers) }) // cannot call value of non-function type 'Int'
return integers.count(predicate: { $0 > average(integers) }) // missing argument label 'integers:' in call
return integers.count(predicate: { $0 < average(integers) }) // missing argument label 'integers:' in call
return integers.count(predicate: { $0 < average(integers) }) // cannot call value of non-function type 'Int'

func filterBySubstring(strings: [String], substring: String) -> [String] {
    return strings.filter { $0.contains(substring) }
}

func filterBySubstrings(strings: [String], substrings: [String]) -> [String] {
    return strings.filter { $0.contains(substrings) }
}
```swift
// Filter an input array of strings only for ones that contain given substring
// filterBySubstring(strings: [] as [String], substring: "a") == [] as [String]
// filterBySubstring(strings: ["abc", "bacd", "cde", "array"], substring: "a") == ["abc", "bacd", "array"]
func filterBySubstring(strings: [String], substring: String) -> [String] {
    return strings.filter { $0.contains(substring) }
}

// ----------------------------------------------------------------------------------------------------------------------

// 2. Write a function that takes a string and an array of strings as input and returns a new array containing only the strings from the original array that do not contain any of the substrings in the second array.
// filterBySubstrings(strings: [] as [String], substrings: []) == [] as [String]
// filterBySubstrings(strings: ["abc", "bacd", "cde", "array"], substrings: ["a", "b"]) == ["cde"]
func filterBySubstrings(strings: [String], substrings: [String]) -> [String] {
    return strings.filter { $0.contains(substrings) }
}

// ----------------------------------------------------------------------------------------------------------------------

// 3. Write a function that takes a string and an array of strings as input and returns a new array containing only the strings from the original array that contain all of the substrings in the second array.
// filterBySubstrings(strings: [] as [String], substrings: []) == [] as [String]
// filterBySubstrings(strings: ["abc", "bacd", "cde", "array"], substrings: ["a", "b"]) == ["abc", "bacd"]
func filterBySubstrings(strings: [String], substrings: [String]) -> [String] {
    return strings.filter { $0.contains(substrings) }
}

// ----------------------------------------------------------------------------------------------------------------------

// 4. Write a function that takes a string and an array of strings as input and returns a new array containing only the strings from the original array that contain all of the substrings in the second array, in the order in which they appear in the second array.
// filterBySubstrings(strings: [] as [String], substrings: []) == [] as [String]
// filterBySubstrings(strings: ["abc", "bacd", "cde", "array"], substrings: ["a", "b"]) == ["abc", "bacd"]
func filterBySubstrings(strings: [String], substrings: [String]) -> [String] {
    return strings.filter { $0.contains(substrings) }
}

// ----------------------------------------------------------------------------------------------------------------------

// 5. Write a function that takes a string and an array of strings as input and returns a new array containing only the strings from the original array that contain all of the substrings in the second array, in the order in which they appear in the second array, and in the order in which they appear in the original array.
// filterBySubstrings(strings: [] as [String], substrings: []) == [] as [String]
// filterBySubstrings(strings: ["abc", "bacd", "cde", "array"], substrings: ["a", "b"]) == ["abc", "bacd"]
func filterBySubstrings(strings: [String], substrings: [String]) -> [String] {
    return strings.filter { $0.contains(substrings) }
}

// ----------------------------------------------------------------------------------------------------------------------

// 6. Write a function that takes a string and an array of strings as input and returns a new array containing only the strings from the original array that contain all of the substrings in the second array, in the order in which they appear in the original array.
// filterBySubstrings(strings: [] as [String], substrings: []) == [] as [String]
// filterBySubstrings(strings:
return strings.filter { $0.contains(substrings) } // type of expression is ambiguous without a type annotation

func filterBySubstring(strings: [String], substring: String) -> [String] {
    return strings.filter { $0.contains(substring) }
}
```swift
// Filter an input array of strings only for ones that contain given substring
// filterBySubstring(strings: [] as [String], substring: "a") == [] as [String]
// filterBySubstring(strings: ["abc", "bacd", "cde", "array"], substring: "a") == ["abc", "bacd", "array"]
func filterBySubstring(strings: [String], substring: String) -> [String] {
    return strings.filter { $0.contains(substring) }
}

// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------

func filterBySubstring(strings: [String], substring: String) -> [String] {
    return strings.filter { $0.contains(substring) }
}

func sumIntegers(integers: [Int]) -> Int {
    return integers.reduce(0, { $0 + $1 })
}

func sumOddIntegers(integers: [Int]) -> Int {
    return integers.filter { $0 % 2 != 0 }.reduce(0, { $0 + $1 })
}

func sumEvenIntegers(integers: [Int]) -> Int {
    return integers.filter { $0 % 2 == 0 }.reduce(0, { $0 + $1 })
}

func sumOddIntegersLessThan100(integers: [Int]) -> Int {
    return integers.filter { $0 % 2 != 0 && $0 < 100 }.reduce(0, { $0 + $1 })
}

func sumEvenIntegersLessThan100(integers: [Int]) -> Int {
    return integers.filter { $0 % 2 == 0 && $0 < 100 }.reduce(0, { $0 + $1 })
}
```swift
// Filter an input array of strings only for ones that contain given substring
// filterBySubstring(strings: [] as [String], substring: "a") == [] as [String]
// filterBySubstring(strings: ["abc", "bacd", "cde", "array"], substring: "a") == ["abc", "bacd", "array"]
func filterBySubstring(strings: [String], substring: String) -> [String] {
    return strings.filter { $0.contains(substring) }
}

// ----------------------------------------------------------------------------------------------------------------------
// 12. Write a function that takes an array of integers and returns the sum of all the integers.
// sumIntegers([1, 2, 3, 4, 5]) == 15
// sumIntegers([-1, 2, 3, 4, 5]) == 12
// sumIntegers([]) == 0
func sumIntegers(integers: [Int]) -> Int {
    return integers.reduce(0, { $0 + $1 })
}

// ----------------------------------------------------------------------------------------------------------------------
// 13. Write a function that takes an array of integers and returns the sum of all the integers that are odd.
// sumOddIntegers([1, 2, 3, 4, 5]) == 9
// sumOddIntegers([-1, 2, 3, 4, 5]) == 9
// sumOddIntegers([]) == 0
func sumOddIntegers(integers: [Int]) -> Int {
    return integers.filter { $0 % 2 != 0 }.reduce(0, { $0 + $1 })
}

// ----------------------------------------------------------------------------------------------------------------------
// 14. Write a function that takes an array of integers and returns the sum of all the integers that are even.
// sumEvenIntegers([1, 2, 3, 4, 5]) == 10
// sumEvenIntegers([-1, 2, 3, 4, 5]) == 10
// sumEvenIntegers([]) == 0
func sumEvenIntegers(integers: [Int]) -> Int {
    return integers.filter { $0 % 2 == 0 }.reduce(0, { $0 + $1 })
}

// ----------------------------------------------------------------------------------------------------------------------
// 15. Write a function that takes an array of integers and returns the sum of all the integers that are odd and less than 100.
// sumOddIntegersLessThan100([1, 2, 3, 4, 5]) == 9
// sumOddIntegersLessThan100([-1, 2, 3, 4, 5]) == 9
// sumOddIntegersLessThan100([]) == 0
func sumOddIntegersLessThan100(integers: [Int]) -> Int {
    return integers.filter { $0 % 2 != 0 && $0 < 100 }.reduce(0, { $0 + $1 })
}

// ----------------------------------------------------------------------------------------------------------------------
// 16. Write a function that takes an array of integers and returns the sum of all the integers that are even and less than 100.
// sumEvenIntegersLessThan100([1, 2, 3, 4, 5]) == 10
// sumEvenIntegersLessThan100([-1, 2, 3, 4, 5]) == 10
// sumEvenIntegersLessThan100([]) == 0
func sumEvenIntegersLessThan100(integers: [Int]) -> Int {
    return integers.filter { $0 % 2 == 0 && $0 < 100 }.reduce(0, { $0 + $1 })
}

// ----------------------------------------------------------------------------------------------------------------------

func filterBySubstring(strings: [String], substring: String) -> [String] {
    return strings.filter { $0.contains(substring) }
}
```swift
// Filter an input array of strings only for ones that contain given substring
// filterBySubstring(strings: [] as [String], substring: "a") == [] as [String]
// filterBySubstring(strings: ["abc", "bacd", "cde", "array"], substring: "a") == ["abc", "bacd", "array"]
func filterBySubstring(strings: [String], substring: String) -> [String] {
    return strings.filter { $0.contains(substring) }
}

// ----------------------------------------------------------------------------------------------------------------------
// 1.2.3.1.2.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.

func filterBySubstring(strings: [String], substring: String) -> [String] {
    return strings.filter { $0.contains(substring) }
}

func sumArray(array: [Int]) -> Int {
    return array.reduce(0, { $0 + $1 })
}

func averageArray(array: [Int]) -> Int {
    return Int(array.reduce(0, { $0 + $1 }) / array.count)
}

func largestInt(array: [Int]) -> Int? {
    return array.max()
}

func smallestInt(array: [Int]) -> Int? {
    return array.min()
}

func largestMinusSmallest(array: [Int]) -> Int? {
    return array.max()! - array.min()
}

func sumOfEvens(array: [Int]) -> Int {
    return array.filter { $0 % 2 == 0 }.reduce(0, { $0 + $1 })
}
```swift
// Filter an input array of strings only for ones that contain given substring
// filterBySubstring(strings: [] as [String], substring: "a") == [] as [String]
// filterBySubstring(strings: ["abc", "bacd", "cde", "array"], substring: "a") == ["abc", "bacd", "array"]
func filterBySubstring(strings: [String], substring: String) -> [String] {
    return strings.filter { $0.contains(substring) }
}

// ---------------------------------------------------------------------------------------------------------------------
// 1.1.2. Write a function that takes an array of integers and returns the sum of all the integers in the array.
// sumArray([1, 2, 3, 4, 5]) == 15
// sumArray([-1, 0, 1]) == 0
// sumArray([]) == 0
func sumArray(array: [Int]) -> Int {
    return array.reduce(0, { $0 + $1 })
}

// ---------------------------------------------------------------------------------------------------------------------
// 1.1.3. Write a function that takes an array of integers and returns the average of all the integers in the array.
// averageArray([1, 2, 3, 4, 5]) == 3
// averageArray([-1, 0, 1]) == 0
// averageArray([]) == 0
func averageArray(array: [Int]) -> Int {
    return Int(array.reduce(0, { $0 + $1 }) / array.count)
}

// ---------------------------------------------------------------------------------------------------------------------
// 1.1.4. Write a function that takes an array of integers and returns the largest integer in the array.
// largestInt([1, 2, 3, 4, 5]) == 5
// largestInt([-1, 0, 1]) == 1
// largestInt([]) == nil
func largestInt(array: [Int]) -> Int? {
    return array.max()
}

// ---------------------------------------------------------------------------------------------------------------------
// 1.1.5. Write a function that takes an array of integers and returns the smallest integer in the array.
// smallestInt([1, 2, 3, 4, 5]) == 1
// smallestInt([-1, 0, 1]) == -1
// smallestInt([]) == nil
func smallestInt(array: [Int]) -> Int? {
    return array.min()
}

// ---------------------------------------------------------------------------------------------------------------------
// 1.1.6. Write a function that takes an array of integers and returns the difference between the largest and smallest integers in the array.
// largestMinusSmallest([1, 2, 3, 4, 5]) == 4
// largestMinusSmallest([-1, 0, 1]) == 2
// largestMinusSmallest([]) == nil
func largestMinusSmallest(array: [Int]) -> Int? {
    return array.max()! - array.min()
}

// ---------------------------------------------------------------------------------------------------------------------
// 1.1.7. Write a function that takes an array of integers and returns the sum of all the even integers in the array.
// sumOfEvens([1, 2, 3, 4, 5]) == 6
// sumOfEvens([-1, 0, 1]) == 0
// sumOfEvens([]) == 0
func sumOfEvens(array: [Int]) -> Int {
    return array.filter { $0 % 2 == 0 }.reduce(0, { $0 + $1 })
}

// ---------------------------------------------------------------------------------------------------------------------
// 1.1.8. Write a function that takes an array of integers and returns the sum of all the odd integers in the array.
// sumOfO
return array.max()! - array.min() // value of optional type 'Int?' must be unwrapped to a value of type 'Int'

func filterBySubstring(strings: [String], substring: String) -> [String] {
    return strings.filter { $0.contains(substring) }
}
```swift
// Filter an input array of strings only for ones that contain given substring
// filterBySubstring(strings: [] as [String], substring: "a") == [] as [String]
// filterBySubstring(strings: ["abc", "bacd", "cde", "array"], substring: "a") == ["abc", "bacd", "array"]
func filterBySubstring(strings: [String], substring: String) -> [String] {
    return strings.filter { $0.contains(substring) }
}

// -----------------------------------------------------------------------------
// 1.2.1.2.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.

func filterBySubstring(strings: [String], substring: String) -> [String] {
    return strings.filter { $0.contains(substring) }
}
```swift
// Filter an input array of strings only for ones that contain given substring
// filterBySubstring(strings: [] as [String], substring: "a") == [] as [String]
// filterBySubstring(strings: ["abc", "bacd", "cde", "array"], substring: "a") == ["abc", "bacd", "array"]
func filterBySubstring(strings: [String], substring: String) -> [String] {
    return strings.filter { $0.contains(substring) }
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

func filterBySubstring(strings: [String], substring: String) -> [String] {
    return strings.filter { $0.contains(substring) }
}
```swift
// Filter an input array of strings only for ones that contain given substring
// filterBySubstring(strings: [] as [String], substring: "a") == [] as [String]
// filterBySubstring(strings: ["abc", "bacd", "cde", "array"], substring: "a") == ["abc", "bacd", "array"]
func filterBySubstring(strings: [String], substring: String) -> [String] {
    return strings.filter { $0.contains(substring) }
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

func filterBySubstring(strings: [String], substring: String) -> [String] {
    return strings.filter { $0.contains(substring) }
}
```swift
// Filter an input array of strings only for ones that contain given substring
// filterBySubstring(strings: [] as [String], substring: "a") == [] as [String]
// filterBySubstring(strings: ["abc", "bacd", "cde", "array"], substring: "a") == ["abc", "bacd", "array"]
func filterBySubstring(strings: [String], substring: String) -> [String] {
    return strings.filter { $0.contains(substring) }
}

// -----------------------------------------------------------------------------
// 1.1.1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.63.64.65.66.67.68.69.70.71.72.73.74.75.76.77.78.79.80.81.82.83.84.85.86.87.88.89.90.91.92.93.94.95.96.97.98.99.100.101.102.103.104.105.106.107.108.109.110.111.112.113.114.115.116.117.118.119.120.121.122.123.124.125.126.127.128.129.130.131.132.133.134.135.136.137.138.139.140.141.142.143.144.145.146.147.148.149.150.151.152.153.154.155.156.157.158.159.160.161.162.163.164.165.166.167.168.169.170.171.172.173.174.175.176.177.178.179.180.181.182.183.184.185.186.187.188.189.190.191.192.193.194.195.196.197.198.199.200.201.202.203.204.205.206.207.208.209.210.211.212.213.214.215.216.217.218.219.220.221.222.223.224.225.226.227.228.229.230.231.232.233.234.235.236.237.238.239.240.241.242.243.244.245.246.247.248.249.250.251.252.253.254.255.256.257.258.259.260.261.262.263.264.265.266.267.268.269.27

func sumProduct(numbers: [Int]) -> (Int, Int) {
    var sum = 0
    var product = 1
    for number in numbers {
        sum += number
        product *= number
    }
    return (sum, product)
}

func reverseString(string: String) -> String {
    var reversed = ""
    for character in string {
        reversed = character + reversed
    }
    return reversed
}
```swift
// For a given array of integers, return a tuple consisting of a sum and a product of all the integers in an array.
// Empty sum should be equal to 0 and empty product should be equal to 1.
// sumProduct(numbers: [] as [Int]) == (0, 1)
// sumProduct(numbers: [1, 2, 3, 4]) == (10, 24)
func sumProduct(numbers: [Int]) -> (Int, Int) {
    var sum = 0
    var product = 1
    for number in numbers {
        sum += number
        product *= number
    }
    return (sum, product)
}

// 2. Given a string, return a string with the characters in reverse order.
// reverseString("hello") == "olleh"
// reverseString("") == ""
func reverseString(string: String) -> String {
    var reversed = ""
    for character in string {
        reversed = character + reversed
    }
    return reversed
}

// 3. Given a string, return a string with the characters in reverse order.
// reverseString("hello") == "olleh"
// reverseString("") == ""
func reverseString(string: String) -> String {
    var reversed = ""
    for character in string {
        reversed = character + reversed
    }
    return reversed
}

// 4. Given a string, return a string with the characters in reverse order.
// reverseString("hello") == "olleh"
// reverseString("") == ""
func reverseString(string: String) -> String {
    var reversed = ""
    for character in string {
        reversed = character + reversed
    }
    return reversed
}

// 5. Given a string, return a string with the characters in reverse order.
// reverseString("hello") == "olleh"
// reverseString("") == ""
func reverseString(string: String) -> String {
    var reversed = ""
    for character in string {
        reversed = character + reversed
    }
    return reversed
}

// 6. Given a string, return a string with the characters in reverse order.
// reverseString("hello") == "olleh"
// reverseString("") == ""
func reverseString(string: String) -> String {
    var reversed = ""
    for character in string {
        reversed = character + reversed
    }
    return reversed
}

// 7. Given a string, return a string with the characters in reverse order.
// reverseString("hello") == "olleh"
// reverseString("") == ""
func reverseString(string: String) -> String {
    var reversed = ""
    for character in string {
        reversed = character + reversed
    }
    return reversed
}

// 8. Given a string, return a string with the characters in reverse order.
// reverseString("hello") == "olleh"
// reverseString("") == ""
func reverseString(string: String) -> String {
    var reversed = ""
    for character in string {
        reversed = character + reversed
    }
    return reversed
}

// 9. Given a string, return a string with the characters in reverse order.
// reverseString("hello") == "olleh"
// reverseString("") == ""
func reverseString(string: String) -> String {
    var reversed = ""
    for character in string {
        reversed = character + reversed
    }
    return reversed
}

// 10. Given a string, return a string with the characters in reverse order.
// reverseString("hello") == "olleh"
// reverseString("") == ""
func reverseString(string: String) -> String {
    var reversed = ""
    for character in string {
        reversed = character + reversed
    }
    return reversed
}

// 11. Given a string, return a string with the characters in reverse order.
// reverseString("hello") == "olleh"
// reverseString("") == ""
func reverseString(string: String) -> String {
    var reversed = ""
    for character in string {
        reversed = character + reversed
    }
    return reversed
}

// 12. Given a string, return a string with the characters in reverse order.
// reverseString("hello") == "olleh"
// reverseString("") == ""
func reverseString(string: String) -> String {
    var reversed = ""
    for character in string {
        reversed = character + reversed
    }
    return
reversed = character + reversed // cannot convert value of type 'Character' to expected argument type 'String'

func sumProduct(numbers: [Int]) -> (Int, Int) {
    var sum = 0
    var product = 1
    for number in numbers {
        sum += number
        product *= number
    }
    return (sum, product)
}

func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}
```swift
// For a given array of integers, return a tuple consisting of a sum and a product of all the integers in an array.
// Empty sum should be equal to 0 and empty product should be equal to 1.
// sumProduct(numbers: [] as [Int]) == (0, 1)
// sumProduct(numbers: [1, 2, 3, 4]) == (10, 24)
func sumProduct(numbers: [Int]) -> (Int, Int) {
    var sum = 0
    var product = 1
    for number in numbers {
        sum += number
        product *= number
    }
    return (sum, product)
}

// 2. Write a function that takes a string and returns a string with all the vowels removed.
// removeVowels("abcdefghijklmnopqrstuvwxyz") == "bcdfghjklmnpqrstvwxyz"
// removeVowels("") == ""
// removeVowels("aeiou") == ""
// removeVowels("aeiouAEIOU") == ""
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// 3. Write a function that takes a string and returns a string with all the vowels removed.
// removeVowels("abcdefghijklmnopqrstuvwxyz") == "bcdfghjklmnpqrstvwxyz"
// removeVowels("") == ""
// removeVowels("aeiou") == ""
// removeVowels("aeiouAEIOU") == ""
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// 4. Write a function that takes a string and returns a string with all the vowels removed.
// removeVowels("abcdefghijklmnopqrstuvwxyz") == "bcdfghjklmnpqrstvwxyz"
// removeVowels("") == ""
// removeVowels("aeiou") == ""
// removeVowels("aeiouAEIOU") == ""
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// 5. Write a function that takes a string and returns a string with all the vowels removed.
// removeVowels("abcdefghijklmnopqrstuvwxyz") == "bcdfghjklmnpqrstvwxyz"
// removeVowels("") == ""
// removeVowels("aeiou") == ""
// removeVowels("aeiouAEIOU") == ""
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// 6. Write a function that takes a string and returns a string with all the vowels removed.
// removeVowels("abcdefghijklmnopqrstuvwxyz") == "bcdfghjklmnpqrstvwxyz"
// removeVowels("") == ""
// removeVowels("aeiou") == ""
// removeVowels("aeiouAEIOU") == ""
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// 7. Write a function that takes a string and returns a string with all the vowels removed.
// removeVowels("abcdefghijklmnopqrstuvwxyz") == "bcdfghjklmnpqrstvwxyz"
// removeVowels("") == ""
// removeVowels("aeiou") == ""
// removeVowels("aeiouAEIOU") == ""
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if !isVowel(char) {
if !isVowel(char) { // cannot find 'isVowel' in scope
result += char // cannot convert value of type 'Character' to expected argument type 'String'

func sumProduct(numbers: [Int]) -> (Int, Int) {
    var sum = 0
    var product = 1
    for number in numbers {
        sum += number
        product *= number
    }
    return (sum, product)
}
```swift
// For a given array of integers, return a tuple consisting of a sum and a product of all the integers in an array.
// Empty sum should be equal to 0 and empty product should be equal to 1.
// sumProduct(numbers: [] as [Int]) == (0, 1)
// sumProduct(numbers: [1, 2, 3, 4]) == (10, 24)
func sumProduct(numbers: [Int]) -> (Int, Int) {
    var sum = 0
    var product = 1
    for number in numbers {
        sum += number
        product *= number
    }
    return (sum, product)
}

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------

func sumProduct(numbers: [Int]) -> (Int, Int) {
    var sum = 0
    var product = 1
    for number in numbers {
        sum += number
        product *= number
    }
    return (sum, product)
}

func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" && char != "y" {
            result += char
        }
    }
    return result
}
```swift
// For a given array of integers, return a tuple consisting of a sum and a product of all the integers in an array.
// Empty sum should be equal to 0 and empty product should be equal to 1.
// sumProduct(numbers: [] as [Int]) == (0, 1)
// sumProduct(numbers: [1, 2, 3, 4]) == (10, 24)
func sumProduct(numbers: [Int]) -> (Int, Int) {
    var sum = 0
    var product = 1
    for number in numbers {
        sum += number
        product *= number
    }
    return (sum, product)
}

// ----------------------------------------------------------------------------------------------------------------------

// 1.1
// Given a string, return a new string with all the vowels removed.
// For example, "This is a test string" yields "Ths s  tst strng".
// Do not count "y" as a vowel.
// removeVowels("This is a test string") == "Ths s  tst strng"
// removeVowels("aeiou") == ""
// removeVowels("") == ""
// removeVowels("y") == ""
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" && char != "y" {
            result += char
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// 1.2
// Given a string, return a new string with all the vowels removed.
// For example, "This is a test string" yields "Ths s  tst strng".
// Do not count "y" as a vowel.
// removeVowels("This is a test string") == "Ths s  tst strng"
// removeVowels("aeiou") == ""
// removeVowels("") == ""
// removeVowels("y") == ""
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" && char != "y" {
            result += char
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// 1.3
// Given a string, return a new string with all the vowels removed.
// For example, "This is a test string" yields "Ths s  tst strng".
// Do not count "y" as a vowel.
// removeVowels("This is a test string") == "Ths s  tst strng"
// removeVowels("aeiou") == ""
// removeVowels("") == ""
// removeVowels("y") == ""
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" && char != "y" {
            result += char
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// 1.4
// Given a string, return a new string with all the vowels removed.
// For example, "This is a test string" yields "Ths s  tst strng".
// Do not count "y" as a vowel.
// removeVowels("This is a test string") == "Ths s  tst strng"
// removeVowels("aeiou") == ""
// removeVowels("") == ""
// removeVowels("y
result += char // cannot convert value of type 'Character' to expected argument type 'String'

func sumProduct(numbers: [Int]) -> (Int, Int) {
    var sum = 0
    var product = 1
    for number in numbers {
        sum += number
        product *= number
    }
    return (sum, product)
}
```swift
// For a given array of integers, return a tuple consisting of a sum and a product of all the integers in an array.
// Empty sum should be equal to 0 and empty product should be equal to 1.
// sumProduct(numbers: [] as [Int]) == (0, 1)
// sumProduct(numbers: [1, 2, 3, 4]) == (10, 24)
func sumProduct(numbers: [Int]) -> (Int, Int) {
    var sum = 0
    var product = 1
    for number in numbers {
        sum += number
        product *= number
    }
    return (sum, product)
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ---------------------

func sumProduct(numbers: [Int]) -> (Int, Int) {
    var sum = 0
    var product = 1
    for number in numbers {
        sum += number
        product *= number
    }
    return (sum, product)
}
```swift
// For a given array of integers, return a tuple consisting of a sum and a product of all the integers in an array.
// Empty sum should be equal to 0 and empty product should be equal to 1.
// sumProduct(numbers: [] as [Int]) == (0, 1)
// sumProduct(numbers: [1, 2, 3, 4]) == (10, 24)
func sumProduct(numbers: [Int]) -> (Int, Int) {
    var sum = 0
    var product = 1
    for number in numbers {
        sum += number
        product *= number
    }
    return (sum, product)
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ---------------------

func sumProduct(numbers: [Int]) -> (Int, Int) {
    var sum = 0
    var product = 1
    for number in numbers {
        sum += number
        product *= number
    }
    return (sum, product)
}
```swift
// For a given array of integers, return a tuple consisting of a sum and a product of all the integers in an array.
// Empty sum should be equal to 0 and empty product should be equal to 1.
// sumProduct(numbers: [] as [Int]) == (0, 1)
// sumProduct(numbers: [1, 2, 3, 4]) == (10, 24)
func sumProduct(numbers: [Int]) -> (Int, Int) {
    var sum = 0
    var product = 1
    for number in numbers {
        sum += number
        product *= number
    }
    return (sum, product)
}

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------

func sumProduct(numbers: [Int]) -> (Int, Int) {
    var sum = 0
    var product = 1
    for number in numbers {
        sum += number
        product *= number
    }
    return (sum, product)
}
```swift
// For a given array of integers, return a tuple consisting of a sum and a product of all the integers in an array.
// Empty sum should be equal to 0 and empty product should be equal to 1.
// sumProduct(numbers: [] as [Int]) == (0, 1)
// sumProduct(numbers: [1, 2, 3, 4]) == (10, 24)
func sumProduct(numbers: [Int]) -> (Int, Int) {
    var sum = 0
    var product = 1
    for number in numbers {
        sum += number
        product *= number
    }
    return (sum, product)
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ---------------------

func sumProduct(numbers: [Int]) -> (Int, Int) {
    var sum = 0
    var product = 1
    for number in numbers {
        sum += number
        product *= number
    }
    return (sum, product)
}
```swift
// For a given array of integers, return a tuple consisting of a sum and a product of all the integers in an array.
// Empty sum should be equal to 0 and empty product should be equal to 1.
// sumProduct(numbers: [] as [Int]) == (0, 1)
// sumProduct(numbers: [1, 2, 3, 4]) == (10, 24)
func sumProduct(numbers: [Int]) -> (Int, Int) {
    var sum = 0
    var product = 1
    for number in numbers {
        sum += number
        product *= number
    }
    return (sum, product)
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ---------------------

func sumProduct(numbers: [Int]) -> (Int, Int) {
    var sum = 0
    var product = 1
    for number in numbers {
        sum += number
        product *= number
    }
    return (sum, product)
}
```swift
// For a given array of integers, return a tuple consisting of a sum and a product of all the integers in an array.
// Empty sum should be equal to 0 and empty product should be equal to 1.
// sumProduct(numbers: [] as [Int]) == (0, 1)
// sumProduct(numbers: [1, 2, 3, 4]) == (10, 24)
func sumProduct(numbers: [Int]) -> (Int, Int) {
    var sum = 0
    var product = 1
    for number in numbers {
        sum += number
        product *= number
    }
    return (sum, product)
}

// ----------------------------------------------------------------------------------------------------------------------

// 1. Write a function that takes a string and returns a string with all the vowels removed.
// Empty string should be returned for empty input.
// removeVowels("") == ""
// removeVowels("abcdef") == "bcdf"
// removeVowels("aeiou") == ""
// removeVowels("AEIOU") == ""
// removeVowels("abracadabra") == "brcrcdbr"
// removeVowels("aeiouAEIOU") == ""
// removeVowels("AEIOUaeiou") == ""
// removeVowels("AEIOUaeiouAEIOU") == ""
// removeVowels("AEIOUaeiouAEIOUaeiouAEIOU") == ""
// removeVowels("AEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaei

func rollingMax(numbers: [Int]) -> [Int] {
    var rollingMax = [Int]()
    var max = Int()
    for number in numbers {
        if number > max {
            max = number
        }
        rollingMax.append(max)
    }
    return rollingMax
}
```swift
// From a given array of integers, generate an array of rolling maximum element found until given moment
// in the sequence.
// rollingMax(numbers: [1, 2, 3, 2, 3, 4, 2]) == [1, 2, 3, 3, 3, 4, 4]
func rollingMax(numbers: [Int]) -> [Int] {
    var rollingMax = [Int]()
    var max = Int()
    for number in numbers {
        if number > max {
            max = number
        }
        rollingMax.append(max)
    }
    return rollingMax
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ---------------

func rollingMax(numbers: [Int]) -> [Int] {
    var result = [Int]()
    var max = Int()
    for number in numbers {
        if number > max {
            max = number
        }
        result.append(max)
    }
    return result
}
```swift
// From a given array of integers, generate an array of rolling maximum element found until given moment
// in the sequence.
// rollingMax(numbers: [1, 2, 3, 2, 3, 4, 2]) == [1, 2, 3, 3, 3, 4, 4]
func rollingMax(numbers: [Int]) -> [Int] {
    var result = [Int]()
    var max = Int()
    for number in numbers {
        if number > max {
            max = number
        }
        result.append(max)
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

func rollingMax(numbers: [Int]) -> [Int] {
    var result = [numbers[0]]
    for i in 1..<numbers.count {
        result.append(max(result[i - 1], numbers[i]))
    }
    return result
}
```swift
// From a given array of integers, generate an array of rolling maximum element found until given moment
// in the sequence.
// rollingMax(numbers: [1, 2, 3, 2, 3, 4, 2]) == [1, 2, 3, 3, 3, 4, 4]
func rollingMax(numbers: [Int]) -> [Int] {
    var result = [numbers[0]]
    for i in 1..<numbers.count {
        result.append(max(result[i - 1], numbers[i]))
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

//
 // Fatal error: Index out of range

func rollingMax(numbers: [Int]) -> [Int] {
    var result = [Int]()
    var max = Int()
    for number in numbers {
        if number > max {
            max = number
        }
        result.append(max)
    }
    return result
}
```swift
// From a given array of integers, generate an array of rolling maximum element found until given moment
// in the sequence.
// rollingMax(numbers: [1, 2, 3, 2, 3, 4, 2]) == [1, 2, 3, 3, 3, 4, 4]
func rollingMax(numbers: [Int]) -> [Int] {
    var result = [Int]()
    var max = Int()
    for number in numbers {
        if number > max {
            max = number
        }
        result.append(max)
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ------------------------

func rollingMax(numbers: [Int]) -> [Int] {
    var result = [Int]()
    var max = Int()
    for i in numbers {
        if i > max {
            max = i
        }
        result.append(max)
    }
    return result
}
```swift
// From a given array of integers, generate an array of rolling maximum element found until given moment
// in the sequence.
// rollingMax(numbers: [1, 2, 3, 2, 3, 4, 2]) == [1, 2, 3, 3, 3, 4, 4]
func rollingMax(numbers: [Int]) -> [Int] {
    var result = [Int]()
    var max = Int()
    for i in numbers {
        if i > max {
            max = i
        }
        result.append(max)
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

func rollingMax(numbers: [Int]) -> [Int] {
    var result = [Int]()
    var max = Int()
    for number in numbers {
        if number > max {
            max = number
        }
        result.append(max)
    }
    return result
}
```swift
// From a given array of integers, generate an array of rolling maximum element found until given moment
// in the sequence.
// rollingMax(numbers: [1, 2, 3, 2, 3, 4, 2]) == [1, 2, 3, 3, 3, 4, 4]
func rollingMax(numbers: [Int]) -> [Int] {
    var result = [Int]()
    var max = Int()
    for number in numbers {
        if number > max {
            max = number
        }
        result.append(max)
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

func rollingMax(numbers: [Int]) -> [Int] {
    var result = [Int]()
    var max = Int()
    for number in numbers {
        if number > max {
            max = number
        }
        result.append(max)
    }
    return result
}
```swift
// From a given array of integers, generate an array of rolling maximum element found until given moment
// in the sequence.
// rollingMax(numbers: [1, 2, 3, 2, 3, 4, 2]) == [1, 2, 3, 3, 3, 4, 4]
func rollingMax(numbers: [Int]) -> [Int] {
    var result = [Int]()
    var max = Int()
    for number in numbers {
        if number > max {
            max = number
        }
        result.append(max)
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

func rollingMax(numbers: [Int]) -> [Int] {
    var result = [Int]()
    var max = Int()
    for i in numbers {
        if i > max {
            max = i
        }
        result.append(max)
    }
    return result
}
```swift
// From a given array of integers, generate an array of rolling maximum element found until given moment
// in the sequence.
// rollingMax(numbers: [1, 2, 3, 2, 3, 4, 2]) == [1, 2, 3, 3, 3, 4, 4]
func rollingMax(numbers: [Int]) -> [Int] {
    var result = [Int]()
    var max = Int()
    for i in numbers {
        if i > max {
            max = i
        }
        result.append(max)
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

func rollingMax(numbers: [Int]) -> [Int] {
    var result = [numbers.first!]
    for i in 1..<numbers.count {
        result.append(max(result[i - 1], numbers[i]))
    }
    return result
}
```swift
// From a given array of integers, generate an array of rolling maximum element found until given moment
// in the sequence.
// rollingMax(numbers: [1, 2, 3, 2, 3, 4, 2]) == [1, 2, 3, 3, 3, 4, 4]
func rollingMax(numbers: [Int]) -> [Int] {
    var result = [numbers.first!]
    for i in 1..<numbers.count {
        result.append(max(result[i - 1], numbers[i]))
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ---------------------------------------
 // Fatal error: Unexpectedly found nil while unwrapping an Optional value

func rollingMax(numbers: [Int]) -> [Int] {
    var result = [Int]()
    var max = Int()
    for number in numbers {
        if number > max {
            max = number
        }
        result.append(max)
    }
    return result
}
```swift
// From a given array of integers, generate an array of rolling maximum element found until given moment
// in the sequence.
// rollingMax(numbers: [1, 2, 3, 2, 3, 4, 2]) == [1, 2, 3, 3, 3, 4, 4]
func rollingMax(numbers: [Int]) -> [Int] {
    var result = [Int]()
    var max = Int()
    for number in numbers {
        if number > max {
            max = number
        }
        result.append(max)
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ------------------------

func makePalindrome(string: String) -> String {
  let reversed = reverse(string)
  let prefix = string + reversed
  let suffix = reverse(string)
  return prefix + suffix
}
```swift
// Find the shortest palindrome that begins with a supplied string.
// Algorithm idea is simple:
// - Find the longest postfix of supplied string that is a palindrome.
// - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.
// makePalindrome(string: "") == ""
// makePalindrome(string: "cat") == "catac"
// makePalindrome(string: "cata") == "catac"
func makePalindrome(string: String) -> String {
  let reversed = reverse(string)
  let prefix = string + reversed
  let suffix = reverse(string)
  return prefix + suffix
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ------------------------------------------------------
let reversed = reverse(string) // cannot find 'reverse' in scope
let suffix = reverse(string) // cannot find 'reverse' in scope

func makePalindrome(string: String) -> String {
    let reversed = string.reversed()
    let prefix = string.prefix(while: (reversed.prefix(length: 1) == reversed.suffix(length: 1)))
    return string + prefix.reversed()
}
```swift
// Find the shortest palindrome that begins with a supplied string.
// Algorithm idea is simple:
// - Find the longest postfix of supplied string that is a palindrome.
// - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.
// makePalindrome(string: "") == ""
// makePalindrome(string: "cat") == "catac"
// makePalindrome(string: "cata") == "catac"
func makePalindrome(string: String) -> String {
    let reversed = string.reversed()
    let prefix = string.prefix(while: (reversed.prefix(length: 1) == reversed.suffix(length: 1)))
    return string + prefix.reversed()
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 2.2
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 2.3
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 2.4
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 2.5
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 2.6
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 2.7
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 2.8
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 2.9
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 2.10
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 2.11
// ---------------------------------------------------------------------------------------------------------------
let prefix = string.prefix(while: (reversed.prefix(length: 1) == reversed.suffix(length: 1))) // cannot convert value of type 'Bool' to expected argument type '(String.Element) throws -> Bool' (aka '(Character) throws -> Bool')
let prefix = string.prefix(while: (reversed.prefix(length: 1) == reversed.suffix(length: 1))) // extraneous argument label 'length:' in call
let prefix = string.prefix(while: (reversed.prefix(length: 1) == reversed.suffix(length: 1))) // extraneous argument label 'length:' in call
let prefix = string.prefix(while: (reversed.prefix(length: 1) == reversed.suffix(length: 1))) // cannot convert value of type 'ReversedCollection<String>.SubSequence' (aka 'Slice<ReversedCollection<String>>') to expected argument type '[ReversedCollection<String>.Element]' (aka 'Array<Character>')

func makePalindrome(string: String) -> String {
    let reversed = string.reversed().join()
    let prefix = string.prefix(while: (reversed.prefix(length: 1) == string.suffix(length: 1)))
    return string + reversed.prefix(length: prefix.count)
}
```swift
// Find the shortest palindrome that begins with a supplied string.
// Algorithm idea is simple:
// - Find the longest postfix of supplied string that is a palindrome.
// - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.
// makePalindrome(string: "") == ""
// makePalindrome(string: "cat") == "catac"
// makePalindrome(string: "cata") == "catac"
func makePalindrome(string: String) -> String {
    let reversed = string.reversed().join()
    let prefix = string.prefix(while: (reversed.prefix(length: 1) == string.suffix(length: 1)))
    return string + reversed.prefix(length: prefix.count)
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------------------------------------------------------------
let reversed = string.reversed().join() // reference to member 'join' cannot be resolved without a contextual type
let prefix = string.prefix(while: (reversed.prefix(length: 1) == string.suffix(length: 1))) // cannot convert value of type 'Bool' to expected argument type '(String.Element) throws -> Bool' (aka '(Character) throws -> Bool')
let prefix = string.prefix(while: (reversed.prefix(length: 1) == string.suffix(length: 1))) // extraneous argument label 'length:' in call

func makePalindrome(string: String) -> String {
    let reversed = String(string.reversed())
    let prefix = string.prefix(while: (reversed.prefix(length: $0) == reversed.prefix(length: $0)))
    return string + reversed.suffix(length: prefix.count)
}
```swift
// Find the shortest palindrome that begins with a supplied string.
// Algorithm idea is simple:
// - Find the longest postfix of supplied string that is a palindrome.
// - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.
// makePalindrome(string: "") == ""
// makePalindrome(string: "cat") == "catac"
// makePalindrome(string: "cata") == "catac"
func makePalindrome(string: String) -> String {
    let reversed = String(string.reversed())
    let prefix = string.prefix(while: (reversed.prefix(length: $0) == reversed.prefix(length: $0)))
    return string + reversed.suffix(length: prefix.count)
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 1.1.2
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 1.1.3
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 1.1.4
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 1.1.5
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 1.1.6
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 1.1.7
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 1.1.8
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 1.1.9
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 1.1.10
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 1.1.11
// ------------------------------
let prefix = string.prefix(while: (reversed.prefix(length: $0) == reversed.prefix(length: $0))) // extraneous argument label 'length:' in call
let prefix = string.prefix(while: (reversed.prefix(length: $0) == reversed.prefix(length: $0))) // anonymous closure argument not contained in a closure
let prefix = string.prefix(while: (reversed.prefix(length: $0) == reversed.prefix(length: $0))) // extraneous argument label 'length:' in call
let prefix = string.prefix(while: (reversed.prefix(length: $0) == reversed.prefix(length: $0))) // anonymous closure argument not contained in a closure
let prefix = string.prefix(while: (reversed.prefix(length: $0) == reversed.prefix(length: $0))) // cannot convert value of type 'Bool' to expected argument type '(String.Element) throws -> Bool' (aka '(Character) throws -> Bool')
return string + reversed.suffix(length: prefix.count) // no exact matches in call to instance method 'suffix'

func makePalindrome(string: String) -> String {
    let reversed = String(string.reversed())
    let prefix = string.prefix(while: (reversed.prefix(length: 1) == string.suffix(length: 1)))
    return string + reversed.prefix(length: prefix.count)
}
```swift
// Find the shortest palindrome that begins with a supplied string.
// Algorithm idea is simple:
// - Find the longest postfix of supplied string that is a palindrome.
// - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.
// makePalindrome(string: "") == ""
// makePalindrome(string: "cat") == "catac"
// makePalindrome(string: "cata") == "catac"
func makePalindrome(string: String) -> String {
    let reversed = String(string.reversed())
    let prefix = string.prefix(while: (reversed.prefix(length: 1) == string.suffix(length: 1)))
    return string + reversed.prefix(length: prefix.count)
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------------
let prefix = string.prefix(while: (reversed.prefix(length: 1) == string.suffix(length: 1))) // extraneous argument label 'length:' in call
let prefix = string.prefix(while: (reversed.prefix(length: 1) == string.suffix(length: 1))) // cannot convert value of type 'Bool' to expected argument type '(String.Element) throws -> Bool' (aka '(Character) throws -> Bool')
let prefix = string.prefix(while: (reversed.prefix(length: 1) == string.suffix(length: 1))) // extraneous argument label 'length:' in call
return string + reversed.prefix(length: prefix.count) // no exact matches in call to instance method 'prefix'

func makePalindrome(string: String) -> String {
    let reversed = string.reversed()
    let prefix = string.prefix(while: (reversed.dropFirst() != string.dropFirst()))
    return string + prefix.reversed()
}
```swift
// Find the shortest palindrome that begins with a supplied string.
// Algorithm idea is simple:
// - Find the longest postfix of supplied string that is a palindrome.
// - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.
// makePalindrome(string: "") == ""
// makePalindrome(string: "cat") == "catac"
// makePalindrome(string: "cata") == "catac"
func makePalindrome(string: String) -> String {
    let reversed = string.reversed()
    let prefix = string.prefix(while: (reversed.dropFirst() != string.dropFirst()))
    return string + prefix.reversed()
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ------------
let prefix = string.prefix(while: (reversed.dropFirst() != string.dropFirst())) // cannot convert value of type 'Bool' to expected argument type '(String.Element) throws -> Bool' (aka '(Character) throws -> Bool')
let prefix = string.prefix(while: (reversed.dropFirst() != string.dropFirst())) // cannot convert value of type 'ReversedCollection<String>.SubSequence' (aka 'Slice<ReversedCollection<String>>') to expected argument type 'String.SubSequence' (aka 'Substring')

func makePalindrome(string: String) -> String {
    let reversed = string.reversed()
    let reversedPrefix = string.prefix(while: (reversed.prefix(1) == string.suffix(1)))
    return string + reversedPrefix.reversed()
}
```swift
// Find the shortest palindrome that begins with a supplied string.
// Algorithm idea is simple:
// - Find the longest postfix of supplied string that is a palindrome.
// - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.
// makePalindrome(string: "") == ""
// makePalindrome(string: "cat") == "catac"
// makePalindrome(string: "cata") == "catac"
func makePalindrome(string: String) -> String {
    let reversed = string.reversed()
    let reversedPrefix = string.prefix(while: (reversed.prefix(1) == string.suffix(1)))
    return string + reversedPrefix.reversed()
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ---
let reversedPrefix = string.prefix(while: (reversed.prefix(1) == string.suffix(1))) // cannot convert value of type 'Bool' to expected argument type '(String.Element) throws -> Bool' (aka '(Character) throws -> Bool')
let reversedPrefix = string.prefix(while: (reversed.prefix(1) == string.suffix(1))) // cannot convert value of type 'ReversedCollection<String>.SubSequence' (aka 'Slice<ReversedCollection<String>>') to expected argument type 'String.SubSequence' (aka 'Substring')

func makePalindrome(string: String) -> String {
    let reversed = string.reversed()
    let reversedPrefix = string.prefix(while: (reversed.prefix(1) == string.prefix(1)))
    return string + reversedPrefix.reversed()
}
```swift
// Find the shortest palindrome that begins with a supplied string.
// Algorithm idea is simple:
// - Find the longest postfix of supplied string that is a palindrome.
// - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.
// makePalindrome(string: "") == ""
// makePalindrome(string: "cat") == "catac"
// makePalindrome(string: "cata") == "catac"
func makePalindrome(string: String) -> String {
    let reversed = string.reversed()
    let reversedPrefix = string.prefix(while: (reversed.prefix(1) == string.prefix(1)))
    return string + reversedPrefix.reversed()
}

// ----------------------------------------------------------------------------------------------------------------------

// 1.1.1
// Write a function that takes a string and returns the number of times each letter appears in the string.
// countLetters("") == {}
// countLetters("a") == {"a": 1}
// countLetters("aa") == {"a": 2}
// countLetters("ab") == {"a": 1, "b": 1}
// countLetters("abc") == {"a": 1, "b": 1, "c": 1}
// countLetters("abca") == {"a": 2, "b": 1, "c": 1}
// countLetters("abcb") == {"a": 1, "b": 2, "c": 1}
// countLetters("abcc") == {"a": 1, "b": 1, "c": 2}
// countLetters("abccc") == {"a": 1, "b": 1, "c": 3}
// countLetters("abcccc") == {"a": 1, "b": 1, "c": 4}
// countLetters("abccccc") == {"a": 1, "b": 1, "c": 5}
// countLetters("abcccccc") == {"a": 1, "b": 1, "c": 6}
// countLetters("abccccccc") == {"a": 1, "b": 1, "c": 7}
// countLetters("abccccccc") == {"a": 1, "b": 1, "c": 7}
// countLetters("abccccccc") == {"a": 1, "b": 1, "c": 7}
// countLetters("abccccccc") == {"a": 1, "b": 1, "c": 7}
// countLetters("abccccccc") == {"a": 1, "b": 1, "c": 7}
// countLetters("abccccccc") == {"a": 1, "b": 1, "c": 7}
// countLetters("abccccccc") == {"a": 1, "b": 1, "c": 7}
// countLetters("abccccccc") == {"a": 1, "b": 1, "c": 7}
// countLetters("abccccccc") == {"a": 1, "b": 1, "c": 7}
// countLetters("abccccccc") == {"a": 1, "b": 1, "c": 7}
// countLetters("abccccccc") == {"a": 1, "b": 1, "c": 7}
// countLetters("abccccccc") == {"a": 1, "b": 1, "c": 7}
// countLetters("abccccccc") == {"a": 1, "b": 1, "c": 7}
// countLetters("abccccccc") == {"a": 1, "b": 1, "c": 7}
// countLetters("abccccccc") == {"a": 1, "b": 1, "c": 7}
// countLetters("abccccccc") == {"a": 1, "b": 1, "c": 7}
// countLetters("abccccccc") == {"a": 1, "b": 1, "c": 7}
// countLetters("abccccccc") == {"a": 1, "b": 1, "c": 7}
// count
let reversedPrefix = string.prefix(while: (reversed.prefix(1) == string.prefix(1))) // cannot convert value of type 'Bool' to expected argument type '(String.Element) throws -> Bool' (aka '(Character) throws -> Bool')
let reversedPrefix = string.prefix(while: (reversed.prefix(1) == string.prefix(1))) // cannot convert value of type 'ReversedCollection<String>.SubSequence' (aka 'Slice<ReversedCollection<String>>') to expected argument type 'String.SubSequence' (aka 'Substring')

func makePalindrome(string: String) -> String {
    let reversed = string.reversed()
    let prefix = string.prefix(while: (reversed.prefix(length: 1) == string.suffix(length: 1)))
    return string + reversed.prefix(length: prefix.count)
}
```swift
// Find the shortest palindrome that begins with a supplied string.
// Algorithm idea is simple:
// - Find the longest postfix of supplied string that is a palindrome.
// - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.
// makePalindrome(string: "") == ""
// makePalindrome(string: "cat") == "catac"
// makePalindrome(string: "cata") == "catac"
func makePalindrome(string: String) -> String {
    let reversed = string.reversed()
    let prefix = string.prefix(while: (reversed.prefix(length: 1) == string.suffix(length: 1)))
    return string + reversed.prefix(length: prefix.count)
}

// ----------------------------------------------------------------------------------------------------------------------

// 1.1.12
// Write a short program that prints each number from 1 to 100 on a new line.
// For each multiple of 3, print "Fizz" instead of the number.
// For each multiple of 5, print "Buzz" instead of the number.
// For numbers which are multiples of both 3 and 5, print "FizzBuzz" instead of the number.
for i in 1...100 {
    print(i)
    if i % 3 == 0 {
        print("Fizz")
    }
    if i % 5 == 0 {
        print("Buzz")
    }
    print()
}

// ----------------------------------------------------------------------------------------------------------------------

// 1.1.13
// Write a short program that prints each number from 1 to 100 on a new line.
// For each multiple of 3, print "Fizz" instead of the number.
// For each multiple of 5, print "Buzz" instead of the number.
// For numbers which are multiples of both 3 and 5, print "FizzBuzz" instead of the number.
for i in 1...100 {
    print(i)
    if i % 3 == 0 {
        print("Fizz")
    }
    if i % 5 == 0 {
        print("Buzz")
    }
    if i % 3 == 0 && i % 5 == 0 {
        print("FizzBuzz")
    }
    print()
}

// ----------------------------------------------------------------------------------------------------------------------

// 1.1.14
// Write a short program that prints each number from 1 to 100 on a new line.
// For each multiple of 3, print "Fizz" instead of the number.
// For each multiple of 5, print "Buzz" instead of the number.
// For numbers which are multiples of both 3 and 5, print "FizzBuzz" instead of the number.
for i in 1...100 {
    print(i)
    if i % 3 == 0 {
        print("Fizz")
    }
    if i % 5 == 0 {
        print("Buzz")
    }
    if i % 3 == 0 && i % 5 == 0 {
        print("FizzBuzz")
    }
    print()
}

// ----------------------------------------------------------------------------------------------------------------------

// 1.1.15
// Write a short program that prints each number from 1 to 100 on a new line.
// For each multiple of 3, print "Fizz" instead of the number.
// For each multiple of 5, print "Buzz" instead of the number.
// For numbers which are multiples of both 3 and 5, print "FizzBuzz" instead of the number.
for i in 1...100 {
    print(i)
    if i % 3 == 0 {
        print("Fizz")
    }
    if i % 5 == 0 {
        print("Buzz")
    }
    if i % 3 == 0 && i % 5 == 0 {
        print("FizzBuzz")
    }
    print()
}

// ---------------
let prefix = string.prefix(while: (reversed.prefix(length: 1) == string.suffix(length: 1))) // extraneous argument label 'length:' in call
let prefix = string.prefix(while: (reversed.prefix(length: 1) == string.suffix(length: 1))) // cannot convert value of type 'Bool' to expected argument type '(String.Element) throws -> Bool' (aka '(Character) throws -> Bool')
let prefix = string.prefix(while: (reversed.prefix(length: 1) == string.suffix(length: 1))) // extraneous argument label 'length:' in call
let prefix = string.prefix(while: (reversed.prefix(length: 1) == string.suffix(length: 1))) // cannot convert value of type 'ReversedCollection<String>.SubSequence' (aka 'Slice<ReversedCollection<String>>') to expected argument type 'String.SubSequence' (aka 'Substring')
return string + reversed.prefix(length: prefix.count) // no exact matches in call to instance method 'prefix'

func makePalindrome(string: String) -> String {
    let reversed = String(string.reversed())
    let palindrome = string + reversed
    return palindrome
}
```swift
// Find the shortest palindrome that begins with a supplied string.
// Algorithm idea is simple:
// - Find the longest postfix of supplied string that is a palindrome.
// - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.
// makePalindrome(string: "") == ""
// makePalindrome(string: "cat") == "catac"
// makePalindrome(string: "cata") == "catac"
func makePalindrome(string: String) -> String {
    let reversed = String(string.reversed())
    let palindrome = string + reversed
    return palindrome
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------
 // XCTAssertTrue failed

func stringXor(a: String, b: String) -> String {
    var result = ""
    for i in 0..<a.count {
        if a[i] == b[i] {
            result += "0"
        } else {
            result += "1"
        }
    }
    return result
}
```swift
// Input are two strings a and b consisting only of 1s and 0s.
// Perform binary XOR on these inputs and return result also as a string.
// stringXor(a: "010", b: "110") == "100"
func stringXor(a: String, b: String) -> String {
    var result = ""
    for i in 0..<a.count {
        if a[i] == b[i] {
            result += "0"
        } else {
            result += "1"
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ---------------------------------------------------
if a[i] == b[i] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if a[i] == b[i] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.

func stringXor(a: String, b: String) -> String {
    var result = ""
    for i in 0..<a.count {
        if a[i] == b[i] {
            result += "0"
        } else {
            result += "1"
        }
    }
    return result
}

func stringReverse(s: String) -> String {
    return String(s.reversed())
}

func stringRemoveFirst(s: String) -> String {
    return s.substring(1)
}

func stringRemoveLast(s: String) -> String {
    return s.substring(0, s.count - 1)
}

func stringRemoveFirstAndLast(s: String) -> String {
    return s.substring(1, s.count - 1)
}

func stringReplaceFirst(s: String) -> String {
    return "$" + s.substring(1)
}

func stringReplaceLast(s: String) -> String {
    return s.substring(0, s.count - 1) + "$"
}

func stringReplaceFirstAndLast(s: String) -> String {
    return "$" + s.substring(1, s.count - 1) + "$"
}

func stringRemoveVowels(s: String) -> String {
    var result = ""
    for char in s {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

func stringRemoveVowelsAndReplaceConsonants(s: String) -> String {
    var result = ""
    for char in s {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += "*"
        } else {
            result += char
        }
    }
    return result
}
```swift
// Input are two strings a and b consisting only of 1s and 0s.
// Perform binary XOR on these inputs and return result also as a string.
// stringXor(a: "010", b: "110") == "100"
func stringXor(a: String, b: String) -> String {
    var result = ""
    for i in 0..<a.count {
        if a[i] == b[i] {
            result += "0"
        } else {
            result += "1"
        }
    }
    return result
}

// 2. Write a function that takes a string as input and returns the string reversed.
// stringReverse("hello") == "olleh"
func stringReverse(s: String) -> String {
    return String(s.reversed())
}

// 3. Write a function that takes a string as input and returns the string with the first character removed.
// stringRemoveFirst("hello") == "ello"
func stringRemoveFirst(s: String) -> String {
    return s.substring(1)
}

// 4. Write a function that takes a string as input and returns the string with the last character removed.
// stringRemoveLast("hello") == "hell"
func stringRemoveLast(s: String) -> String {
    return s.substring(0, s.count - 1)
}

// 5. Write a function that takes a string as input and returns the string with the first and last characters removed.
// stringRemoveFirstAndLast("hello") == "ell"
func stringRemoveFirstAndLast(s: String) -> String {
    return s.substring(1, s.count - 1)
}

// 6. Write a function that takes a string as input and returns the string with the first character replaced by "$".
// stringReplaceFirst("hello") == "$ello"
func stringReplaceFirst(s: String) -> String {
    return "$" + s.substring(1)
}

// 7. Write a function that takes a string as input and returns the string with the last character replaced by "$".
// stringReplaceLast("hello") == "hell$"
func stringReplaceLast(s: String) -> String {
    return s.substring(0, s.count - 1) + "$"
}

// 8. Write a function that takes a string as input and returns the string with the first and last characters replaced by "$".
// stringReplaceFirstAndLast("hello") == "$ello$"
func stringReplaceFirstAndLast(s: String) -> String {
    return "$" + s.substring(1, s.count - 1) + "$"
}

// 9. Write a function that takes a string as input and returns the string with all the vowels removed.
// stringRemoveVowels("hello") == "hll"
func stringRemoveVowels(s: String) -> String {
    var result = ""
    for char in s {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// 10. Write a function that takes a string as input and returns the string with all the vowels removed, and all the consonants replaced by "*".
// stringRemoveVowelsAndReplaceConsonants("hello") == "h*ll*"
func stringRemoveVowelsAndReplaceConsonants(s: String) -> String {
    var result = ""
    for char in s {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += "*"
        } else {
            result += char
        }
    }
    return result
}

// 11. Write a function that takes a string as input and returns the string with all the vowels removed, and all the consonants replaced by "*", and all the digits removed.
// stringRemoveVowelsAndReplaceConsonantsAndRemoveDigits("hello123") == "h*ll*"
func stringRemoveVowelsAndReplaceConsonantsAndRemoveDigits(s: String) -> String {
    var result = ""
    for char in s {
        if char != "a" && char != "e" && char != "i" && char != "
if a[i] == b[i] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if a[i] == b[i] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
return s.substring(1) // no exact matches in call to instance method 'substring'
return s.substring(0, s.count - 1) // no exact matches in call to instance method 'substring'
return s.substring(1, s.count - 1) // no exact matches in call to instance method 'substring'
return "$" + s.substring(1) // no exact matches in call to instance method 'substring'
return s.substring(0, s.count - 1) + "$" // no exact matches in call to instance method 'substring'
return "$" + s.substring(1, s.count - 1) + "$" // no exact matches in call to instance method 'substring'
result += char // cannot convert value of type 'Character' to expected argument type 'String'
result += char // cannot convert value of type 'Character' to expected argument type 'String'

func stringXor(a: String, b: String) -> String {
    var result = ""
    for i in 0..<a.count {
        if a[i] == b[i] {
            result += "0"
        } else {
            result += "1"
        }
    }
    return result
}

func stringReverse(s: String) -> String {
    return String(s.reversed())
}

func stringCapitalize(s: String) -> String {
    return String(s.capitalized)
}
```swift
// Input are two strings a and b consisting only of 1s and 0s.
// Perform binary XOR on these inputs and return result also as a string.
// stringXor(a: "010", b: "110") == "100"
func stringXor(a: String, b: String) -> String {
    var result = ""
    for i in 0..<a.count {
        if a[i] == b[i] {
            result += "0"
        } else {
            result += "1"
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 10. Write a function that takes a string as input and returns the string reversed.
// stringReverse("hello") == "olleh"
func stringReverse(s: String) -> String {
    return String(s.reversed())
}

// -----------------------------------------------------------------------------
// 11. Write a function that takes a string as input and returns the string with the first character
// capitalized and the rest lowercase.
// stringCapitalize("hello") == "Hello"
func stringCapitalize(s: String) -> String {
    return String(s.capitalized)
}

// -----------------------------------------------------------------------------
// 12. Write a function that takes a string as input and returns the string with the first letter
// capitalized and the rest lowercase.
// stringCapitalize("hello") == "Hello"
func stringCapitalize(s: String) -> String {
    return String(s.capitalized)
}

// -----------------------------------------------------------------------------
// 13. Write a function that takes a string as input and returns the string with the first letter
// capitalized and the rest lowercase.
// stringCapitalize("hello") == "Hello"
func stringCapitalize(s: String) -> String {
    return String(s.capitalized)
}

// -----------------------------------------------------------------------------
// 14. Write a function that takes a string as input and returns the string with the first letter
// capitalized and the rest lowercase.
// stringCapitalize("hello") == "Hello"
func stringCapitalize(s: String) -> String {
    return String(s.capitalized)
}

// -----------------------------------------------------------------------------
// 15. Write a function that takes a string as input and returns the string with the first letter
// capitalized and the rest lowercase.
// stringCapitalize("hello") == "Hello"
func stringCapitalize(s: String) -> String {
    return String(s.capitalized)
}

// -----------------------------------------------------------------------------
// 16. Write a function that takes a string as input and returns the string with the first letter
// capitalized and the rest lowercase.
// stringCapitalize("hello") == "Hello"
func stringCapitalize(s: String) -> String {
    return String(s.capitalized)
}

// -----------------------------------------------------------------------------
// 17. Write a function that takes a string as input and returns the string with the first letter
// capitalized and the rest lowercase.
// stringCapitalize("hello") == "Hello"
func stringCapitalize(s: String) -> String {
    return String(s.capitalized)
}

// -----------------------------------------------------------------------------
// 18. Write a function that takes a string as input and returns the string with the first letter
// capitalized and the rest lowercase.
// stringCapitalize("hello") == "Hello"
func stringCapitalize(s: String) -> String {
    return String(s.capitalized)
}

// -----------------------------------------------------------------------------
// 19
if a[i] == b[i] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if a[i] == b[i] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.

func stringXor(a: String, b: String) -> String {
    var result = ""
    for i in 0..<a.count {
        if a[i] == b[i] {
            result += "0"
        } else {
            result += "1"
        }
    }
    return result
}
```swift
// Input are two strings a and b consisting only of 1s and 0s.
// Perform binary XOR on these inputs and return result also as a string.
// stringXor(a: "010", b: "110") == "100"
func stringXor(a: String, b: String) -> String {
    var result = ""
    for i in 0..<a.count {
        if a[i] == b[i] {
            result += "0"
        } else {
            result += "1"
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ---------------------------------------------------
if a[i] == b[i] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if a[i] == b[i] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.

func stringXor(a: String, b: String) -> String {
    var result = ""
    for i in 0..<a.count {
        if a[i] == b[i] {
            result += "0"
        } else {
            result += "1"
        }
    }
    return result
}
```swift
// Input are two strings a and b consisting only of 1s and 0s.
// Perform binary XOR on these inputs and return result also as a string.
// stringXor(a: "010", b: "110") == "100"
func stringXor(a: String, b: String) -> String {
    var result = ""
    for i in 0..<a.count {
        if a[i] == b[i] {
            result += "0"
        } else {
            result += "1"
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ---------------------------------------------------
if a[i] == b[i] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if a[i] == b[i] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.

func stringXor(a: String, b: String) -> String {
    var result = ""
    for i in 0..<a.count {
        if a[i] == "1" && b[i] == "1" {
            result += "0"
        } else if a[i] == "0" && b[i] == "0" {
            result += "0"
        } else {
            result += "1"
        }
    }
    return result
}

func stringLengthOfLongestSubstring(s: String) -> Int {
    var result = 0
    var left = 0
    var right = 0
    var map = [Character: Int]()
    while right < s.count {
        if map[s[right]] != nil {
            left = max(left, map[s[right]]! + 1)
        }
        map[s[right]] = right
        result = max(result, right - left + 1)
        right += 1
    }
    return result
}
```swift
// Input are two strings a and b consisting only of 1s and 0s.
// Perform binary XOR on these inputs and return result also as a string.
// stringXor(a: "010", b: "110") == "100"
func stringXor(a: String, b: String) -> String {
    var result = ""
    for i in 0..<a.count {
        if a[i] == "1" && b[i] == "1" {
            result += "0"
        } else if a[i] == "0" && b[i] == "0" {
            result += "0"
        } else {
            result += "1"
        }
    }
    return result
}

// 2. Given a string, find the length of the longest substring without repeating characters.
// stringLengthOfLongestSubstring("abcabcbb") == 3
// stringLengthOfLongestSubstring("bbbbb") == 1
// stringLengthOfLongestSubstring("pwwkew") == 3
func stringLengthOfLongestSubstring(s: String) -> Int {
    var result = 0
    var left = 0
    var right = 0
    var map = [Character: Int]()
    while right < s.count {
        if map[s[right]] != nil {
            left = max(left, map[s[right]]! + 1)
        }
        map[s[right]] = right
        result = max(result, right - left + 1)
        right += 1
    }
    return result
}

// 3. Given a string, find the length of the longest substring without repeating characters.
// stringLengthOfLongestSubstring("abcabcbb") == 3
// stringLengthOfLongestSubstring("bbbbb") == 1
// stringLengthOfLongestSubstring("pwwkew") == 3
func stringLengthOfLongestSubstring(s: String) -> Int {
    var result = 0
    var left = 0
    var right = 0
    var map = [Character: Int]()
    while right < s.count {
        if map[s[right]] != nil {
            left = max(left, map[s[right]]! + 1)
        }
        map[s[right]] = right
        result = max(result, right - left + 1)
        right += 1
    }
    return result
}

// 4. Given a string, find the length of the longest substring without repeating characters.
// stringLengthOfLongestSubstring("abcabcbb") == 3
// stringLengthOfLongestSubstring("bbbbb") == 1
// stringLengthOfLongestSubstring("pwwkew") == 3
func stringLengthOfLongestSubstring(s: String) -> Int {
    var result = 0
    var left = 0
    var right = 0
    var map = [Character: Int]()
    while right < s.count {
        if map[s[right]] != nil {
            left = max(left, map[s[right]]! + 1)
        }
        map[s[right]] = right
        result = max(result, right - left + 1)
        right += 1
    }
    return result
}

// 5. Given a string, find the length of the longest substring without repeating characters.
// stringLengthOfLongestSubstring("abcabcbb") == 3
// stringLengthOfLongestSubstring("bbbbb") == 1
// stringLengthOfLongestSubstring("pwwkew") == 3
func stringLengthOfLongestSubstring(s: String) -> Int {
    var result = 0
    var left = 0
    var right = 0
    var map = [Character: Int]()
    while right < s.count {
        if map[s[right]] != nil {
            left = max(left, map[s[right]]! + 1)
        }
        map[s[right]] = right
        result = max(result, right - left + 1)
        right += 1
    }
    return result
}

// 6. Given a string, find the length of the longest substring without repeating characters.
// stringLengthOfLongestSubstring("abcabcbb") == 3
// stringLengthOfLongestSubstring("bbbbb") == 1
// stringLengthOf
if a[i] == "1" && b[i] == "1" { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if a[i] == "1" && b[i] == "1" { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
} else if a[i] == "0" && b[i] == "0" { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
} else if a[i] == "0" && b[i] == "0" { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if map[s[right]] != nil { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
left = max(left, map[s[right]]! + 1) // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
map[s[right]] = right // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.

func stringXor(a: String, b: String) -> String {
    var result = ""
    for i in 0..<a.count {
        if a[i] == "1" && b[i] == "1" {
            result += "0"
        } else if a[i] == "0" && b[i] == "0" {
            result += "0"
        } else {
            result += "1"
        }
    }
    return result
}

func stringReverse(s: String) -> String {
    var result = ""
    for i in s.count-1..<0 {
        result += s[i]
    }
    return result
}

func stringCapitalize(s: String) -> String {
    var result = ""
    result += s[0].capitalized
    for i in 1..<s.count {
        result += s[i].lowercased
    }
    return result
}

func stringLowercase(s: String) -> String {
    var result = ""
    for i in s.count {
        result += s[i].lowercased
    }
    return result
}

func stringUppercase(s: String) -> String {
    var result = ""
    for i in s.count {
        result += s[i].uppercased
    }
    return result
}

func stringTitle(s: String) -> String {
    var result = ""
    for i in s.count {
        result += s[i].capitalized
    }
    return result
}

func stringLowercaseTitle(s: String) -> String {
    var result = ""
    for i in s.count {
        result += s[i].capitalized
    }
    return result
}

func stringUppercaseTitle(s: String) -> String {
    var result = ""
    for i in s.count {
        result += s[i].capitalized
    }
    return result
}
```swift
// Input are two strings a and b consisting only of 1s and 0s.
// Perform binary XOR on these inputs and return result also as a string.
// stringXor(a: "010", b: "110") == "100"
func stringXor(a: String, b: String) -> String {
    var result = ""
    for i in 0..<a.count {
        if a[i] == "1" && b[i] == "1" {
            result += "0"
        } else if a[i] == "0" && b[i] == "0" {
            result += "0"
        } else {
            result += "1"
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 11. Write a function that takes a string as input and returns the string reversed.
// stringReverse("hello") == "olleh"
func stringReverse(s: String) -> String {
    var result = ""
    for i in s.count-1..<0 {
        result += s[i]
    }
    return result
}

// -----------------------------------------------------------------------------
// 12. Write a function that takes a string as input and returns the string with the first letter capitalized and the rest lowercase.
// stringCapitalize("hello") == "Hello"
func stringCapitalize(s: String) -> String {
    var result = ""
    result += s[0].capitalized
    for i in 1..<s.count {
        result += s[i].lowercased
    }
    return result
}

// -----------------------------------------------------------------------------
// 13. Write a function that takes a string as input and returns the string with all the letters converted to lowercase.
// stringLowercase("Hello") == "hello"
func stringLowercase(s: String) -> String {
    var result = ""
    for i in s.count {
        result += s[i].lowercased
    }
    return result
}

// -----------------------------------------------------------------------------
// 14. Write a function that takes a string as input and returns the string with all the letters converted to uppercase.
// stringUppercase("hello") == "HELLO"
func stringUppercase(s: String) -> String {
    var result = ""
    for i in s.count {
        result += s[i].uppercased
    }
    return result
}

// -----------------------------------------------------------------------------
// 15. Write a function that takes a string as input and returns the string with all the letters converted to title case.
// stringTitle("hello") == "Hello"
func stringTitle(s: String) -> String {
    var result = ""
    for i in s.count {
        result += s[i].capitalized
    }
    return result
}

// -----------------------------------------------------------------------------
// 16. Write a function that takes a string as input and returns the string with all the letters converted to lowercase and title case.
// stringLowercaseTitle("Hello") == "Hello"
func stringLowercaseTitle(s: String) -> String {
    var result = ""
    for i in s.count {
        result += s[i].capitalized
    }
    return result
}

// -----------------------------------------------------------------------------
// 17. Write a function that takes a string as input and returns the string with all the letters converted to uppercase and title case.
// stringUppercaseTitle("hello") == "Hello"
func stringUppercaseTitle(s: String) -> String {
    var result = ""
    for i in s.count {
        result += s[i].capitalized
    }
    return result
}

// -----------------------------------------------------------------------------
// 1
if a[i] == "1" && b[i] == "1" { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if a[i] == "1" && b[i] == "1" { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
} else if a[i] == "0" && b[i] == "0" { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
} else if a[i] == "0" && b[i] == "0" { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
result += s[i] // no exact matches in call to subscript
result += s[0].capitalized // no exact matches in call to subscript
result += s[i].lowercased // function produces expected type 'String'; did you mean to call it with '()'?
for i in s.count { // for-in loop requires 'Int' to conform to 'Sequence'
for i in s.count { // for-in loop requires 'Int' to conform to 'Sequence'
for i in s.count { // for-in loop requires 'Int' to conform to 'Sequence'
for i in s.count { // for-in loop requires 'Int' to conform to 'Sequence'
for i in s.count { // for-in loop requires 'Int' to conform to 'Sequence'

func stringXor(a: String, b: String) -> String {
    let result = ""
    for i in 0..<a.count {
        if a[i] == b[i] {
            result += "0"
        } else {
            result += "1"
        }
    }
    return result
}

func firstUniqChar(s: String) -> Int {
    var result = 0
    var count = [Int](repeating: 0, count: 26)
    for i in 0..<s.count {
        count[s[i].asciiValue - 97] += 1
    }
    for i in 0..<s.count {
        if count[s[i].asciiValue - 97] == 1 {
            result = i
            break
        }
    }
    return result
}

func longestPalindrome(s: String) -> String {
    var result = ""
    for i in 0..<s.count {
        for j in i..<s.count {
            var temp = ""
            for k in i..<j {
                temp += s[k]
            }
            if temp == String(temp.reversed()) {
                if temp.count > result.count {
                    result = temp
                }
            }
        }
    }
    return result
}
```swift
// Input are two strings a and b consisting only of 1s and 0s.
// Perform binary XOR on these inputs and return result also as a string.
// stringXor(a: "010", b: "110") == "100"
func stringXor(a: String, b: String) -> String {
    let result = ""
    for i in 0..<a.count {
        if a[i] == b[i] {
            result += "0"
        } else {
            result += "1"
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// Task 2.
// Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.
// s = "leetcode" return 0.
// s = "loveleetcode" return 2.
func firstUniqChar(s: String) -> Int {
    var result = 0
    var count = [Int](repeating: 0, count: 26)
    for i in 0..<s.count {
        count[s[i].asciiValue - 97] += 1
    }
    for i in 0..<s.count {
        if count[s[i].asciiValue - 97] == 1 {
            result = i
            break
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// Task 3.
// Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.
// Example 1:
// Input: "babad"
// Output: "bab"
// Note: "aba" is also a valid answer.
// Example 2:
// Input: "cbbd"
// Output: "bb"
func longestPalindrome(s: String) -> String {
    var result = ""
    for i in 0..<s.count {
        for j in i..<s.count {
            var temp = ""
            for k in i..<j {
                temp += s[k]
            }
            if temp == String(temp.reversed()) {
                if temp.count > result.count {
                    result = temp
                }
            }
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// Task 4.
// Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.
// Example 1:
// Input: "babad"
// Output: "bab"
// Note: "aba" is also a valid answer.
// Example 2:
// Input: "cbbd"
// Output: "bb"
func longestPalindrome(s: String) -> String {
    var result = ""
    for i in 0..<s.count {
        for j in i..<s.count {
            var temp = ""
            for k in i..<j {
                temp += s[k]
            }
            if temp == String(temp.reversed()) {
                if temp.count > result.count {
                    result = temp
                }
            }
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// Task 5.
// Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.
// Example 1:
// Input: "babad"
// Output: "bab"
// Note: "aba" is also a valid answer.
// Example 2:
// Input: "cbbd"
// Output: "bb"
func longestPalindrome(s: String) -> String {
    var result = ""
    for i in 0..<s.count {
        for j in
if a[i] == b[i] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if a[i] == b[i] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
result += "0" // left side of mutating operator isn't mutable: 'result' is a 'let' constant
result += "1" // left side of mutating operator isn't mutable: 'result' is a 'let' constant
count[s[i].asciiValue - 97] += 1 // cannot convert value of type 'UInt8?' to expected argument type 'Int'
if count[s[i].asciiValue - 97] == 1 { // cannot convert value of type 'UInt8?' to expected argument type 'Int'
temp += s[k] // no exact matches in call to subscript

func stringXor(a: String, b: String) -> String {
    let result = ""
    for i in 0..<a.count {
        if a[i] == b[i] {
            result += "0"
        } else {
            result += "1"
        }
    }
    return result
}

func stringSum(input: String) -> Int {
    var result = 0
    var currentNumber = ""
    for char in input {
        if char.isDigit {
            currentNumber += char
        } else {
            if currentNumber != "" {
                result += Int(currentNumber)
                currentNumber = ""
            }
        }
    }
    if currentNumber != "" {
        result += Int(currentNumber)
    }
    return result
}

func stringBits(input: String) -> String {
    var result = ""
    for i in 0..<input.count {
        if i % 2 == 0 {
            result += input[i]
        }
    }
    return result
}

func stringSplosion(a: String, b: String) -> String {
    var result = ""
    for i in 0..<a.count {
        result += a[0..<i+1]
    }
    for i in 0..<b.count {
        result += b[0..<i+1]
    }
    return result
}

func last2(input: String) -> Int {
    var result = 0
    for i in 0..<input.count - 2 {
        if input[i..<i+2] == input[input.count - 2..<input.count - 1] {
            result += 1
        }
    }
    return result
}

func arrayCount9(input: [Int]) -> Int {
    var result = 0
    for i in input {
        if i == 9 {
            result += 1
        }
    }
    return result
}
```swift
// Input are two strings a and b consisting only of 1s and 0s.
// Perform binary XOR on these inputs and return result also as a string.
// stringXor(a: "010", b: "110") == "100"
func stringXor(a: String, b: String) -> String {
    let result = ""
    for i in 0..<a.count {
        if a[i] == b[i] {
            result += "0"
        } else {
            result += "1"
        }
    }
    return result
}

// 2. Given a string, return the sum of the numbers appearing in the string, ignoring all other characters. A number is a series of 1 or more digit chars in a row. (Note: Character.isDigit(char) tests if a char is one of the chars '0', '1', .. '9').
// stringSum("abc123xyz") == 123
func stringSum(input: String) -> Int {
    var result = 0
    var currentNumber = ""
    for char in input {
        if char.isDigit {
            currentNumber += char
        } else {
            if currentNumber != "" {
                result += Int(currentNumber)
                currentNumber = ""
            }
        }
    }
    if currentNumber != "" {
        result += Int(currentNumber)
    }
    return result
}

// 3. Given a string, return a new string made of every other char starting with the first, so "Hello" yields "Hlo".
// stringBits("Hello") == "Hlo"
func stringBits(input: String) -> String {
    var result = ""
    for i in 0..<input.count {
        if i % 2 == 0 {
            result += input[i]
        }
    }
    return result
}

// 4. Given two strings, a and b, return the result of putting them together in the order abba, e.g. "Hi" and "Bye" returns "HiByeByeHi".
// stringSplosion("Code", "Rocks") == "CCoCodCodeRocRocRocksrccodocodoc"
func stringSplosion(a: String, b: String) -> String {
    var result = ""
    for i in 0..<a.count {
        result += a[0..<i+1]
    }
    for i in 0..<b.count {
        result += b[0..<i+1]
    }
    return result
}

// 5. Given a string, return the count of the number of times that a substring length 2 appears in the string and also as the last 2 chars of the string, so "hixxxhi" yields 1 (we won't count the end substring).
// last2("hixxhi") == 1
func last2(input: String) -> Int {
    var result = 0
    for i in 0..<input.count - 2 {
        if input[i..<i+2] == input[input.count - 2..<input.count - 1] {
            result += 1
        }
    }
    return result
}

// 6. Given an array of ints, return the number of 9's in the array.
// arrayCount9([1, 2, 9]) == 1
// arrayCount9([1, 9, 9]) == 2
// arrayCount9([1, 9, 9, 3, 9]) == 3
func arrayCount9(input: [Int]) -> Int {
    var result = 0
    for i in input {
        if i == 9 {
            result += 1
        }
    }
    return result
}

// 7. Given an array of ints, return true if one of the first 4 elements in the array is a 9. The array length may be less than 4.
// arrayFront9([1, 2, 9, 3, 4]) == true
// arrayFront9([1, 2, 3, 4, 9]) == false
// arrayFront9([1, 2, 3, 4, 5]) == false
func arrayFront9(input: [Int]) -> Bool {
    for i in 0..<input.count {
        if input[i] == 9 {
            return true
        
if a[i] == b[i] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if a[i] == b[i] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
result += "0" // left side of mutating operator isn't mutable: 'result' is a 'let' constant
result += "1" // left side of mutating operator isn't mutable: 'result' is a 'let' constant
if char.isDigit { // value of type 'Character' has no member 'isDigit'
currentNumber += char // cannot convert value of type 'Character' to expected argument type 'String'
result += Int(currentNumber) // value of optional type 'Int?' must be unwrapped to a value of type 'Int'
result += Int(currentNumber) // value of optional type 'Int?' must be unwrapped to a value of type 'Int'
result += input[i] // no exact matches in call to subscript
result += a[0..<i+1] // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.
result += b[0..<i+1] // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.
if input[i..<i+2] == input[input.count - 2..<input.count - 1] { // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.
if input[i..<i+2] == input[input.count - 2..<input.count - 1] { // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.

func stringXor(a: String, b: String) -> String {
    let result = ""
    for i in 0..<a.count {
        if a[i] == b[i] {
            result += "0"
        } else {
            result += "1"
        }
    }
    return result
}

func stringReverse(s: String) -> String {
    return String(s.reversed())
}

func stringCapitalize(s: String) -> String {
    var result = ""
    for i in 0..<s.count {
        if s[i] == " " {
            result += " "
        } else {
            result += String(s[i].uppercased())
        }
    }
    return result
}

func stringRemoveVowels(s: String) -> String {
    var result = ""
    for i in 0..<s.count {
        if s[i] != "a" && s[i] != "e" && s[i] != "i" && s[i] != "o" && s[i] != "u" {
            result += s[i]
        }
    }
    return result
}

func stringRemoveSpaces(s: String) -> String {
    var result = ""
    for i in 0..<s.count {
        if s[i] != " " {
            result += s[i]
        }
    }
    return result
}

func stringReverseLetters(s: String) -> String {
    var result = ""
    for i in 0..<s.count {
        result = s[i] + result
    }
    return result
}

func stringAlphabetPosition(s: String) -> String {
    var result = ""
    for i in 0..<s.count {
        if s[i] == " " {
            result += " "
        } else {
            result += String(s[i].asciiValue - 96)
        }
    }
    return result
}

func stringRemoveLetters(s: String) -> String {
    var result = ""
    for i in 0..<s.count {
        if s[i] != "a" && s[i] != "e" && s[i] != "i" && s[i] != "o" && s[i] != "u" {
            result += s[i]
        }
    }
    return result
}
```swift
// Input are two strings a and b consisting only of 1s and 0s.
// Perform binary XOR on these inputs and return result also as a string.
// stringXor(a: "010", b: "110") == "100"
func stringXor(a: String, b: String) -> String {
    let result = ""
    for i in 0..<a.count {
        if a[i] == b[i] {
            result += "0"
        } else {
            result += "1"
        }
    }
    return result
}

// 2. Write a function that takes a string as input and returns the string reversed.
// stringReverse("hello") == "olleh"
func stringReverse(s: String) -> String {
    return String(s.reversed())
}

// 3. Write a function that takes a string as input and returns the string with the first character of each word capitalized.
// stringCapitalize("hello world") == "Hello World"
func stringCapitalize(s: String) -> String {
    var result = ""
    for i in 0..<s.count {
        if s[i] == " " {
            result += " "
        } else {
            result += String(s[i].uppercased())
        }
    }
    return result
}

// 4. Write a function that takes a string as input and returns the string with all the vowels removed.
// stringRemoveVowels("hello world") == "hll wrld"
func stringRemoveVowels(s: String) -> String {
    var result = ""
    for i in 0..<s.count {
        if s[i] != "a" && s[i] != "e" && s[i] != "i" && s[i] != "o" && s[i] != "u" {
            result += s[i]
        }
    }
    return result
}

// 5. Write a function that takes a string as input and returns the string with all the spaces removed.
// stringRemoveSpaces("hello world") == "helloworld"
func stringRemoveSpaces(s: String) -> String {
    var result = ""
    for i in 0..<s.count {
        if s[i] != " " {
            result += s[i]
        }
    }
    return result
}

// 6. Write a function that takes a string as input and returns the string with all the letters reversed.
// stringReverseLetters("hello world") == "dlrow olleh"
func stringReverseLetters(s: String) -> String {
    var result = ""
    for i in 0..<s.count {
        result = s[i] + result
    }
    return result
}

// 7. Write a function that takes a string as input and returns the string with all the letters replaced by their positions in the alphabet.
// stringAlphabetPosition("hello world") == "20 8 5 19 21 14 19 5 20 19 5 20 19 1 20 20 23 5 12 22 5 15 3 12"
func stringAlphabetPosition(s: String) -> String {
    var result = ""
    for i in 0..<s.count {
        if s[i] == " " {
            result += " "
        } else {
            result += String(s[i].asciiValue - 96)
        }
    }
    return result
}

// 8. Write a function that takes a string as input and returns the string with all the letters removed.
// stringRemoveLetters("hello world") == "hll wrld"
func stringRemoveLetters(s: String) -> String {
    var result = ""
    for i in 0..<s.count {
        if s[i] != "a" && s[i] != "e" && s[i] != "i" && s[i] != "o" && s[i] != "u" {
            result += s[i]
        }
    }
    return result
}

// 9. Write a function that takes a string as input and returns the string with all the letters replaced by their positions in the alphabet.
// stringAlphabetPositionLetters("hello
if a[i] == b[i] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if a[i] == b[i] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
result += "0" // left side of mutating operator isn't mutable: 'result' is a 'let' constant
result += "1" // left side of mutating operator isn't mutable: 'result' is a 'let' constant
if s[i] == " " { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
result += String(s[i].uppercased()) // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] != "a" && s[i] != "e" && s[i] != "i" && s[i] != "o" && s[i] != "u" { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] != "a" && s[i] != "e" && s[i] != "i" && s[i] != "o" && s[i] != "u" { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] != "a" && s[i] != "e" && s[i] != "i" && s[i] != "o" && s[i] != "u" { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] != "a" && s[i] != "e" && s[i] != "i" && s[i] != "o" && s[i] != "u" { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] != "a" && s[i] != "e" && s[i] != "i" && s[i] != "o" && s[i] != "u" { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
result += s[i] // no exact matches in call to subscript
if s[i] != " " { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
result += s[i] // no exact matches in call to subscript
result = s[i] + result // no exact matches in call to subscript
if s[i] == " " { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
result += String(s[i].asciiValue - 96) // value of optional type 'UInt8?' must be unwrapped to a value of type 'UInt8'
if s[i] != "a" && s[i] != "e" && s[i] != "i" && s[i] != "o" && s[i] != "u" { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] != "a" && s[i] != "e" && s[i] != "i" && s[i] != "o" && s[i] != "u" { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] != "a" && s[i] != "e" && s[i] != "i" && s[i] != "o" && s[i] != "u" { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] != "a" && s[i] != "e" && s[i] != "i" && s[i] != "o" && s[i] != "u" { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] != "a" && s[i] != "e" && s[i] != "i" && s[i] != "o" && s[i] != "u" { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
result += s[i] // no exact matches in call to subscript

func longest(strings: [String]) -> String? {
    if strings.isEmpty {
        return nil
    }
    var longest = strings[0]
    for string in strings {
        if string.length > longest.length {
            longest = string
        }
    }
    return longest
}
```swift
// Out of array of strings, return the longest one. Return the first one in case of multiple
// strings of the same length. Return nil in case the input array is empty.
// longest(strings: [] as [String]) == nil
// longest(strings: ["a", "b", "c"]) == "a"
// longest(strings: ["a", "bb", "ccc"]) == "ccc"
func longest(strings: [String]) -> String? {
    if strings.isEmpty {
        return nil
    }
    var longest = strings[0]
    for string in strings {
        if string.length > longest.length {
            longest = string
        }
    }
    return longest
}

// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------

//
if string.length > longest.length { // value of type 'String' has no member 'length'
if string.length > longest.length { // value of type 'String' has no member 'length'

func longest(strings: [String]) -> String? {
    if strings.isEmpty {
        return nil
    }
    return strings.reduce(strings[0], { (longest, next) in
        if longest.length < next.length {
            return next
        } else {
            return longest
        }
    })
}
```swift
// Out of array of strings, return the longest one. Return the first one in case of multiple
// strings of the same length. Return nil in case the input array is empty.
// longest(strings: [] as [String]) == nil
// longest(strings: ["a", "b", "c"]) == "a"
// longest(strings: ["a", "bb", "ccc"]) == "ccc"
func longest(strings: [String]) -> String? {
    if strings.isEmpty {
        return nil
    }
    return strings.reduce(strings[0], { (longest, next) in
        if longest.length < next.length {
            return next
        } else {
            return longest
        }
    })
}

// -------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------------
// ------------------------------
if longest.length < next.length { // value of type 'String' has no member 'length'
if longest.length < next.length { // value of type 'String' has no member 'length'

func longest(strings: [String]) -> String? {
    if strings.isEmpty {
        return nil
    }
    return strings.reduce(strings[0], { (longest, string) in
        return longest.length > string.length ? longest : string
    })
}
```swift
// Out of array of strings, return the longest one. Return the first one in case of multiple
// strings of the same length. Return nil in case the input array is empty.
// longest(strings: [] as [String]) == nil
// longest(strings: ["a", "b", "c"]) == "a"
// longest(strings: ["a", "bb", "ccc"]) == "ccc"
func longest(strings: [String]) -> String? {
    if strings.isEmpty {
        return nil
    }
    return strings.reduce(strings[0], { (longest, string) in
        return longest.length > string.length ? longest : string
    })
}

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// 1. Write a function that takes a string as input and returns the string reversed.
// Example:
// Given s = "hello", return "olleh".

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ---------
return longest.length > string.length ? longest : string // value of type 'String' has no member 'length'
return longest.length > string.length ? longest : string // value of type 'String' has no member 'length'

func longest(strings: [String]) -> String? {
    if strings.count == 0 {
        return nil
    }
    var longest = strings[0]
    for string in strings {
        if string.length > longest.length {
            longest = string
        }
    }
    return longest
}

func sum(numbers: [Int]) -> Int {
    var sum = 0
    for number in numbers {
        sum += number
    }
    return sum
}

func average(numbers: [Int]) -> Double {
    return Double(sum(numbers: numbers)) / Double(numbers.count)
}

func min(numbers: [Int]) -> Int {
    var min = numbers[0]
    for number in numbers {
        if number < min {
            min = number
        }
    }
    return min
}

func max(numbers: [Int]) -> Int {
    var max = numbers[0]
    for number in numbers {
        if number > max {
            max = number
        }
    }
    return max
}

func range(numbers: [Int]) -> Int {
    return max(numbers: numbers) - min(numbers: numbers)
}
```swift
// Out of array of strings, return the longest one. Return the first one in case of multiple
// strings of the same length. Return nil in case the input array is empty.
// longest(strings: [] as [String]) == nil
// longest(strings: ["a", "b", "c"]) == "a"
// longest(strings: ["a", "bb", "ccc"]) == "ccc"
func longest(strings: [String]) -> String? {
    if strings.count == 0 {
        return nil
    }
    var longest = strings[0]
    for string in strings {
        if string.length > longest.length {
            longest = string
        }
    }
    return longest
}

// ------------------------------------------------------------------------------------------------
// 2. Write a function that takes an array of numbers and returns the sum of all the numbers.
// sum([1, 2, 3]) == 6
// sum([1, 2, 3, 4]) == 10
// sum([1, 2, 3, 4, 5]) == 15
func sum(numbers: [Int]) -> Int {
    var sum = 0
    for number in numbers {
        sum += number
    }
    return sum
}

// ------------------------------------------------------------------------------------------------
// 3. Write a function that takes an array of numbers and returns the average of all the numbers.
// average([1, 2, 3]) == 2
// average([1, 2, 3, 4]) == 2.5
// average([1, 2, 3, 4, 5]) == 3
func average(numbers: [Int]) -> Double {
    return Double(sum(numbers: numbers)) / Double(numbers.count)
}

// ------------------------------------------------------------------------------------------------
// 4. Write a function that takes an array of numbers and returns the minimum number.
// min([1, 2, 3]) == 1
// min([1, 2, 3, 4]) == 1
// min([1, 2, 3, 4, 5]) == 1
func min(numbers: [Int]) -> Int {
    var min = numbers[0]
    for number in numbers {
        if number < min {
            min = number
        }
    }
    return min
}

// ------------------------------------------------------------------------------------------------
// 5. Write a function that takes an array of numbers and returns the maximum number.
// max([1, 2, 3]) == 3
// max([1, 2, 3, 4]) == 4
// max([1, 2, 3, 4, 5]) == 5
func max(numbers: [Int]) -> Int {
    var max = numbers[0]
    for number in numbers {
        if number > max {
            max = number
        }
    }
    return max
}

// ------------------------------------------------------------------------------------------------
// 6. Write a function that takes an array of numbers and returns the range of the numbers.
// range([1, 2, 3]) == 2
// range([1, 2, 3, 4]) == 3
// range([1, 2, 3, 4, 5]) == 4
func range(numbers: [Int]) -> Int {
    return max(numbers: numbers) - min(numbers: numbers)
}

// ------------------------------------------------------------------------------------------------
// 7. Write a function that takes an array of numbers and returns the median number.
// median([1, 2, 3]) == 2
// median([1, 2, 3, 4]) == 2.5
// median([1, 2, 3, 4, 5]) == 3
func median(numbers: [Int]) -> Int {
    var sortedNumbers = numbers
    sortedNumbers.sort()
    var middle = sortedNumbers.count / 2
    if sortedNumbers.count % 2 == 0 {
        return (sortedNumbers[middle - 1] + sortedNumbers[middle]) / 2
if string.length > longest.length { // value of type 'String' has no member 'length'
if string.length > longest.length { // value of type 'String' has no member 'length'

func longest(strings: [String]) -> String? {
    if strings.isEmpty {
        return nil
    }
    return strings.reduce(strings[0], { (l, r) -> String in
        return l.length > r.length ? l : r
    })
}
```swift
// Out of array of strings, return the longest one. Return the first one in case of multiple
// strings of the same length. Return nil in case the input array is empty.
// longest(strings: [] as [String]) == nil
// longest(strings: ["a", "b", "c"]) == "a"
// longest(strings: ["a", "bb", "ccc"]) == "ccc"
func longest(strings: [String]) -> String? {
    if strings.isEmpty {
        return nil
    }
    return strings.reduce(strings[0], { (l, r) -> String in
        return l.length > r.length ? l : r
    })
}

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------
// ---------------------------------
return l.length > r.length ? l : r // value of type 'String' has no member 'length'
return l.length > r.length ? l : r // value of type 'String' has no member 'length'

func longest(strings: [String]) -> String? {
    if strings.isEmpty {
        return nil
    }
    var maxLength = 0
    var maxLengthString: String? = nil
    for string in strings {
        if string.count > maxLength {
            maxLength = string.count
            maxLengthString = string
        }
    }
    return maxLengthString
}

func sum(integers: [Int]) -> Int {
    return integers.reduce(0, \(sum, integer) { sum + integer })
}

func sumOfEvens(integers: [Int]) -> Int {
    return integers.reduce(0, \(sum, integer) { sum + (integer % 2 == 0 ? integer : 0) })
}

func sumOfOdds(integers: [Int]) -> Int {
    return integers.reduce(0, \(sum, integer) { sum + (integer % 2 != 0 ? integer : 0) })
}

func sumOfGreaterThanFive(integers: [Int]) -> Int {
    return integers.reduce(0, \(sum, integer) { sum + (integer > 5 ? integer : 0) })
}

func sumOfLessThanFive(integers: [Int]) -> Int {
    return integers.reduce(0, \(sum, integer) { sum + (integer < 5 ? integer : 0) })
}
```swift
// Out of array of strings, return the longest one. Return the first one in case of multiple
// strings of the same length. Return nil in case the input array is empty.
// longest(strings: [] as [String]) == nil
// longest(strings: ["a", "b", "c"]) == "a"
// longest(strings: ["a", "bb", "ccc"]) == "ccc"
func longest(strings: [String]) -> String? {
    if strings.isEmpty {
        return nil
    }
    var maxLength = 0
    var maxLengthString: String? = nil
    for string in strings {
        if string.count > maxLength {
            maxLength = string.count
            maxLengthString = string
        }
    }
    return maxLengthString
}

// ------------------------------------------------------------------------------------------------
// 1.1.2
// Given an array of integers, return the sum of all the integers.
// sum(integers: []) == 0
// sum(integers: [1, 2, 3]) == 6
func sum(integers: [Int]) -> Int {
    return integers.reduce(0, \(sum, integer) { sum + integer })
}

// ------------------------------------------------------------------------------------------------
// 1.1.3
// Given an array of integers, return the sum of all the even integers.
// sumOfEvens(integers: []) == 0
// sumOfEvens(integers: [1, 2, 3]) == 2
// sumOfEvens(integers: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 30
func sumOfEvens(integers: [Int]) -> Int {
    return integers.reduce(0, \(sum, integer) { sum + (integer % 2 == 0 ? integer : 0) })
}

// ------------------------------------------------------------------------------------------------
// 1.1.4
// Given an array of integers, return the sum of all the odd integers.
// sumOfOdds(integers: []) == 0
// sumOfOdds(integers: [1, 2, 3]) == 4
// sumOfOdds(integers: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 25
func sumOfOdds(integers: [Int]) -> Int {
    return integers.reduce(0, \(sum, integer) { sum + (integer % 2 != 0 ? integer : 0) })
}

// ------------------------------------------------------------------------------------------------
// 1.1.5
// Given an array of integers, return the sum of all the integers that are greater than 5.
// sumOfGreaterThanFive(integers: []) == 0
// sumOfGreaterThanFive(integers: [1, 2, 3]) == 0
// sumOfGreaterThanFive(integers: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 30
func sumOfGreaterThanFive(integers: [Int]) -> Int {
    return integers.reduce(0, \(sum, integer) { sum + (integer > 5 ? integer : 0) })
}

// ------------------------------------------------------------------------------------------------
// 1.1.6
// Given an array of integers, return the sum of all the integers that are less than 5.
// sumOfLessThanFive(integers: []) == 0
// sumOfLessThanFive(integers: [1, 2, 3]) == 0
// sumOfLessThanFive(integers: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 15
func sumOfLessThanFive(integers: [Int]) -> Int {
    return integers.reduce(0, \(sum, integer) { sum + (integer < 5 ? integer : 0) })
}

// ---------------
return integers.reduce(0, \(sum, integer) { sum + integer }) // expected ',' separator
return integers.reduce(0, \(sum, integer) { sum + integer }) // extra argument in call
return integers.reduce(0, \(sum, integer) { sum + integer }) // cannot find 'integer' in scope
return integers.reduce(0, \(sum, integer) { sum + integer }) // string interpolation can only appear inside a string literal
return integers.reduce(0, \(sum, integer) { sum + integer }) // cannot find 'integer' in scope
return integers.reduce(0, \(sum, integer) { sum + integer }) // cannot convert value of type 'WritableKeyPath<_, _>' to expected argument type '(Int, Int) throws -> Int'
return integers.reduce(0, \(sum, integer) { sum + (integer % 2 == 0 ? integer : 0) }) // cannot find 'integer' in scope
return integers.reduce(0, \(sum, integer) { sum + (integer % 2 == 0 ? integer : 0) }) // cannot find 'integer' in scope
return integers.reduce(0, \(sum, integer) { sum + (integer % 2 == 0 ? integer : 0) }) // cannot convert value of type 'WritableKeyPath<_, _>' to expected argument type '(Int, Int) throws -> Int'
return integers.reduce(0, \(sum, integer) { sum + (integer % 2 == 0 ? integer : 0) }) // extra argument in call
return integers.reduce(0, \(sum, integer) { sum + (integer % 2 == 0 ? integer : 0) }) // string interpolation can only appear inside a string literal
return integers.reduce(0, \(sum, integer) { sum + (integer % 2 == 0 ? integer : 0) }) // cannot find 'integer' in scope
return integers.reduce(0, \(sum, integer) { sum + (integer % 2 == 0 ? integer : 0) }) // cannot convert value of type '([Int]) -> Int' to expected argument type 'Int'
return integers.reduce(0, \(sum, integer) { sum + (integer % 2 == 0 ? integer : 0) }) // expected ',' separator
return integers.reduce(0, \(sum, integer) { sum + (integer % 2 != 0 ? integer : 0) }) // cannot convert value of type 'WritableKeyPath<_, _>' to expected argument type '(Int, Int) throws -> Int'
return integers.reduce(0, \(sum, integer) { sum + (integer % 2 != 0 ? integer : 0) }) // expected ',' separator
return integers.reduce(0, \(sum, integer) { sum + (integer % 2 != 0 ? integer : 0) }) // cannot convert value of type '([Int]) -> Int' to expected argument type 'Int'
return integers.reduce(0, \(sum, integer) { sum + (integer % 2 != 0 ? integer : 0) }) // cannot find 'integer' in scope
return integers.reduce(0, \(sum, integer) { sum + (integer % 2 != 0 ? integer : 0) }) // cannot find 'integer' in scope
return integers.reduce(0, \(sum, integer) { sum + (integer % 2 != 0 ? integer : 0) }) // string interpolation can only appear inside a string literal
return integers.reduce(0, \(sum, integer) { sum + (integer % 2 != 0 ? integer : 0) }) // extra argument in call
return integers.reduce(0, \(sum, integer) { sum + (integer % 2 != 0 ? integer : 0) }) // cannot find 'integer' in scope
return integers.reduce(0, \(sum, integer) { sum + (integer > 5 ? integer : 0) }) // string interpolation can only appear inside a string literal
return integers.reduce(0, \(sum, integer) { sum + (integer > 5 ? integer : 0) }) // expected ',' separator
return integers.reduce(0, \(sum, integer) { sum + (integer > 5 ? integer : 0) }) // cannot convert value of type '([Int]) -> Int' to expected argument type 'Int'
return integers.reduce(0, \(sum, integer) { sum + (integer > 5 ? integer : 0) }) // cannot find 'integer' in scope
return integers.reduce(0, \(sum, integer) { sum + (integer > 5 ? integer : 0) }) // cannot convert value of type 'WritableKeyPath<_, _>' to expected argument type '(Int, Int) throws -> Int'
return integers.reduce(0, \(sum, integer) { sum + (integer > 5 ? integer : 0) }) // cannot find 'integer' in scope
return integers.reduce(0, \(sum, integer) { sum + (integer > 5 ? integer : 0) }) // extra argument in call
return integers.reduce(0, \(sum, integer) { sum + (integer > 5 ? integer : 0) }) // cannot find 'integer' in scope
return integers.reduce(0, \(sum, integer) { sum + (integer < 5 ? integer : 0) }) // cannot find 'integer' in scope
return integers.reduce(0, \(sum, integer) { sum + (integer < 5 ? integer : 0) }) // cannot find 'integer' in scope
return integers.reduce(0, \(sum, integer) { sum + (integer < 5 ? integer : 0) }) // extra argument in call
return integers.reduce(0, \(sum, integer) { sum + (integer < 5 ? integer : 0) }) // string interpolation can only appear inside a string literal
return integers.reduce(0, \(sum, integer) { sum + (integer < 5 ? integer : 0) }) // expected ',' separator
return integers.reduce(0, \(sum, integer) { sum + (integer < 5 ? integer : 0) }) // cannot find 'integer' in scope
return integers.reduce(0, \(sum, integer) { sum + (integer < 5 ? integer : 0) }) // cannot convert value of type 'WritableKeyPath<_, _>' to expected argument type '(Int, Int) throws -> Int'
return integers.reduce(0, \(sum, integer) { sum + (integer < 5 ? integer : 0) }) // cannot convert value of type '([Int]) -> Int' to expected argument type 'Int'

func longest(strings: [String]) -> String? {
    if strings.count == 0 {
        return nil
    }
    var longest = strings[0]
    for string in strings {
        if string.length > longest.length {
            longest = string
        }
    }
    return longest
}

func reverseString(string: String) -> String {
    return string.reversed().join()
}

func firstUniqChar(s: String) -> Int {
    var dict = [String: Int]()
    for i in 0..<s.length {
        if dict[s[i]] == nil {
            dict[s[i]] = 1
        } else {
            dict[s[i]]! += 1
        }
    }
    for i in 0..<s.length {
        if dict[s[i]] == 1 {
            return i
        }
    }
    return -1
}

func countElements(nums: [Int]) -> Int {
    var count = 0
    for i in 0..<nums.count {
        for j in 0..<nums.count {
            if i != j && nums[i] > nums[j] && nums[i] < nums[j] {
                count += 1
            }
        }
    }
    return count
}
```swift
// Out of array of strings, return the longest one. Return the first one in case of multiple
// strings of the same length. Return nil in case the input array is empty.
// longest(strings: [] as [String]) == nil
// longest(strings: ["a", "b", "c"]) == "a"
// longest(strings: ["a", "bb", "ccc"]) == "ccc"
func longest(strings: [String]) -> String? {
    if strings.count == 0 {
        return nil
    }
    var longest = strings[0]
    for string in strings {
        if string.length > longest.length {
            longest = string
        }
    }
    return longest
}

// ------------------------------------------------------------------------------------------------

// 1. Write a function that takes a string as input and returns the string reversed.
// reverseString("hello") == "olleh"
// reverseString("") == ""
// reverseString("a") == "a"
func reverseString(string: String) -> String {
    return string.reversed().join()
}

// ------------------------------------------------------------------------------------------------

// 2. Given a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1.
// firstUniqChar("leetcode") == 0
// firstUniqChar("loveleetcode") == 2
// firstUniqChar("") == -1
func firstUniqChar(s: String) -> Int {
    var dict = [String: Int]()
    for i in 0..<s.length {
        if dict[s[i]] == nil {
            dict[s[i]] = 1
        } else {
            dict[s[i]]! += 1
        }
    }
    for i in 0..<s.length {
        if dict[s[i]] == 1 {
            return i
        }
    }
    return -1
}

// ------------------------------------------------------------------------------------------------

// 3. Given an integer array nums, return the number of elements that have both a strictly smaller
// and a strictly greater element appear in nums.
// countElements(nums: [11,7,2,15]) == 2
// countElements(nums: [-3,3,3,90]) == 2
// countElements(nums: [29,6,10]) == 2
func countElements(nums: [Int]) -> Int {
    var count = 0
    for i in 0..<nums.count {
        for j in 0..<nums.count {
            if i != j && nums[i] > nums[j] && nums[i] < nums[j] {
                count += 1
            }
        }
    }
    return count
}

// ------------------------------------------------------------------------------------------------

// 4. Given an integer array nums, return the number of elements that have both a strictly
// smaller and a strictly greater element appear in nums.
// countElements(nums: [11,7,2,15]) == 2
// countElements(nums: [-3,3,3,90]) == 2
// countElements(nums: [29,6,10]) == 2
func countElements(nums: [Int]) -> Int {
    var count = 0
    for i in 0..<nums.count {
        for j in 0..<nums.count {
            if i != j && nums[i] > nums[j] && nums[i] < nums[j] {
                count += 1
            }
        }
    }
    return count
}

// ------------------------------------------------------------------------------------------------

// 5. Given an integer array nums, return the number of elements that have both a strictly
// smaller and a strictly greater element appear in nums.
// countElements(nums: [11,7,2,15]) == 2
// countElements(nums: [-3,3
if string.length > longest.length { // value of type 'String' has no member 'length'
if string.length > longest.length { // value of type 'String' has no member 'length'
return string.reversed().join() // reference to member 'join' cannot be resolved without a contextual type
for i in 0..<s.length { // value of type 'String' has no member 'length'
for i in 0..<s.length { // value of type 'String' has no member 'length'

func longest(strings: [String]) -> String? {
    return strings.max(by: { $0.length })
}
```swift
// Out of array of strings, return the longest one. Return the first one in case of multiple
// strings of the same length. Return nil in case the input array is empty.
// longest(strings: [] as [String]) == nil
// longest(strings: ["a", "b", "c"]) == "a"
// longest(strings: ["a", "bb", "ccc"]) == "ccc"
func longest(strings: [String]) -> String? {
    return strings.max(by: { $0.length })
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
return strings.max(by: { $0.length }) // contextual closure type '(String, String) throws -> Bool' expects 2 arguments, but 1 was used in closure body
return strings.max(by: { $0.length }) // value of type 'String' has no member 'length'

func longest(strings: [String]) -> String? {
    return strings.max { $0.length < $1.length }
}

func sum(numbers: [Int]) -> Int {
    return numbers.reduce(0, \(sum, number) { sum + number })
}

func sumOdd(numbers: [Int]) -> Int {
    return numbers.filter { $0 % 2 == 1 }.reduce(0, \(sum, number) { sum + number })
}

func sumEven(numbers: [Int]) -> Int {
    return numbers.filter { $0 % 2 == 0 }.reduce(0, \(sum, number) { sum + number })
}

func sumOddGreaterThan5(numbers: [Int]) -> Int {
    return numbers.filter { $0 % 2 == 1 && $0 > 5 }.reduce(0, \(sum, number) { sum + number })
}

func sumEvenGreaterThan5(numbers: [Int]) -> Int {
    return numbers.filter { $0 % 2 == 0 && $0 > 5 }.reduce(0, \(sum, number) { sum + number })
}

func sumEvenLessThan10(numbers: [Int]) -> Int {
    return numbers.filter { $0 % 2 == 0 && $0 < 10 }.reduce(0, \(sum, number) { sum + number })
}
```swift
// Out of array of strings, return the longest one. Return the first one in case of multiple
// strings of the same length. Return nil in case the input array is empty.
// longest(strings: [] as [String]) == nil
// longest(strings: ["a", "b", "c"]) == "a"
// longest(strings: ["a", "bb", "ccc"]) == "ccc"
func longest(strings: [String]) -> String? {
    return strings.max { $0.length < $1.length }
}

// ------------------------------------------------------------------------------------------------
// 1.1.2
// Given an array of integers, return the sum of all the integers.
// sum(numbers: []) == 0
// sum(numbers: [1, 2, 3]) == 6
func sum(numbers: [Int]) -> Int {
    return numbers.reduce(0, \(sum, number) { sum + number })
}

// ------------------------------------------------------------------------------------------------
// 1.1.3
// Given an array of integers, return the sum of all the integers that are odd.
// sumOdd(numbers: []) == 0
// sumOdd(numbers: [1, 2, 3]) == 4
func sumOdd(numbers: [Int]) -> Int {
    return numbers.filter { $0 % 2 == 1 }.reduce(0, \(sum, number) { sum + number })
}

// ------------------------------------------------------------------------------------------------
// 1.1.4
// Given an array of integers, return the sum of all the integers that are even.
// sumEven(numbers: []) == 0
// sumEven(numbers: [1, 2, 3]) == 4
func sumEven(numbers: [Int]) -> Int {
    return numbers.filter { $0 % 2 == 0 }.reduce(0, \(sum, number) { sum + number })
}

// ------------------------------------------------------------------------------------------------
// 1.1.5
// Given an array of integers, return the sum of all the integers that are odd and greater than 5.
// sumOddGreaterThan5(numbers: []) == 0
// sumOddGreaterThan5(numbers: [1, 2, 3]) == 0
// sumOddGreaterThan5(numbers: [6, 7, 8]) == 12
func sumOddGreaterThan5(numbers: [Int]) -> Int {
    return numbers.filter { $0 % 2 == 1 && $0 > 5 }.reduce(0, \(sum, number) { sum + number })
}

// ------------------------------------------------------------------------------------------------
// 1.1.6
// Given an array of integers, return the sum of all the integers that are even and greater than 5.
// sumEvenGreaterThan5(numbers: []) == 0
// sumEvenGreaterThan5(numbers: [1, 2, 3]) == 0
// sumEvenGreaterThan5(numbers: [6, 7, 8]) == 12
func sumEvenGreaterThan5(numbers: [Int]) -> Int {
    return numbers.filter { $0 % 2 == 0 && $0 > 5 }.reduce(0, \(sum, number) { sum + number })
}

// ------------------------------------------------------------------------------------------------
// 1.1.7
// Given an array of integers, return the sum of all the integers that are even and less than 10.
// sumEvenLessThan10(numbers: []) == 0
// sumEvenLessThan10(numbers: [1, 2, 3]) == 2
// sumEvenLessThan10(numbers: [6, 7, 8]) == 12
func sumEvenLessThan10(numbers: [Int]) -> Int {
    return numbers.filter { $0 % 2 == 0 && $0 < 10 }.reduce(0, \(sum, number) { sum + number })
}

// ---------------------------------
return strings.max { $0.length < $1.length } // value of type 'String' has no member 'length'
return strings.max { $0.length < $1.length } // value of type 'String' has no member 'length'
return numbers.reduce(0, \(sum, number) { sum + number }) // expected ',' separator
return numbers.reduce(0, \(sum, number) { sum + number }) // string interpolation can only appear inside a string literal
return numbers.reduce(0, \(sum, number) { sum + number }) // cannot find 'number' in scope
return numbers.reduce(0, \(sum, number) { sum + number }) // cannot find 'number' in scope
return numbers.reduce(0, \(sum, number) { sum + number }) // cannot convert value of type 'WritableKeyPath<_, _>' to expected argument type '(Int, Int) throws -> Int'
return numbers.reduce(0, \(sum, number) { sum + number }) // extra argument in call
return numbers.filter { $0 % 2 == 1 }.reduce(0, \(sum, number) { sum + number }) // cannot find 'number' in scope
return numbers.filter { $0 % 2 == 1 }.reduce(0, \(sum, number) { sum + number }) // cannot find 'number' in scope
return numbers.filter { $0 % 2 == 1 }.reduce(0, \(sum, number) { sum + number }) // cannot convert value of type 'WritableKeyPath<_, _>' to expected argument type '(Int, Int) throws -> Int'
return numbers.filter { $0 % 2 == 1 }.reduce(0, \(sum, number) { sum + number }) // extra argument in call
return numbers.filter { $0 % 2 == 1 }.reduce(0, \(sum, number) { sum + number }) // string interpolation can only appear inside a string literal
return numbers.filter { $0 % 2 == 1 }.reduce(0, \(sum, number) { sum + number }) // expected ',' separator
return numbers.filter { $0 % 2 == 0 }.reduce(0, \(sum, number) { sum + number }) // expected ',' separator
return numbers.filter { $0 % 2 == 0 }.reduce(0, \(sum, number) { sum + number }) // cannot find 'number' in scope
return numbers.filter { $0 % 2 == 0 }.reduce(0, \(sum, number) { sum + number }) // cannot convert value of type 'WritableKeyPath<_, _>' to expected argument type '(Int, Int) throws -> Int'
return numbers.filter { $0 % 2 == 0 }.reduce(0, \(sum, number) { sum + number }) // extra argument in call
return numbers.filter { $0 % 2 == 0 }.reduce(0, \(sum, number) { sum + number }) // cannot find 'number' in scope
return numbers.filter { $0 % 2 == 0 }.reduce(0, \(sum, number) { sum + number }) // string interpolation can only appear inside a string literal
return numbers.filter { $0 % 2 == 1 && $0 > 5 }.reduce(0, \(sum, number) { sum + number }) // expected ',' separator
return numbers.filter { $0 % 2 == 1 && $0 > 5 }.reduce(0, \(sum, number) { sum + number }) // extra argument in call
return numbers.filter { $0 % 2 == 1 && $0 > 5 }.reduce(0, \(sum, number) { sum + number }) // cannot find 'number' in scope
return numbers.filter { $0 % 2 == 1 && $0 > 5 }.reduce(0, \(sum, number) { sum + number }) // cannot convert value of type 'WritableKeyPath<_, _>' to expected argument type '(Int, Int) throws -> Int'
return numbers.filter { $0 % 2 == 1 && $0 > 5 }.reduce(0, \(sum, number) { sum + number }) // string interpolation can only appear inside a string literal
return numbers.filter { $0 % 2 == 1 && $0 > 5 }.reduce(0, \(sum, number) { sum + number }) // cannot find 'number' in scope
return numbers.filter { $0 % 2 == 0 && $0 > 5 }.reduce(0, \(sum, number) { sum + number }) // expected ',' separator
return numbers.filter { $0 % 2 == 0 && $0 > 5 }.reduce(0, \(sum, number) { sum + number }) // extra argument in call
return numbers.filter { $0 % 2 == 0 && $0 > 5 }.reduce(0, \(sum, number) { sum + number }) // cannot convert value of type 'WritableKeyPath<_, _>' to expected argument type '(Int, Int) throws -> Int'
return numbers.filter { $0 % 2 == 0 && $0 > 5 }.reduce(0, \(sum, number) { sum + number }) // cannot find 'number' in scope
return numbers.filter { $0 % 2 == 0 && $0 > 5 }.reduce(0, \(sum, number) { sum + number }) // cannot find 'number' in scope
return numbers.filter { $0 % 2 == 0 && $0 > 5 }.reduce(0, \(sum, number) { sum + number }) // string interpolation can only appear inside a string literal
return numbers.filter { $0 % 2 == 0 && $0 < 10 }.reduce(0, \(sum, number) { sum + number }) // expected ',' separator
return numbers.filter { $0 % 2 == 0 && $0 < 10 }.reduce(0, \(sum, number) { sum + number }) // cannot find 'number' in scope
return numbers.filter { $0 % 2 == 0 && $0 < 10 }.reduce(0, \(sum, number) { sum + number }) // string interpolation can only appear inside a string literal
return numbers.filter { $0 % 2 == 0 && $0 < 10 }.reduce(0, \(sum, number) { sum + number }) // cannot find 'number' in scope
return numbers.filter { $0 % 2 == 0 && $0 < 10 }.reduce(0, \(sum, number) { sum + number }) // cannot convert value of type 'WritableKeyPath<_, _>' to expected argument type '(Int, Int) throws -> Int'
return numbers.filter { $0 % 2 == 0 && $0 < 10 }.reduce(0, \(sum, number) { sum + number }) // extra argument in call

func longest(strings: [String]) -> String? {
    return strings.first(where: { $0.count > 0 })
}
```swift
// Out of array of strings, return the longest one. Return the first one in case of multiple
// strings of the same length. Return nil in case the input array is empty.
// longest(strings: [] as [String]) == nil
// longest(strings: ["a", "b", "c"]) == "a"
// longest(strings: ["a", "bb", "ccc"]) == "ccc"
func longest(strings: [String]) -> String? {
    return strings.first(where: { $0.count > 0 })
}

// -------------------------------------------------------------------------------------------------

// Given a string, return a new string that has transformed based on the input:
// Change case of every character, ie. lower case to upper case, upper case to lower case.
// Reverse the order of words from the input.
// Note: You will have to handle multiple spaces, and leading/trailing spaces.
// Note: You will have to handle multiple spaces, and leading/trailing spaces.
// Note: This is a slightly different version of the "fix string" exercise from the strings section.
// fixString("Example") == "eXAMPLe"
// fixString("Example string") == "eXAMPLe STRING"
// fixString("Example string!") == "eXAMPLe STRING!"
// fixString("Example string!@") == "eXAMPLe STRING!@"
// fixString("") == ""

// -------------------------------------------------------------------------------------------------

// Given a string, return the boolean true if the string is a palindrome.
// A palindrome is a word or sentence that's spelled the same forwards and backwards.
// Note: You should ignore punctuation, spaces, and capitalization.
// isPalindrome("a") == true
// isPalindrome("ab") == false
// isPalindrome("aba") == true
// isPalindrome("abba") == true
// isPalindrome("abab") == false
// isPalindrome("amanaplanacanalpanama") == true
// isPalindrome("amanaplanacanalpandemonium") == false

// -------------------------------------------------------------------------------------------------

// Given a string, return the boolean true if the string is a palindrome.
// A palindrome is a word or sentence that's spelled the same forwards and backwards.
// Note: You should ignore punctuation, spaces, and capitalization.
// isPalindrome("a") == true
// isPalindrome("ab") == false
// isPalindrome("aba") == true
// isPalindrome("abba") == true
// isPalindrome("abab") == false
// isPalindrome("amanaplanacanalpanama") == true
// isPalindrome("amanaplanacanalpandemonium") == false

// -------------------------------------------------------------------------------------------------

// Given a string, return the boolean true if the string is a palindrome.
// A palindrome is a word or sentence that's spelled the same forwards and backwards.
// Note: You should ignore punctuation, spaces, and capitalization.
// isPalindrome("a") == true
// isPalindrome("ab") == false
// isPalindrome("aba") == true
// isPalindrome("abba") == true
// isPalindrome("abab") == false
// isPalindrome("amanaplanacanalpanama") == true
// isPalindrome("amanaplanacanalpandemonium") == false

// -------------------------------------------------------------------------------------------------

// Given a string, return the boolean true if the string is a palindrome.
// A palindrome is a word or sentence that's spelled the same forwards and backwards.
// Note: You should ignore punctuation, spaces, and capitalization.
// isPalindrome("a") == true
// isPalindrome("ab") == false
// isPalindrome("aba") == true
// isPalindrome("abba") == true
// isPalindrome(
 // XCTAssertTrue failed

func greatestCommonDivisor(a: Int, b: Int) -> Int {
    while b != 0 {
        let temp = b
        b = a % b
        a = temp
    }
    return a
}
```swift
// Return a greatest common divisor of two integers a and b
// greatestCommonDivisor(a: 3, b: 5) == 1
// greatestCommonDivisor(a: 25, b: 15) == 5
func greatestCommonDivisor(a: Int, b: Int) -> Int {
    while b != 0 {
        let temp = b
        b = a % b
        a = temp
    }
    return a
}

// -----------------------------------------------------------------------------
// MARK: - 1.1.1.2
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: - 1.1.1.3
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: - 1.1.1.4
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: - 1.1.1.5
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: - 1.1.1.6
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: - 1.1.1.7
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: - 1.1.1.8
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: - 1.1.1.9
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: - 1.1.1.10
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: - 1.1.1.11
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: - 1.1.1.12
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: - 1.1.1.13
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: - 1.1.1.14
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// M
b = a % b // cannot assign to value: 'b' is a 'let' constant
a = temp // cannot assign to value: 'a' is a 'let' constant

func greatestCommonDivisor(a: Int, b: Int) -> Int {
    var result = 1
    for i in 1...min(a, b) {
        if a % i == 0 && b % i == 0 {
            result = i
        }
    }
    return result
}

func reverseString(string: String) -> String {
    var reversedString = ""
    for i in string.reversed() {
        reversedString += String(i)
    }
    return reversedString
}

func hammingWeight(n: Int) -> Int {
    var count = 0
    while n > 0 {
        if n & 1 == 1 {
            count += 1
        }
        n >>= 1
    }
    return count
}
```swift
// Return a greatest common divisor of two integers a and b
// greatestCommonDivisor(a: 3, b: 5) == 1
// greatestCommonDivisor(a: 25, b: 15) == 5
func greatestCommonDivisor(a: Int, b: Int) -> Int {
    var result = 1
    for i in 1...min(a, b) {
        if a % i == 0 && b % i == 0 {
            result = i
        }
    }
    return result
}

// 2. Write a function that takes a string as input and returns the string reversed.
// reverseString("hello") == "olleh"
func reverseString(string: String) -> String {
    var reversedString = ""
    for i in string.reversed() {
        reversedString += String(i)
    }
    return reversedString
}

// 3. Write a function that takes an integer and returns the number of 1 bits it has.
// hammingWeight(0b00000000000000000000000000001011) == 3
func hammingWeight(n: Int) -> Int {
    var count = 0
    while n > 0 {
        if n & 1 == 1 {
            count += 1
        }
        n >>= 1
    }
    return count
}

// 4. Write a function that takes an integer and returns the number of 1 bits it has.
// hammingWeight(0b00000000000000000000000000001011) == 3
func hammingWeight(n: Int) -> Int {
    var count = 0
    while n > 0 {
        if n & 1 == 1 {
            count += 1
        }
        n >>= 1
    }
    return count
}

// 5. Write a function that takes an integer and returns the number of 1 bits it has.
// hammingWeight(0b00000000000000000000000000001011) == 3
func hammingWeight(n: Int) -> Int {
    var count = 0
    while n > 0 {
        if n & 1 == 1 {
            count += 1
        }
        n >>= 1
    }
    return count
}

// 6. Write a function that takes an integer and returns the number of 1 bits it has.
// hammingWeight(0b00000000000000000000000000001011) == 3
func hammingWeight(n: Int) -> Int {
    var count = 0
    while n > 0 {
        if n & 1 == 1 {
            count += 1
        }
        n >>= 1
    }
    return count
}

// 7. Write a function that takes an integer and returns the number of 1 bits it has.
// hammingWeight(0b00000000000000000000000000001011) == 3
func hammingWeight(n: Int) -> Int {
    var count = 0
    while n > 0 {
        if n & 1 == 1 {
            count += 1
        }
        n >>= 1
    }
    return count
}

// 8. Write a function that takes an integer and returns the number of 1 bits it has.
// hammingWeight(0b00000000000000000000000000001011) == 3
func hammingWeight(n: Int) -> Int {
    var count = 0
    while n > 0 {
        if n & 1 == 1 {
            count += 1
        }
        n >>= 1
    }
    return count
}

// 9. Write a function that takes an integer and returns the number of 1 bits it has.
// hammingWeight(0b00000000000000000000000000001011) == 3
func hammingWeight(n: Int) -> Int {
    var count = 
n >>= 1 // left side of mutating operator isn't mutable: 'n' is a 'let' constant

func greatestCommonDivisor(a: Int, b: Int) -> Int {
    if a == 0 {
        return b
    }
    if b == 0 {
        return a
    }
    if a > b {
        return greatestCommonDivisor(a: a % b, b: b)
    }
    return greatestCommonDivisor(a: a, b: b % a)
}
```swift
// Return a greatest common divisor of two integers a and b
// greatestCommonDivisor(a: 3, b: 5) == 1
// greatestCommonDivisor(a: 25, b: 15) == 5
func greatestCommonDivisor(a: Int, b: Int) -> Int {
    if a == 0 {
        return b
    }
    if b == 0 {
        return a
    }
    if a > b {
        return greatestCommonDivisor(a: a % b, b: b)
    }
    return greatestCommonDivisor(a: a, b: b % a)
}

// -----------------------------------------------------------------------------
// 2. Write a function that takes a string as a parameter and returns a new string that
//    contains all the characters in the original string except the first and last
//    characters. The length of the returned string should be 1 less than the original
//    string's length. If the original string has fewer than 2 characters, the returned
//    string should be empty.
//
//    Example:
//
//    removeFirstLast("Hello") == "ell"
//    removeFirstLast("abcdefg") == "bcdef"
//    removeFirstLast("ab") == ""
//    removeFirstLast("a") == ""
//    removeFirstLast("") == ""
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 3. Write a function that takes a string as a parameter and returns a new string that
//    contains all the characters in the original string except the first and last
//    characters. The length of the returned string should be 1 less than the original
//    string's length. If the original string has fewer than 2 characters, the returned
//    string should be empty.
//
//    Example:
//
//    removeFirstLast("Hello") == "ell"
//    removeFirstLast("abcdefg") == "bcdef"
//    removeFirstLast("ab") == ""
//    removeFirstLast("a") == ""
//    removeFirstLast("") == ""
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 4. Write a function that takes a string as a parameter and returns a new string that
//    contains all the characters in the original string except the first and last
//    characters. The length of the returned string should be 1 less than the original
//    string's length. If the original string has fewer than 2 characters, the returned
//    string should be empty.
//
//    Example:
//
//    removeFirstLast("Hello") == "ell"
//    removeFirstLast("abcdefg") == "bcdef"
//    removeFirstLast("ab") == ""
//    removeFirstLast("a") == ""
//    removeFirstLast("") == ""
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 5. Write a function that takes a string as a parameter and returns a new string that
//    contains all the characters in the original string except the first and last
//    characters. The length of the returned string should be 1 less than the original
//    string's length. If the original string has fewer than 2 characters, the returned
//    string should be empty.
//
//    Example:
//
//    removeFirstLast("Hello") == "ell"
//    removeFirstLast("abcdefg") == "bcdef"
//    removeFirstLast("ab") == ""
//    removeFirstLast("a") == ""
//    removeFirstLast("") == ""
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 6

func greatestCommonDivisor(a: Int, b: Int) -> Int {
    var a = a
    var b = b
    while a != b {
        if a > b {
            a -= b
        } else {
            b -= a
        }
    }
    return a
}
```swift
// Return a greatest common divisor of two integers a and b
// greatestCommonDivisor(a: 3, b: 5) == 1
// greatestCommonDivisor(a: 25, b: 15) == 5
func greatestCommonDivisor(a: Int, b: Int) -> Int {
    var a = a
    var b = b
    while a != b {
        if a > b {
            a -= b
        } else {
            b -= a
        }
    }
    return a
}

// -----------------------------------------------------------------------------
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// MARK: -
// M

func greatestCommonDivisor(a: Int, b: Int) -> Int {
    var result = 1
    for i in 1...min(a, b) {
        if a % i == 0 && b % i == 0 {
            result = i
        }
    }
    return result
}
```swift
// Return a greatest common divisor of two integers a and b
// greatestCommonDivisor(a: 3, b: 5) == 1
// greatestCommonDivisor(a: 25, b: 15) == 5
func greatestCommonDivisor(a: Int, b: Int) -> Int {
    var result = 1
    for i in 1...min(a, b) {
        if a % i == 0 && b % i == 0 {
            result = i
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.2.10
// -----------------------------------------------------------------------------
// Return the greatest common divisor of two integers a and b
// greatestCommonDivisor(a: 3, b: 5) == 1
// greatestCommonDivisor(a: 25, b: 15) == 5
func greatestCommonDivisor(a: Int, b: Int) -> Int {
    var result = 1
    for i in 1...min(a, b) {
        if a % i == 0 && b % i == 0 {
            result = i
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.2.11
// -----------------------------------------------------------------------------
// Return the greatest common divisor of two integers a and b
// greatestCommonDivisor(a: 3, b: 5) == 1
// greatestCommonDivisor(a: 25, b: 15) == 5
func greatestCommonDivisor(a: Int, b: Int) -> Int {
    var result = 1
    for i in 1...min(a, b) {
        if a % i == 0 && b % i == 0 {
            result = i
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.2.12
// -----------------------------------------------------------------------------
// Return the greatest common divisor of two integers a and b
// greatestCommonDivisor(a: 3, b: 5) == 1
// greatestCommonDivisor(a: 25, b: 15) == 5
func greatestCommonDivisor(a: Int, b: Int) -> Int {
    var result = 1
    for i in 1...min(a, b) {
        if a % i == 0 && b % i == 0 {
            result = i
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.2.13
// -----------------------------------------------------------------------------
// Return the greatest common divisor of two integers a and b
// greatestCommonDivisor(a: 3, b: 5) == 1
// greatestCommonDivisor(a: 25, b: 15) == 5
func greatestCommonDivisor(a: Int, b: Int) -> Int {
    var result = 1
    for i in 1...min(a, b) {
        if a % i == 0 && b % i == 0 {
            result = i
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.2.14
// -----------------------------------------------------------------------------
// Return the greatest common divisor of two integers a and b
// greatestCommonDivisor(a: 3, b: 5) == 1
// greatestCommonDivisor(a: 25, b: 15) == 5
func greatestCommonDivisor(a: Int, b: Int) -> Int {
    var result = 1
    for i in 1...min(a, b) {
        if a %

func greatestCommonDivisor(a: Int, b: Int) -> Int {
    var a = a
    var b = b
    while a != b {
        if a > b {
            a -= b
        } else {
            b -= a
        }
    }
    return a
}
```swift
// Return a greatest common divisor of two integers a and b
// greatestCommonDivisor(a: 3, b: 5) == 1
// greatestCommonDivisor(a: 25, b: 15) == 5
func greatestCommonDivisor(a: Int, b: Int) -> Int {
    var a = a
    var b = b
    while a != b {
        if a > b {
            a -= b
        } else {
            b -= a
        }
    }
    return a
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// ---------------

func greatestCommonDivisor(a: Int, b: Int) -> Int {
    var a = a
    var b = b
    while a != b {
        if a > b {
            a -= b
        } else {
            b -= a
        }
    }
    return a
}
```swift
// Return a greatest common divisor of two integers a and b
// greatestCommonDivisor(a: 3, b: 5) == 1
// greatestCommonDivisor(a: 25, b: 15) == 5
func greatestCommonDivisor(a: Int, b: Int) -> Int {
    var a = a
    var b = b
    while a != b {
        if a > b {
            a -= b
        } else {
            b -= a
        }
    }
    return a
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ---------------------------------------------------------------

func greatestCommonDivisor(a: Int, b: Int) -> Int {
    let min = min(a, b)
    for i in (1...min) {
        if a % i == 0 && b % i == 0 {
            return i
        }
    }
    return 1
}
```swift
// Return a greatest common divisor of two integers a and b
// greatestCommonDivisor(a: 3, b: 5) == 1
// greatestCommonDivisor(a: 25, b: 15) == 5
func greatestCommonDivisor(a: Int, b: Int) -> Int {
    let min = min(a, b)
    for i in (1...min) {
        if a % i == 0 && b % i == 0 {
            return i
        }
    }
    return 1
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ------------------------------------------------------------------------
 // XCTAssertTrue failed

func greatestCommonDivisor(a: Int, b: Int) -> Int {
    var a = a
    var b = b
    while a != b {
        if a > b {
            a -= b
        } else {
            b -= a
        }
    }
    return a
}
```swift
// Return a greatest common divisor of two integers a and b
// greatestCommonDivisor(a: 3, b: 5) == 1
// greatestCommonDivisor(a: 25, b: 15) == 5
func greatestCommonDivisor(a: Int, b: Int) -> Int {
    var a = a
    var b = b
    while a != b {
        if a > b {
            a -= b
        } else {
            b -= a
        }
    }
    return a
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

func greatestCommonDivisor(a: Int, b: Int) -> Int {
    var a = a
    var b = b
    while a != b {
        if a > b {
            a -= b
        } else {
            b -= a
        }
    }
    return a
}
```swift
// Return a greatest common divisor of two integers a and b
// greatestCommonDivisor(a: 3, b: 5) == 1
// greatestCommonDivisor(a: 25, b: 15) == 5
func greatestCommonDivisor(a: Int, b: Int) -> Int {
    var a = a
    var b = b
    while a != b {
        if a > b {
            a -= b
        } else {
            b -= a
        }
    }
    return a
}

// -----------------------------------------------------------------------------
// MARK: -
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: -
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: -
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: -
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: -
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: -
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: -
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: -
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: -
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: -
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: -
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: -
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: -
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: -
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: -
// ------------------------------------------------------------

func allPrefixes(string: String) -> [String] {
    var prefixes = [String]()
    for i in 0..<string.count {
        prefixes.append(string[0..<i])
    }
    return prefixes
}
```swift
// Return array of all prefixes from shortest to longest of the input string
// allPrefixes(string: "abc") == ["a", "ab", "abc"]
func allPrefixes(string: String) -> [String] {
    var prefixes = [String]()
    for i in 0..<string.count {
        prefixes.append(string[0..<i])
    }
    return prefixes
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
prefixes.append(string[0..<i]) // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.

func allPrefixes(string: String) -> [String] {
    var prefixes = [String]()
    for i in 0..<string.count {
        prefixes.append(string[0..<i])
    }
    return prefixes
}
```swift
// Return array of all prefixes from shortest to longest of the input string
// allPrefixes(string: "abc") == ["a", "ab", "abc"]
func allPrefixes(string: String) -> [String] {
    var prefixes = [String]()
    for i in 0..<string.count {
        prefixes.append(string[0..<i])
    }
    return prefixes
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
prefixes.append(string[0..<i]) // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.

func allPrefixes(string: String) -> [String] {
    var prefixes = [string]
    for i in 1...string.count {
        prefixes.append(string[..<i])
    }
    return prefixes
}
```swift
// Return array of all prefixes from shortest to longest of the input string
// allPrefixes(string: "abc") == ["a", "ab", "abc"]
func allPrefixes(string: String) -> [String] {
    var prefixes = [string]
    for i in 1...string.count {
        prefixes.append(string[..<i])
    }
    return prefixes
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
prefixes.append(string[..<i]) // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.

func allPrefixes(string: String) -> [String] {
    var prefixes = [String()]
    for character in string {
        prefixes.append(prefixes.last! + character)
    }
    return prefixes
}
```swift
// Return array of all prefixes from shortest to longest of the input string
// allPrefixes(string: "abc") == ["a", "ab", "abc"]
func allPrefixes(string: String) -> [String] {
    var prefixes = [String()]
    for character in string {
        prefixes.append(prefixes.last! + character)
    }
    return prefixes
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
prefixes.append(prefixes.last! + character) // cannot convert value of type 'Character' to expected argument type 'String'

func allPrefixes(string: String) -> [String] {
    var prefixes = [String]()
    for i in 0..<string.count {
        prefixes.append(string[0..<i])
    }
    return prefixes
}
```swift
// Return array of all prefixes from shortest to longest of the input string
// allPrefixes(string: "abc") == ["a", "ab", "abc"]
func allPrefixes(string: String) -> [String] {
    var prefixes = [String]()
    for i in 0..<string.count {
        prefixes.append(string[0..<i])
    }
    return prefixes
}

// -----------------------------------------------------------------------------
// 1.2.2.3.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.
prefixes.append(string[0..<i]) // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.

func allPrefixes(string: String) -> [String] {
    var prefixes = [string]
    for i in 1..<string.count {
        prefixes.append(string[..<i])
    }
    return prefixes
}

func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

func isPalindrome(string: String) -> Bool {
    var reversed = ""
    for char in string {
        reversed = char + reversed
    }
    return string == reversed
}

func letterCounts(string: String) -> [String: Int] {
    var counts = [String: Int]()
    for char in string {
        if let count = counts[char] {
            counts[char] = count + 1
        } else {
            counts[char] = 1
        }
    }
    return counts
}

func letterCountsNoWhitespace(string: String) -> [String: Int] {
    var counts = [String: Int]()
    for char in string {
        if char.isLetter {
            if let count = counts[char] {
                counts[char] = count + 1
            } else {
                counts[char] = 1
            }
        }
    }
    return counts
}

func letterCountsNoWhitespaceOrPunctuation(string: String) -> [String: Int] {
    var counts = [String: Int]()
    for char in string {
        if char.isLetter || char.isNumber {
            if let count = counts[char] {
                counts[char] = count + 1
            } else {
                counts[char] = 1
            }
        }
    }
    return counts
}
```swift
// Return array of all prefixes from shortest to longest of the input string
// allPrefixes(string: "abc") == ["a", "ab", "abc"]
func allPrefixes(string: String) -> [String] {
    var prefixes = [string]
    for i in 1..<string.count {
        prefixes.append(string[..<i])
    }
    return prefixes
}

// 2. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels(string: "abcdefghijklmnopqrstuvwxyz") == "bcdfghjklmnpqrstvwxyz"
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// 3. Write a function that takes a string and returns true if the string is a palindrome, and false otherwise.
// isPalindrome(string: "racecar") == true
// isPalindrome(string: "hello") == false
func isPalindrome(string: String) -> Bool {
    var reversed = ""
    for char in string {
        reversed = char + reversed
    }
    return string == reversed
}

// 4. Write a function that takes a string and returns the number of times each letter appears in the string.
// letterCounts(string: "hello") == ["h": 1, "e": 1, "l": 2, "o": 1]
func letterCounts(string: String) -> [String: Int] {
    var counts = [String: Int]()
    for char in string {
        if let count = counts[char] {
            counts[char] = count + 1
        } else {
            counts[char] = 1
        }
    }
    return counts
}

// 5. Write a function that takes a string and returns the number of times each letter appears in the string, excluding whitespace.
// letterCountsNoWhitespace(string: "hello world") == ["h": 1, "e": 1, "l": 2, "o": 1, "w": 1, "r": 1, "d": 1]
func letterCountsNoWhitespace(string: String) -> [String: Int] {
    var counts = [String: Int]()
    for char in string {
        if char.isLetter {
            if let count = counts[char] {
                counts[char] = count + 1
            } else {
                counts[char] = 1
            }
        }
    }
    return counts
}

// 6. Write a function that takes a string and returns the number of times each letter appears in the string, excluding whitespace and punctuation.
// letterCountsNoWhitespaceOrPunctuation(string: "hello world!") == ["h": 1, "e": 1, "l": 2, "o": 1, "w": 1, "r": 1, "d": 1]
func letterCountsNoWhitespaceOrPunctuation(string: String) -> [String: Int] {
    var counts = [String: Int]()
    for char in string {
        if char.isLetter || char.isNumber {
            if let count = counts[char] {
                counts[char] = count + 1
            } else {
                counts[char] = 1
            }
        }
    }
    return counts
}

// 7. Write a function that takes a string and returns the number of times each letter appears in the string, excluding whitespace, punctuation, and numbers.
// letterCountsNoWhitespaceOrPunctuationOrNumbers(string: "hello world!") == ["h": 1, "e": 1, "l": 2, "o": 1, "w": 1, "r": 1, "d": 1]
func letterCountsNoWhitespaceOrPunctuationOrNumbers(string: String) -> [String: Int] {
    var counts = [String: Int]()
    for char in string {
        if char.isLetter || char.isNumber {
            if let count = counts[char] {
                counts[char] = count + 1
            } else {
                counts[char] = 1
            }
        }
    
prefixes.append(string[..<i]) // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.
if !isVowel(char) { // cannot find 'isVowel' in scope
result += char // cannot convert value of type 'Character' to expected argument type 'String'
reversed = char + reversed // cannot convert value of type 'Character' to expected argument type 'String'
if let count = counts[char] { // cannot convert value of type 'Character' to expected argument type 'String'
counts[char] = count + 1 // cannot convert value of type 'Character' to expected argument type 'String'
counts[char] = 1 // cannot convert value of type 'Character' to expected argument type 'String'
if let count = counts[char] { // cannot convert value of type 'Character' to expected argument type 'String'
counts[char] = count + 1 // cannot convert value of type 'Character' to expected argument type 'String'
counts[char] = 1 // cannot convert value of type 'Character' to expected argument type 'String'
if let count = counts[char] { // cannot convert value of type 'Character' to expected argument type 'String'
counts[char] = count + 1 // cannot convert value of type 'Character' to expected argument type 'String'
counts[char] = 1 // cannot convert value of type 'Character' to expected argument type 'String'

func allPrefixes(string: String) -> [String] {
    var prefixes = [string]
    for i in 1...string.count {
        prefixes.append(string[..<i])
    }
    return prefixes
}

func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char: char) {
            result += char
        }
    }
    return result
}

func countVowels(string: String) -> Int {
    var count = 0
    for char in string {
        if isVowel(char: char) {
            count += 1
        }
    }
    return count
}

func isPalindrome(string: String) -> Bool {
    var reversed = ""
    for char in string {
        reversed = char + reversed
    }
    return reversed == string
}

func countCharacters(string: String, character: Character) -> Int {
    var count = 0
    for char in string {
        if char == character {
            count += 1
        }
    }
    return count
}

func countCharacters(string: String) -> [Character: Int] {
    var result = [Character: Int]()
    for char in string {
        if result[char] == nil {
            result[char] = 1
        } else {
            result[char] += 1
        }
    }
    return result
}

func countCharacters(string: String) -> [Character: Int] {
    var result = [Character: Int]()
    for char in string {
        if char != " " {
            if result[char] == nil {
                result[char] = 1
            } else {
                result[char] += 1
            }
        }
    }
    return result
}
```swift
// Return array of all prefixes from shortest to longest of the input string
// allPrefixes(string: "abc") == ["a", "ab", "abc"]
func allPrefixes(string: String) -> [String] {
    var prefixes = [string]
    for i in 1...string.count {
        prefixes.append(string[..<i])
    }
    return prefixes
}

// 2. Write a function that takes a string and returns the string with all vowels removed.
// removeVowels(string: "abcdefghijklmnopqrstuvwxyz") == "bcdfghjklmnpqrstvwxyz"
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char: char) {
            result += char
        }
    }
    return result
}

// 3. Write a function that takes a string and returns the number of vowels in the string.
// countVowels(string: "abcdefghijklmnopqrstuvwxyz") == 5
func countVowels(string: String) -> Int {
    var count = 0
    for char in string {
        if isVowel(char: char) {
            count += 1
        }
    }
    return count
}

// 4. Write a function that takes a string and returns true if the string is a palindrome, false otherwise.
// isPalindrome(string: "racecar") == true
// isPalindrome(string: "hello") == false
func isPalindrome(string: String) -> Bool {
    var reversed = ""
    for char in string {
        reversed = char + reversed
    }
    return reversed == string
}

// 5. Write a function that takes a string and returns the number of times a specific character appears in the string.
// countCharacters(string: "apple", character: "p") == 2
// countCharacters(string: "banana", character: "n") == 3
func countCharacters(string: String, character: Character) -> Int {
    var count = 0
    for char in string {
        if char == character {
            count += 1
        }
    }
    return count
}

// 6. Write a function that takes a string and returns the number of times each character appears in the string.
// countCharacters(string: "apple") == ["a": 1, "p": 2, "l": 1, "e": 1]
// countCharacters(string: "banana") == ["b": 1, "a": 3, "n": 2]
func countCharacters(string: String) -> [Character: Int] {
    var result = [Character: Int]()
    for char in string {
        if result[char] == nil {
            result[char] = 1
        } else {
            result[char] += 1
        }
    }
    return result
}

// 7. Write a function that takes a string and returns the number of times each character appears in the string, excluding whitespace.
// countCharacters(string: "apple") == ["a": 1, "p": 2, "l": 1, "e": 1]
// countCharacters(string: "banana") == ["b": 1, "a": 3, "n": 2]
// countCharacters(string: "   apple   ") == ["a": 1, "p": 2, "l": 1, "e": 1]
func countCharacters(string: String) -> [Character: Int] {
    var result = [Character: Int]()
    for char in string {
        if char != " " {
            if result[char] == nil {
                result[char] = 1
            } else {
                result[char] += 1
            }
        }
    }
    return result
}

// 8. Write a function that takes a string and returns the number of times each character appears in the string, excluding whitespace and punctuation.
// countCharacters(string: "apple") == ["a": 1, "p": 2, "l": 1, "e": 1]
// countCharacters(string: "banana") == ["b": 1, "a": 3, "n": 
prefixes.append(string[..<i]) // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.
if !isVowel(char: char) { // cannot find 'isVowel' in scope
result += char // cannot convert value of type 'Character' to expected argument type 'String'
if isVowel(char: char) { // cannot find 'isVowel' in scope
reversed = char + reversed // cannot convert value of type 'Character' to expected argument type 'String'
result[char] += 1 // value of optional type 'Int?' must be unwrapped to a value of type 'Int'
func countCharacters(string: String) -> [Character: Int] { // invalid redeclaration of 'countCharacters(string:)'
result[char] += 1 // value of optional type 'Int?' must be unwrapped to a value of type 'Int'

func allPrefixes(string: String) -> [String] {
    var prefixes = [String()]
    for i in 0..<string.count {
        prefixes.append(string[0..<i])
    }
    return prefixes
}

func vowels(string: String) -> Int {
    var count = 0
    for char in string {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}

func palindrome(string: String) -> Bool {
    var reversed = String(string.reversed())
    return string == reversed
}

func countChar(string: String, char: String) -> Int {
    var count = 0
    for char in string {
        if char == char {
            count += 1
        }
    }
    return count
}
```swift
// Return array of all prefixes from shortest to longest of the input string
// allPrefixes(string: "abc") == ["a", "ab", "abc"]
func allPrefixes(string: String) -> [String] {
    var prefixes = [String()]
    for i in 0..<string.count {
        prefixes.append(string[0..<i])
    }
    return prefixes
}

// 2. Write a function that takes a string and returns the number of vowels in the string.
// vowels("aeiou") == 5
// vowels("bcdfghjklmnpqrstvwxyz") == 0
// vowels("") == 0
// vowels("aeiouAEIOU") == 10
func vowels(string: String) -> Int {
    var count = 0
    for char in string {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}

// 3. Write a function that takes a string and returns true if the string is a palindrome, and false otherwise.
// palindrome("abba") == true
// palindrome("abc") == false
// palindrome("") == true
// palindrome("abcdcba") == true
// palindrome("abcdefgfedcba") == true
// palindrome("abcdefgfedcbaa") == false
func palindrome(string: String) -> Bool {
    var reversed = String(string.reversed())
    return string == reversed
}

// 4. Write a function that takes a string and returns the number of times a specific character appears in the string.
// countChar("apple", "p") == 2
// countChar("apple", "z") == 0
// countChar("", "z") == 0
// countChar("apple", "") == 0
// countChar("apple", "a") == 2
// countChar("apple", "e") == 1
// countChar("apple", "l") == 2
// countChar("apple", "p") == 2
// countChar("apple", "z") == 0
func countChar(string: String, char: String) -> Int {
    var count = 0
    for char in string {
        if char == char {
            count += 1
        }
    }
    return count
}

// 5. Write a function that takes a string and returns the number of times each character appears in the string.
// countChars("apple") == ["a": 1, "p": 2, "l": 1, "e": 1]
// countChars("") == ["a": 0, "p": 0, "l": 0, "e": 0]
// countChars("appleapple") == ["a": 2, "p": 2, "l": 1, "e": 2]
// countChars("applepearple") == ["a": 2, "p": 3, "l": 1, "e": 2]
// countChars("applepearpleapple") == ["a": 2, "p": 3, "l": 1, "e": 2]
// countChars("applepearpleapplepearple") == ["a": 2, "p": 3, "l": 1, "e": 2]
// countChars("applepearpleapplepearpleapple") == ["a": 2, "p": 3, "l": 1, "e": 2]
// countChars("applepearpleapplepearpleapplepearple") == ["a": 2, "p": 3, "l": 1, "e": 2]
// countChars("applepearpleapplepearpleapplepearpleapple") == ["a": 2, "p": 3, "l": 1, "e": 2]
// countChars("applepearpleapplepearpleapplepearpleapplepearple") == ["a": 2, "p": 3, "l":
prefixes.append(string[0..<i]) // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.
var reversed = String(string.reversed()) // variable 'reversed' was never mutated; consider changing to 'let' constant

func allPrefixes(string: String) -> [String] {
    var prefixes = [string]
    for i in 1..<string.count {
        prefixes.append(string[..<i])
    }
    return prefixes
}

func reverseString(string: String) -> String {
    return string.reversed().join()
}

func countAs(string: String) -> Int {
    return string.count(character: "a")
}

func countAsExcludingVowels(string: String) -> Int {
    var count = 0
    for i in 0..<string.count {
        if string[i] == "a" {
            if isVowel(string: string[i..<i+1]) {
                continue
            }
            count += 1
        }
    }
    return count
}

func countAsExcludingVowelsAndConsonants(string: String) -> Int {
    var count = 0
    for i in 0..<string.count {
        if string[i] == "a" {
            if isVowel(string: string[i..<i+1]) {
                continue
            }
            if isConsonant(string: string[i..<i+1]) {
                continue
            }
            count += 1
        }
    }
    return count
}

func countAsExcludingVowelsAndConsonantsAndX(string: String) -> Int {
    var count = 0
    for i in 0..<string.count {
        if string[i] == "a" {
            if isVowel(string: string[i..<i+1]) {
                continue
            }
            if isConsonant(string: string[i..<i+1]) {
                continue
            }
            if isX(string: string[i..<i+1]) {
                continue
            }
            count += 1
        }
    }
    return count
}
```swift
// Return array of all prefixes from shortest to longest of the input string
// allPrefixes(string: "abc") == ["a", "ab", "abc"]
func allPrefixes(string: String) -> [String] {
    var prefixes = [string]
    for i in 1..<string.count {
        prefixes.append(string[..<i])
    }
    return prefixes
}

// -----------------------------------------------------------------------------
// 2. Write a function that takes a string and returns the string with all
//    characters reversed.
//
//    reverseString(string: "abc") == "cba"
func reverseString(string: String) -> String {
    return string.reversed().join()
}

// -----------------------------------------------------------------------------
// 3. Write a function that takes a string and returns the number of times
//    the letter "a" appears in it.
//
//    countAs(string: "apple") == 2
func countAs(string: String) -> Int {
    return string.count(character: "a")
}

// -----------------------------------------------------------------------------
// 4. Write a function that takes a string and returns the number of times
//    the letter "a" appears in it, excluding the ones immediately after vowels.
//
//    countAsExcludingVowels(string: "apple") == 1
func countAsExcludingVowels(string: String) -> Int {
    var count = 0
    for i in 0..<string.count {
        if string[i] == "a" {
            if isVowel(string: string[i..<i+1]) {
                continue
            }
            count += 1
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// 5. Write a function that takes a string and returns the number of times
//    the letter "a" appears in it, excluding the ones immediately after vowels,
//    and excluding the ones immediately before consonants.
//
//    countAsExcludingVowelsAndConsonants(string: "apple") == 0
func countAsExcludingVowelsAndConsonants(string: String) -> Int {
    var count = 0
    for i in 0..<string.count {
        if string[i] == "a" {
            if isVowel(string: string[i..<i+1]) {
                continue
            }
            if isConsonant(string: string[i..<i+1]) {
                continue
            }
            count += 1
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// 6. Write a function that takes a string and returns the number of times
//    the letter "a" appears in it, excluding the ones immediately after vowels,
//    and excluding the ones immediately before consonants, and excluding the
//    ones that are preceded by "x".
//
//    countAsExcludingVowelsAndConsonantsAndX(string: "apple") == 1
func countAsExcludingVowelsAndConsonantsAndX(string: String) -> Int {
    var count = 0
    for i in 0..<string.count {
        if string[i] == "a" {
            if isVowel(string: string[i..<i+1]) {
                continue
            }
            if isConsonant(string: string[i..<i+1]) {
                continue
            }
            if isX(string: string[i..<i+1]) {
                continue
            }
            count += 1
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// 7. Write a function that takes a string and returns the number of times
//    the letter "a" appears in it, excluding the ones immediately after vowels,
//    and excluding the ones immediately before conson
prefixes.append(string[..<i]) // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.
return string.reversed().join() // reference to member 'join' cannot be resolved without a contextual type
return string.count(character: "a") // cannot call value of non-function type 'Int'
if string[i] == "a" { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if isVowel(string: string[i..<i+1]) { // cannot find 'isVowel' in scope
if string[i] == "a" { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if isVowel(string: string[i..<i+1]) { // cannot find 'isVowel' in scope
if isConsonant(string: string[i..<i+1]) { // cannot find 'isConsonant' in scope
if string[i] == "a" { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if isVowel(string: string[i..<i+1]) { // cannot find 'isVowel' in scope
if isConsonant(string: string[i..<i+1]) { // cannot find 'isConsonant' in scope
if isX(string: string[i..<i+1]) { // cannot find 'isX' in scope

func allPrefixes(string: String) -> [String] {
    var prefixes = [string]
    for i in 1...string.count {
        prefixes.append(string[..<i])
    }
    return prefixes
}

func vowelCount(string: String) -> Int {
    var count = 0
    for char in string {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}

func isPalindrome(string: String) -> Bool {
    return string == string.reversed()
}

func countA(string: String) -> Int {
    var count = 0
    for char in string {
        if char == "a" {
            count += 1
        }
    }
    return count
}

func swapFirstLast(string: String) -> String {
    if string.count == 0 {
        return ""
    }
    return string.last + string[1..<string.count - 1] + string[0]
}
```swift
// Return array of all prefixes from shortest to longest of the input string
// allPrefixes(string: "abc") == ["a", "ab", "abc"]
func allPrefixes(string: String) -> [String] {
    var prefixes = [string]
    for i in 1...string.count {
        prefixes.append(string[..<i])
    }
    return prefixes
}

// 2. Write a function that takes a string and returns the number (count) of vowels contained within it.
// vowelCount(string: "aeiou") == 5
// vowelCount(string: "abcdefg") == 0
// vowelCount(string: "") == 0
func vowelCount(string: String) -> Int {
    var count = 0
    for char in string {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}

// 3. Write a function that takes a string and returns true if the string is a palindrome, and false if it is not.
// isPalindrome(string: "racecar") == true
// isPalindrome(string: "hello") == false
// isPalindrome(string: "") == true
func isPalindrome(string: String) -> Bool {
    return string == string.reversed()
}

// 4. Write a function that takes a string and returns the number (count) of times the character "a" appears in it.
// countA(string: "apple") == 1
// countA(string: "banana") == 2
// countA(string: "") == 0
func countA(string: String) -> Int {
    var count = 0
    for char in string {
        if char == "a" {
            count += 1
        }
    }
    return count
}

// 5. Write a function that takes a string and returns a new string with the first and last characters swapped.
// swapFirstLast(string: "apple") == "eplla"
// swapFirstLast(string: "banana") == "anaban"
// swapFirstLast(string: "") == ""
func swapFirstLast(string: String) -> String {
    if string.count == 0 {
        return ""
    }
    return string.last + string[1..<string.count - 1] + string[0]
}

// 6. Write a function that takes a string and returns true if the string is a palindrome, and false if it is not.
// isPalindrome(string: "racecar") == true
// isPalindrome(string: "hello") == false
// isPalindrome(string: "") == true
func isPalindrome(string: String) -> Bool {
    return string == string.reversed()
}

// 7. Write a function that takes a string and returns the number (count) of times the character "a" appears in it.
// countA(string: "apple") == 1
// countA(string: "banana") == 2
// countA(string: "") == 0
func countA(string: String) -> Int {
    var count = 0
    for char in string {
        if char == "a" {
            count += 1
        }
    }
    return count
}

// 8. Write a function that takes a string and returns a new string with the first and last characters swapped.
// swapFirstLast(string: "apple") == "eplla"
// swapFirstLast(string: "banana") == "anaban"
// swapFirstLast(string: "") == ""
func swapFirstLast(string: String) -> String {
    if string.count == 0 {
        return ""
    }
    return string.last + string[1..<string.count - 1] + string[0]
}

// 9. Write a function that takes a string and returns true if the string is a palindrome, and false if it is not.
// isPalindrome(string: "racecar") == true
// isPalindrome(string: "hello") == false
// isPalindrome(string: "") == true
func isPalindrome(string: String) -> Bool {
prefixes.append(string[..<i]) // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.
return string == string.reversed() // binary operator '==' cannot be applied to operands of type 'String' and '[String.Element]' (aka 'Array<Character>')
return string.last + string[1..<string.count - 1] + string[0] // cannot convert value of type 'Character' to expected argument type 'String'
return string.last + string[1..<string.count - 1] + string[0] // cannot convert value of type 'String.Element?' (aka 'Optional<Character>') to expected argument type 'String'

func stringSequence(n: Int) -> String {
    var result = ""
    for i in 0...n {
        result += "\(i) "
    }
    return result.trim()
}
```swift
// Return a string containing space-delimited numbers starting from 0 upto n inclusive.
// stringSequence(n: 0) == "0"
// stringSequence(n: 5) == "0 1 2 3 4 5"
func stringSequence(n: Int) -> String {
    var result = ""
    for i in 0...n {
        result += "\(i) "
    }
    return result.trim()
}

// -----------------------------------------------------------------------------
// 1. Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels("I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
// removeVowels("abracadabra") == "brcrdbrkr"
// removeVowels("") == ""
// removeVowels("a") == ""
// removeVowels("aeiou") == ""
// removeVowels("aeiouAEIOU") == ""
// removeVowels("bcdfghjklmnpqrstvwxz") == "bcdfghjklmnpqrstvwxz"
// removeVowels("bcdfghjklmnpqrstvwxzBcdfghjklmnpqrstvwxz") == "bcdfghjklmnpqrstvwxzBcdfghjklmnpqrstvwxz"
// removeVowels("bcdfghjklmnpqrstvwxzBcdfghjklmnpqrstvwxz")
// removeVowels("bcdfghjklmnpqrstvwxzBcdfghjklmnpqrstvwxz")
// removeVowels("bcdfghjklmnpqrstvwxzBcdfghjklmnpqrstvwxz")
// removeVowels("bcdfghjklmnpqrstvwxzBcdfghjklmnpqrstvwxz")
// removeVowels("bcdfghjklmnpqrstvwxzBcdfghjklmnpqrstvwxz")
// removeVowels("bcdfghjklmnpqrstvwxzBcdfghjklmnpqrstvwxz")
// removeVowels("bcdfghjklmnpqrstvwxzBcdfghjklmnpqrstvwxz")
// removeVowels("bcdfghjklmnpqrstvwxzBcdfghjklmnpqrstvwxz")
// removeVowels("bcdfghjklmnpqrstvwxzBcdfghjklmnpqrstvwxz")
// removeVowels("bcdfghjklmnpqrstvwxzBcdfghjklmnpqrstvwxz")
// removeVowels("bcdfghjklmnpqrstvwxzBcdfghjklmnpqrstvwxz")
// removeVowels("bcdfghjklmnpqrstvwxzBcdfghjklmnpqrstvwxz")
// removeVowels("bcdfghjklmnpqrstvwxzBcdfghjklmnpqrstvwxz")
// removeVowels("bcdfghjklmnpqrstvwxzBcdfghjklmnpqrstvwxz")
// removeVowels("bcdfghjklmnpqrstvwxzBcdfghjklmnpqrstvwxz")
// removeVowels("bcdfghjklmnpqrstvwxzBcdfghjklmnpqrstvwxz")
// removeVowels("bcdfghjklmnpqrstvwxzBcdfghjklmnpqrstvwxz")
// removeVowels("bcdfghjklmnpqrstvwxzBcdfghjklmnpqrstvwxz")
// removeVowels("bcdfghjklmnpqrstvwxzBcdfghjklmnpqrstvwxz")
// removeVowels("bcdfghjklmnpqrstvwxzBcdfghjklmnpqrstvwxz")
// removeVowels("bcdfghjklmnpqrstvwxzBcdfghj
return result.trim() // value of type 'String' has no member 'trim'

func stringSequence(n: Int) -> String {
    var result = ""
    for i in 0...n {
        result += "\(i) "
    }
    return result.trim()
}
```swift
// Return a string containing space-delimited numbers starting from 0 upto n inclusive.
// stringSequence(n: 0) == "0"
// stringSequence(n: 5) == "0 1 2 3 4 5"
func stringSequence(n: Int) -> String {
    var result = ""
    for i in 0...n {
        result += "\(i) "
    }
    return result.trim()
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 10. Write a function that takes a string as input and returns the string reversed.
// Example:
// Given s = "hello", return "olleh".

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 11. Write a function that takes an integer and returns the number of 1 bits it has.
// Example:
// The 32-bit integer 11 has binary representation
// 00000000000000000000000000001011
// so the function should return 3.

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 12. Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).
// Example:
// The 32-bit integer ’11' has binary representation
// 00000000000000000000000000001011
// so the function should return 3.

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 13. Write a function that takes an integer and returns the number of times the number 1 appears in all its decimal representation.
// Example:
// The 32-bit integer ’11' has binary representation
// 00000000000000000000000000001011
// so the function should return 3.

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 14. Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).
// Example:
// The 32-bit integer ’11' has binary representation
// 00000000000000000000000000001011
// so the function should return 3.

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 15. Write a function that takes an integer and returns the number of times the number 1 appears in all its decimal representation.
// Example:
// The 32-bit integer ’11' has binary representation
// 00000000000000000000000000001011
// so the function should return 3.

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 16. Write a function that takes an integer and returns the number of times the number 1 appears in all its decimal representation.
// Example:
// The 32-bit integer ’11' has binary representation
// 00000000000000000000000000001011
// so the function should return 3.

// ---------------------------------------------------------------------------------------
return result.trim() // value of type 'String' has no member 'trim'

func stringSequence(n: Int) -> String {
    var result = ""
    for i in 0..<n {
        result += "\(i) "
    }
    return result.trimEnd()
}

func reverseString(s: String) -> String {
    return String(s.reversed())
}
```swift
// Return a string containing space-delimited numbers starting from 0 upto n inclusive.
// stringSequence(n: 0) == "0"
// stringSequence(n: 5) == "0 1 2 3 4 5"
func stringSequence(n: Int) -> String {
    var result = ""
    for i in 0..<n {
        result += "\(i) "
    }
    return result.trimEnd()
}

// -----------------------------------------------------------------------------
// 10. Write a function that takes a string and returns a new string with all
//     characters in reverse order.
//     reverseString("hello") == "olleh"
//     reverseString("Howdy") == "ydwoH"
//     reverseString("Greetings from Earth") == "htraE morf sgniteerG"
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// -----------------------------------------------------------------------------
// 11. Write a function that takes a string and returns a new string with all
//     characters in reverse order.
//     reverseString("hello") == "olleh"
//     reverseString("Howdy") == "ydwoH"
//     reverseString("Greetings from Earth") == "htraE morf sgniteerG"
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// -----------------------------------------------------------------------------
// 12. Write a function that takes a string and returns a new string with all
//     characters in reverse order.
//     reverseString("hello") == "olleh"
//     reverseString("Howdy") == "ydwoH"
//     reverseString("Greetings from Earth") == "htraE morf sgniteerG"
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// -----------------------------------------------------------------------------
// 13. Write a function that takes a string and returns a new string with all
//     characters in reverse order.
//     reverseString("hello") == "olleh"
//     reverseString("Howdy") == "ydwoH"
//     reverseString("Greetings from Earth") == "htraE morf sgniteerG"
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// -----------------------------------------------------------------------------
// 14. Write a function that takes a string and returns a new string with all
//     characters in reverse order.
//     reverseString("hello") == "olleh"
//     reverseString("Howdy") == "ydwoH"
//     reverseString("Greetings from Earth") == "htraE morf sgniteerG"
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// -----------------------------------------------------------------------------
// 15. Write a function that takes a string and returns a new string with all
//     characters in reverse order.
//     reverseString("hello") == "olleh"
//     reverseString("Howdy") == "ydwoH"
//     reverseString("Greetings from Earth") == "htraE morf sgniteerG"
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// -----------------------------------------------------------------------------
// 16. Write a function that takes a string and returns a new string with all
//     characters in reverse order.
//     reverseString("hello") == "olleh"
//     reverseString("Howdy") == "ydwoH"
//     reverseString("Greetings from Earth") == "htraE morf sgniteerG"
func reverseString(s: String) -> String {
return result.trimEnd() // value of type 'String' has no member 'trimEnd'

func stringSequence(n: Int) -> String {
    var result = ""
    for i in 0..<n {
        result += "\(i) "
    }
    return result.trim()
}
```swift
// Return a string containing space-delimited numbers starting from 0 upto n inclusive.
// stringSequence(n: 0) == "0"
// stringSequence(n: 5) == "0 1 2 3 4 5"
func stringSequence(n: Int) -> String {
    var result = ""
    for i in 0..<n {
        result += "\(i) "
    }
    return result.trim()
}

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------
return result.trim() // value of type 'String' has no member 'trim'

func stringSequence(n: Int) -> String {
    var result = ""
    for i in 0..<n {
        result += "\(i) "
    }
    return result.trim()
}
```swift
// Return a string containing space-delimited numbers starting from 0 upto n inclusive.
// stringSequence(n: 0) == "0"
// stringSequence(n: 5) == "0 1 2 3 4 5"
func stringSequence(n: Int) -> String {
    var result = ""
    for i in 0..<n {
        result += "\(i) "
    }
    return result.trim()
}

// ----------------------------------------------------------------------------------------------------------------------

// 1. Write a function that takes a string as input and returns the string reversed.
// Example:
// Given s = "hello", return "olleh".

// ----------------------------------------------------------------------------------------------------------------------

// 1. Write a function that takes a string as input and returns the string reversed.
// Example:
// Given s = "hello", return "olleh".

// ----------------------------------------------------------------------------------------------------------------------

// 1. Write a function that takes a string as input and returns the string reversed.
// Example:
// Given s = "hello", return "olleh".

// ----------------------------------------------------------------------------------------------------------------------

// 1. Write a function that takes a string as input and returns the string reversed.
// Example:
// Given s = "hello", return "olleh".

// ----------------------------------------------------------------------------------------------------------------------

// 1. Write a function that takes a string as input and returns the string reversed.
// Example:
// Given s = "hello", return "olleh".

// ----------------------------------------------------------------------------------------------------------------------

// 1. Write a function that takes a string as input and returns the string reversed.
// Example:
// Given s = "hello", return "olleh".

// ----------------------------------------------------------------------------------------------------------------------

// 1. Write a function that takes a string as input and returns the string reversed.
// Example:
// Given s = "hello", return "olleh".

// ----------------------------------------------------------------------------------------------------------------------

// 1. Write a function that takes a string as input and returns the string reversed.
// Example:
// Given s = "hello", return "olleh".

// ----------------------------------------------------------------------------------------------------------------------

// 1. Write a function that takes a string as input and returns the string reversed.
// Example:
// Given s = "hello", return "olleh".

// ----------------------------------------------------------------------------------------------------------------------

// 1. Write a function that takes a string as input and returns the string reversed.
// Example:
// Given s = "hello", return "olleh".

// ----------------------------------------------------------------------------------------------------------------------

// 1. Write a function that takes a string as input and returns the string reversed.
// Example:
// Given s = "hello", return "olleh".

// ----------------------------------------------------------------------------------------------------------------------

// 
return result.trim() // value of type 'String' has no member 'trim'

func stringSequence(n: Int) -> String {
    var result = ""
    for i in 0..<n {
        result += "\(i) "
    }
    return result
}

func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}
```swift
// Return a string containing space-delimited numbers starting from 0 upto n inclusive.
// stringSequence(n: 0) == "0"
// stringSequence(n: 5) == "0 1 2 3 4 5"
func stringSequence(n: Int) -> String {
    var result = ""
    for i in 0..<n {
        result += "\(i) "
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 12. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
// removeVowels("abracadabra") == "brcrdbrkr"
// removeVowels("pear tree") == " pr t"
// removeVowels("hello world") == " hll wrd"
// removeVowels("cucumber") == " cmbtr"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 13. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
// removeVowels("abracadabra") == "brcrdbrkr"
// removeVowels("pear tree") == " pr t"
// removeVowels("hello world") == " hll wrd"
// removeVowels("cucumber") == " cmbtr"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 14. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
// removeVowels("abracadabra") == "brcrdbrkr"
// removeVowels("pear tree") == " pr t"
// removeVowels("hello world") == " hll wrd"
// removeVowels("cucumber") == " cmbtr"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 15. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
// removeVowels("abracadabra") == "brcrdbrkr"
// removeVowels
result += char // cannot convert value of type 'Character' to expected argument type 'String'

func stringSequence(n: Int) -> String {
    var result = ""
    for i in 0..<n {
        result += "\(i) "
    }
    return result.trimmingTrailingWhitespace()
}
```swift
// Return a string containing space-delimited numbers starting from 0 upto n inclusive.
// stringSequence(n: 0) == "0"
// stringSequence(n: 5) == "0 1 2 3 4 5"
func stringSequence(n: Int) -> String {
    var result = ""
    for i in 0..<n {
        result += "\(i) "
    }
    return result.trimmingTrailingWhitespace()
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// ---------------
return result.trimmingTrailingWhitespace() // value of type 'String' has no member 'trimmingTrailingWhitespace'

func stringSequence(n: Int) -> String {
    var result = ""
    for i in 0..<n {
        result += "\(i) "
    }
    return result
}

func stringDoubler(s: String) -> String {
    var result = ""
    for char in s {
        result += String(char) + String(char)
    }
    return result
}
```swift
// Return a string containing space-delimited numbers starting from 0 upto n inclusive.
// stringSequence(n: 0) == "0"
// stringSequence(n: 5) == "0 1 2 3 4 5"
func stringSequence(n: Int) -> String {
    var result = ""
    for i in 0..<n {
        result += "\(i) "
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// 1. Write a function that takes a string as an argument and returns a new string that contains the same letters in the same order, but with each letter repeated twice.
// stringDoubler("Hello") == "HHeelllloo"
// stringDoubler("Goodbye") == "GGoooodddbbYYbyyeeezzz"
func stringDoubler(s: String) -> String {
    var result = ""
    for char in s {
        result += String(char) + String(char)
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// 2. Write a function that takes a string as an argument and returns a new string that contains the same letters in the same order, but with each letter repeated twice.
// stringDoubler("Hello") == "HHeelllloo"
// stringDoubler("Goodbye") == "GGoooodddbbYYbyyeeezzz"
func stringDoubler(s: String) -> String {
    var result = ""
    for char in s {
        result += String(char) + String(char)
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// 3. Write a function that takes a string as an argument and returns a new string that contains the same letters in the same order, but with each letter repeated twice.
// stringDoubler("Hello") == "HHeelllloo"
// stringDoubler("Goodbye") == "GGoooodddbbYYbyyeeezzz"
func stringDoubler(s: String) -> String {
    var result = ""
    for char in s {
        result += String(char) + String(char)
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// 4. Write a function that takes a string as an argument and returns a new string that contains the same letters in the same order, but with each letter repeated twice.
// stringDoubler("Hello") == "HHeelllloo"
// stringDoubler("Goodbye") == "GGoooodddbbYYbyyeeezzz"
func stringDoubler(s: String) -> String {
    var result = ""
    for char in s {
        result += String(char) + String(char)
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// 5. Write a function that takes a string as an argument and returns a new string that contains the same letters in the same order, but with each letter repeated twice.
// stringDoubler("Hello") == "HHeelllloo"
// stringDoubler("Goodbye") == "GGoooodddbbYYbyyeeezzz"
func stringDoubler(s: String) -> String {
    var result = ""
    for char in s {
        result += String(char) + String(char)
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// 6. Write a function that takes a string as an argument and returns a new string that contains the same letters in the same order, but with each letter repeated twice.
// stringDoubler("Hello") == "H
 // XCTAssertTrue failed

func stringSequence(n: Int) -> String {
    var result = ""
    for i in 0..<n {
        result += "\(i) "
    }
    return result
}
```swift
// Return a string containing space-delimited numbers starting from 0 upto n inclusive.
// stringSequence(n: 0) == "0"
// stringSequence(n: 5) == "0 1 2 3 4 5"
func stringSequence(n: Int) -> String {
    var result = ""
    for i in 0..<n {
        result += "\(i) "
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// ------------------------------------------
 // XCTAssertTrue failed

func stringSequence(n: Int) -> String {
    var result = ""
    for i in 0...n {
        result += "\(i) "
    }
    return result.trim()
}

func reverseString(string: String) -> String {
    return string.reversed().join()
}

func firstUniqChar(string: String) -> Int {
    var result = 0
    var count = 0
    for char in string {
        if string.count(for: char) == 1 {
            result = string.firstIndex(of: char)!
            count += 1
            break
        }
    }
    return count == 0 ? -1 : result
}

func lengthOfLongestSubstring(string: String) -> Int {
    var result = 0
    var count = 0
    var start = 0
    var map = [Character: Int]()
    for i in 0..<string.count {
        if map[string[i]] != nil {
            start = max(map[string[i]]! + 1, start)
        }
        map[string[i]] = i
        count = i - start + 1
        result = max(result, count)
    }
    return result
}

func firstUniqChar(string: String) -> Int {
    var result = 0
    var count = 0
    var map = [Character: Int]()
    for i in 0..<string.count {
        if map[string[i]] != nil {
            map[string[i]]! += 1
        } else {
            map[string[i]] = 1
        }
    }
    for i in 0..<string.count {
        if map[string[i]] == 1 {
            result = i
            count += 1
            break
        }
    }
    return count == 0 ? -1 : result
}
```swift
// Return a string containing space-delimited numbers starting from 0 upto n inclusive.
// stringSequence(n: 0) == "0"
// stringSequence(n: 5) == "0 1 2 3 4 5"
func stringSequence(n: Int) -> String {
    var result = ""
    for i in 0...n {
        result += "\(i) "
    }
    return result.trim()
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 2. Write a function that takes a string as input and returns the string reversed.
// reverseString("hello") == "olleh"
// reverseString("Greetings from Earth") == "htraE morf sgniteerG"
func reverseString(string: String) -> String {
    return string.reversed().join()
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 3. Given a string s, find the first non-repeating character in it and return its index. If it doesn't exist, return -1.
// firstUniqChar("leetcode") == 0
// firstUniqChar("loveleetcode") == 2
func firstUniqChar(string: String) -> Int {
    var result = 0
    var count = 0
    for char in string {
        if string.count(for: char) == 1 {
            result = string.firstIndex(of: char)!
            count += 1
            break
        }
    }
    return count == 0 ? -1 : result
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 4. Given a string s, find the length of the longest substring without repeating characters.
// lengthOfLongestSubstring("abcabcbb") == 3
// lengthOfLongestSubstring("bbbbb") == 1
// lengthOfLongestSubstring("pwwkew") == 3
func lengthOfLongestSubstring(string: String) -> Int {
    var result = 0
    var count = 0
    var start = 0
    var map = [Character: Int]()
    for i in 0..<string.count {
        if map[string[i]] != nil {
            start = max(map[string[i]]! + 1, start)
        }
        map[string[i]] = i
        count = i - start + 1
        result = max(result, count)
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 5. Given a string s, find the first non-repeating character in it and return its index. If it doesn't exist, return -1.
// firstUniqChar("leetcode") == 0
// firstUniqChar("loveleetcode") == 2
func firstUniqChar(string: String) -> Int {
    var result = 0
    var count = 0
    var map = [Character: Int]()
    for i in 0..<string.count {
        if map[string[i]] != nil {
            map[string[i]]! += 1
        } else {
            map[string[i]] = 1
        }
    }
    for i in 0..<string.count {
        if map[string[i]] == 1 {
            result = i
            count += 1
            break
        }
    }
    return count == 0 ? -1 : result
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 6. Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.
// longest
return result.trim() // value of type 'String' has no member 'trim'
return string.reversed().join() // reference to member 'join' cannot be resolved without a contextual type
if string.count(for: char) == 1 { // cannot call value of non-function type 'Int'
result = string.firstIndex(of: char)! // cannot assign value of type 'String.Index' to type 'Int'
if map[string[i]] != nil { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
start = max(map[string[i]]! + 1, start) // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
map[string[i]] = i // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
func firstUniqChar(string: String) -> Int { // invalid redeclaration of 'firstUniqChar(string:)'
if map[string[i]] != nil { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
map[string[i]]! += 1 // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
map[string[i]] = 1 // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if map[string[i]] == 1 { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.

func countDistinctCharacters(string: String) -> Int {
    return Set(string.map { $0.toLowercase() }).count
}
```swift
// Given a string, find out how many distinct characters (regardless of case) does it consist of
// countDistinctCharacters(string: "xyzXYZ") == 3
// countDistinctCharacters(string: "Jerry") == 4
func countDistinctCharacters(string: String) -> Int {
    return Set(string.map { $0.toLowercase() }).count
}

// ----------------------------------------------------------------------------------------------------------------------

// 1.1.2
// ----------------------------------------------------------------------------------------------------------------------
// Given a string, find out how many distinct characters does it consist of
// countDistinctCharacters(string: "xyzXYZ") == 3
// countDistinctCharacters(string: "Jerry") == 4
func countDistinctCharacters(string: String) -> Int {
    return Set(string.map { $0.toLowercase() }).count
}

// ----------------------------------------------------------------------------------------------------------------------

// 1.1.3
// ----------------------------------------------------------------------------------------------------------------------
// Given a string, find out how many distinct characters does it consist of
// countDistinctCharacters(string: "xyzXYZ") == 3
// countDistinctCharacters(string: "Jerry") == 4
func countDistinctCharacters(string: String) -> Int {
    return Set(string.map { $0.toLowercase() }).count
}

// ----------------------------------------------------------------------------------------------------------------------

// 1.1.4
// ----------------------------------------------------------------------------------------------------------------------
// Given a string, find out how many distinct characters does it consist of
// countDistinctCharacters(string: "xyzXYZ") == 3
// countDistinctCharacters(string: "Jerry") == 4
func countDistinctCharacters(string: String) -> Int {
    return Set(string.map { $0.toLowercase() }).count
}

// ----------------------------------------------------------------------------------------------------------------------

// 1.1.5
// ----------------------------------------------------------------------------------------------------------------------
// Given a string, find out how many distinct characters does it consist of
// countDistinctCharacters(string: "xyzXYZ") == 3
// countDistinctCharacters(string: "Jerry") == 4
func countDistinctCharacters(string: String) -> Int {
    return Set(string.map { $0.toLowercase() }).count
}

// ----------------------------------------------------------------------------------------------------------------------

// 1.1.6
// ----------------------------------------------------------------------------------------------------------------------
// Given a string, find out how many distinct characters does it consist of
// countDistinctCharacters(string: "xyzXYZ") == 3
// countDistinctCharacters(string: "Jerry") == 4
func countDistinctCharacters(string: String) -> Int {
    return Set(string.map { $0.toLowercase() }).count
}

// ----------------------------------------------------------------------------------------------------------------------

// 1.1.7
// ------------------------------------------------------------------
return Set(string.map { $0.toLowercase() }).count // value of type 'String.Element' (aka 'Character') has no member 'toLowercase'

func countDistinctCharacters(string: String) -> Int {
    var set = Set<Character>()
    for char in string {
        set.insert(char)
    }
    return set.count
}

func longestSubstringWithoutRepeatingCharacters(string: String) -> String {
    var set = Set<Character>()
    var maxLength = 0
    var left = 0
    var right = 0
    while (right < string.count) {
        if !set.contains(string[right]) {
            set.insert(string[right])
            right += 1
            maxLength = max(maxLength, right - left)
        } else {
            set.remove(string[left])
            left += 1
        }
    }
    return string[left..<right]
}

func longestSubstringWithRepeatingCharacters(string: String) -> String {
    var set = Set<Character>()
    var maxLength = 0
    var left = 0
    var right = 0
    while (right < string.count) {
        if !set.contains(string[right]) {
            set.insert(string[right])
            right += 1
            maxLength = max(maxLength, right - left)
        } else {
            set.remove(string[left])
            left += 1
        }
    }
    return string[left..<right]
}
```swift
// Given a string, find out how many distinct characters (regardless of case) does it consist of
// countDistinctCharacters(string: "xyzXYZ") == 3
// countDistinctCharacters(string: "Jerry") == 4
func countDistinctCharacters(string: String) -> Int {
    var set = Set<Character>()
    for char in string {
        set.insert(char)
    }
    return set.count
}

// 2. Given a string, find the longest substring without repeating characters.
// countDistinctCharacters(string: "xyzXYZ") == 3
// countDistinctCharacters(string: "Jerry") == 4
func longestSubstringWithoutRepeatingCharacters(string: String) -> String {
    var set = Set<Character>()
    var maxLength = 0
    var left = 0
    var right = 0
    while (right < string.count) {
        if !set.contains(string[right]) {
            set.insert(string[right])
            right += 1
            maxLength = max(maxLength, right - left)
        } else {
            set.remove(string[left])
            left += 1
        }
    }
    return string[left..<right]
}

// 3. Given a string, find the longest substring with repeating characters.
// countDistinctCharacters(string: "xyzXYZ") == 3
// countDistinctCharacters(string: "Jerry") == 4
func longestSubstringWithRepeatingCharacters(string: String) -> String {
    var set = Set<Character>()
    var maxLength = 0
    var left = 0
    var right = 0
    while (right < string.count) {
        if !set.contains(string[right]) {
            set.insert(string[right])
            right += 1
            maxLength = max(maxLength, right - left)
        } else {
            set.remove(string[left])
            left += 1
        }
    }
    return string[left..<right]
}

// 4. Given a string, find the longest substring with repeating characters.
// countDistinctCharacters(string: "xyzXYZ") == 3
// countDistinctCharacters(string: "Jerry") == 4
func longestSubstringWithRepeatingCharacters(string: String) -> String {
    var set = Set<Character>()
    var maxLength = 0
    var left = 0
    var right = 0
    while (right < string.count) {
        if !set.contains(string[right]) {
            set.insert(string[right])
            right += 1
            maxLength = max(maxLength, right - left)
        } else {
            set.remove(string[left])
            left += 1
        }
    }
    return string[left..<right]
}

// 5. Given a string, find the longest substring with repeating characters.
// countDistinctCharacters(string: "xyzXYZ") == 3
// countDistinctCharacters(string: "Jerry") == 4
func longestSubstringWithRepeatingCharacters(string: String) -> String {
    var set = Set<Character>()
    var maxLength = 0
    var left = 0
    var right = 0
    while (right < string.count) {
        if !set.contains(string[right]) {
            set.insert(string[right])
            right += 1
            maxLength = max(maxLength, right - left)
        } else {
            set.remove(string[left])
            left += 1
        }
    }
    return string[left..<right]
}

// 6. Given a string, find the longest substring with repeating characters.
// countDistinctCharacters(string: "xyzXYZ") == 3
// countDistinctCharacters(string: "Jerry") == 4
func longestSubstringWithRepeatingCharacters(string: String) -> String {
    var set = Set<Character>()
    var maxLength = 0
    var left = 0
    var right = 0
    while (right < string.count) {
        if !set.contains(string[right]) {
            set.insert(string[right])
            right += 1
            maxLength = max(maxLength, right - left)
        } else {
            set.remove(string[left])
            left += 1
        }
if !set.contains(string[right]) { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
set.insert(string[right]) // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
set.remove(string[left]) // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
return string[left..<right] // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.
if !set.contains(string[right]) { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
set.insert(string[right]) // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
set.remove(string[left]) // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
return string[left..<right] // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.

func countDistinctCharacters(string: String) -> Int {
    return Set(string).count
}

func longestPalindromicSubstring(string: String) -> String {
    var longest = ""
    for i in 0..<string.count {
        for j in i..<string.count {
            let substring = string[i..<j]
            if substring == substring.reversed() && substring.length > longest.length {
                longest = substring
            }
        }
    }
    return longest
}
```swift
// Given a string, find out how many distinct characters (regardless of case) does it consist of
// countDistinctCharacters(string: "xyzXYZ") == 3
// countDistinctCharacters(string: "Jerry") == 4
func countDistinctCharacters(string: String) -> Int {
    return Set(string).count
}

// ----------------------------------------------------------------------------------------------------------------------
// 1.1.3
// Given a string, find the longest palindromic substring.
// longestPalindromicSubstring(string: "abaxyzzyxf") == "xyzzyx"
// longestPalindromicSubstring(string: "abaxyzzyxf") == "a"
// longestPalindromicSubstring(string: "abaxyzzyxf") == "f"
// longestPalindromicSubstring(string: "abaxyzzyxf") == ""
func longestPalindromicSubstring(string: String) -> String {
    var longest = ""
    for i in 0..<string.count {
        for j in i..<string.count {
            let substring = string[i..<j]
            if substring == substring.reversed() && substring.length > longest.length {
                longest = substring
            }
        }
    }
    return longest
}

// ----------------------------------------------------------------------------------------------------------------------
// 1.1.4
// Given a string, find the longest palindromic substring of it.
// longestPalindromicSubstring(string: "abaxyzzyxf") == "xyzzyx"
// longestPalindromicSubstring(string: "abaxyzzyxf") == "a"
// longestPalindromicSubstring(string: "abaxyzzyxf") == "f"
// longestPalindromicSubstring(string: "abaxyzzyxf") == ""
func longestPalindromicSubstring(string: String) -> String {
    var longest = ""
    for i in 0..<string.count {
        for j in i..<string.count {
            let substring = string[i..<j]
            if substring == substring.reversed() && substring.length > longest.length {
                longest = substring
            }
        }
    }
    return longest
}

// ----------------------------------------------------------------------------------------------------------------------
// 1.1.5
// Given a string, find the longest palindromic substring of it.
// longestPalindromicSubstring(string: "abaxyzzyxf") == "xyzzyx"
// longestPalindromicSubstring(string: "abaxyzzyxf") == "a"
// longestPalindromicSubstring(string: "abaxyzzyxf") == "f"
// longestPalindromicSubstring(string: "abaxyzzyxf") == ""
func longestPalindromicSubstring(string: String) -> String {
    var longest = ""
    for i in 0..<string.count {
        for j in i..<string.count {
            let substring = string[i..<j]
            if substring == substring.reversed() && substring.length > longest.length {
                longest = substring
            }
        }
    }
    return longest
}

// ----------------------------------------------------------------------------------------------------------------------
// 1.1.6
// Given a string, find the longest palindromic substring of it.
// longestPalindromicSubstring(string: "abaxyzzyxf") == "xyzzyx"
// longestPalindromicSubstring(string: "abaxyzzyxf") == "a"
// longestPalindromicSubstring(string: "abaxyzzyxf") == "f"
// longestPalindromicSubstring(string: "abaxyzzyxf") == ""
func longestPal
let substring = string[i..<j] // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.
if substring == substring.reversed() && substring.length > longest.length { // value of type 'String' has no member 'length'
if substring == substring.reversed() && substring.length > longest.length { // cannot convert value of type 'ReversedCollection<String>' to expected argument type 'String'
if substring == substring.reversed() && substring.length > longest.length { // value of type 'String' has no member 'length'

func countDistinctCharacters(string: String) -> Int {
    var set = Set<Character>()
    for c in string {
        set.insert(c)
    }
    return set.count
}

func removeVowels(string: String) -> String {
    var result = ""
    for c in string {
        if c != "a" && c != "e" && c != "i" && c != "o" && c != "u" {
            result += c
        }
    }
    return result
}

func removeSpaces(string: String) -> String {
    var result = ""
    for c in string {
        if c != " " {
            result += c
        }
    }
    return result
}

func swapCase(string: String) -> String {
    var result = ""
    for c in string {
        if c.isUpper {
            result += c.lowerCased
        } else {
            result += c.upperCased
        }
    }
    return result
}
```swift
// Given a string, find out how many distinct characters (regardless of case) does it consist of
// countDistinctCharacters(string: "xyzXYZ") == 3
// countDistinctCharacters(string: "Jerry") == 4
func countDistinctCharacters(string: String) -> Int {
    var set = Set<Character>()
    for c in string {
        set.insert(c)
    }
    return set.count
}

// 2. Write a function that takes a string and returns a string with all the vowels removed.
// removeVowels("Hey, I'm a coder") == "Hy, m  coder"
func removeVowels(string: String) -> String {
    var result = ""
    for c in string {
        if c != "a" && c != "e" && c != "i" && c != "o" && c != "u" {
            result += c
        }
    }
    return result
}

// 3. Write a function that takes a string and returns a string with all the spaces removed.
// removeSpaces("Hello, world!") == "Helloworld!"
func removeSpaces(string: String) -> String {
    var result = ""
    for c in string {
        if c != " " {
            result += c
        }
    }
    return result
}

// 4. Write a function that takes a string and returns a string with all the uppercase characters lowercase and all lowercase characters uppercase.
// swapCase("Hello, world!") == "hELLO, WORLD!"
func swapCase(string: String) -> String {
    var result = ""
    for c in string {
        if c.isUpper {
            result += c.lowerCased
        } else {
            result += c.upperCased
        }
    }
    return result
}

// 5. Write a function that takes a string and returns a string with all the vowels removed.
// removeVowels("Hey, I'm a coder") == "Hy, m  coder"
func removeVowels(string: String) -> String {
    var result = ""
    for c in string {
        if c != "a" && c != "e" && c != "i" && c != "o" && c != "u" {
            result += c
        }
    }
    return result
}

// 6. Write a function that takes a string and returns a string with all the spaces removed.
// removeSpaces("Hello, world!") == "Helloworld!"
func removeSpaces(string: String) -> String {
    var result = ""
    for c in string {
        if c != " " {
            result += c
        }
    }
    return result
}

// 7. Write a function that takes a string and returns a string with all the uppercase characters lowercase and all lowercase characters uppercase.
// swapCase("Hello, world!") == "hELLO, WORLD!"
func swapCase(string: String) -> String {
    var result = ""
    for c in string {
        if c.isUpper {
            result += c.lowerCased
        } else {
            result += c.upperCased
        }
    }
    return result
}

// 8. Write a function that takes a string and returns a string with all the vowels removed.
// removeVowels("Hey, I'm a coder") == "Hy, m  coder"
func removeVowels(string: String) -> String {
    var result = ""
    for c in string {
        if c != "a" && c != "e" && c != "i" && c != "o" && c != "u" {
            result += c
        }
    }
    return result
}

// 9. Write a function that takes a string and returns a string with all the spaces removed.
// removeSpaces("Hello, world!") == "Helloworld!"
func removeSpaces(string: String) -> String {
    var result = ""
    for c in string {
        if c != " " {
            result += c
        }
    }
    return result
}

// 10. Write a function that takes a string and returns a string with all the uppercase characters lowercase and all lowercase characters uppercase.
result += c // cannot convert value of type 'Character' to expected argument type 'String'
result += c // cannot convert value of type 'Character' to expected argument type 'String'
if c.isUpper { // value of type 'Character' has no member 'isUpper'
result += c.lowerCased // value of type 'Character' has no member 'lowerCased'
result += c.upperCased // value of type 'Character' has no member 'upperCased'

func countDistinctCharacters(string: String) -> Int {
    var chars = [Character]()
    for c in string {
        if !chars.contains(c) {
            chars.append(c)
        }
    }
    return chars.count
}
```swift
// Given a string, find out how many distinct characters (regardless of case) does it consist of
// countDistinctCharacters(string: "xyzXYZ") == 3
// countDistinctCharacters(string: "Jerry") == 4
func countDistinctCharacters(string: String) -> Int {
    var chars = [Character]()
    for c in string {
        if !chars.contains(c) {
            chars.append(c)
        }
    }
    return chars.count
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// 
 // XCTAssertTrue failed

func countDistinctCharacters(string: String) -> Int {
    var distinctCharacters = Set<Character>()
    for character in string {
        distinctCharacters.insert(character)
    }
    return distinctCharacters.count
}
```swift
// Given a string, find out how many distinct characters (regardless of case) does it consist of
// countDistinctCharacters(string: "xyzXYZ") == 3
// countDistinctCharacters(string: "Jerry") == 4
func countDistinctCharacters(string: String) -> Int {
    var distinctCharacters = Set<Character>()
    for character in string {
        distinctCharacters.insert(character)
    }
    return distinctCharacters.count
}

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
 // XCTAssertTrue failed

func countDistinctCharacters(string: String) -> Int {
    var count = 0
    var seen = Set<Character>()
    for c in string {
        if !seen.contains(c) {
            count += 1
            seen.insert(c)
        }
    }
    return count
}
```swift
// Given a string, find out how many distinct characters (regardless of case) does it consist of
// countDistinctCharacters(string: "xyzXYZ") == 3
// countDistinctCharacters(string: "Jerry") == 4
func countDistinctCharacters(string: String) -> Int {
    var count = 0
    var seen = Set<Character>()
    for c in string {
        if !seen.contains(c) {
            count += 1
            seen.insert(c)
        }
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------------------------------------------------------------------
 // XCTAssertTrue failed

func countDistinctCharacters(string: String) -> Int {
    return Set(string.uppercase).count
}

func countLowercaseLetters(string: String) -> Int {
    return string.count(for: .lowerCased)
}

func countUppercaseLetters(string: String) -> Int {
    return string.count(for: .upperCased)
}

func countDigits(string: String) -> Int {
    return string.count(for: .digit)
}

func countWords(string: String) -> Int {
    return string.split(by: .whitespace).count
}

func countWordsExcludingPunctuation(string: String) -> Int {
    return string.split(by: .whitespace).count
}

func countWordsExcludingPunctuationAndNumbers(string: String) -> Int {
    return string.split(by: .whitespace).count
}

func countWordsExcludingPunctuationAndNumbersAndSpaces(string: String) -> Int {
    return string.split(by: .whitespace).count
}
```swift
// Given a string, find out how many distinct characters (regardless of case) does it consist of
// countDistinctCharacters(string: "xyzXYZ") == 3
// countDistinctCharacters(string: "Jerry") == 4
func countDistinctCharacters(string: String) -> Int {
    return Set(string.uppercase).count
}

// 2. Given a string, find out how many lowercase letters does it consist of
// countLowercaseLetters(string: "xyzXYZ") == 3
// countLowercaseLetters(string: "Jerry") == 2
func countLowercaseLetters(string: String) -> Int {
    return string.count(for: .lowerCased)
}

// 3. Given a string, find out how many uppercase letters does it consist of
// countUppercaseLetters(string: "xyzXYZ") == 3
// countUppercaseLetters(string: "Jerry") == 1
func countUppercaseLetters(string: String) -> Int {
    return string.count(for: .upperCased)
}

// 4. Given a string, find out how many digits does it consist of
// countDigits(string: "xyzXYZ") == 0
// countDigits(string: "Jerry123") == 3
func countDigits(string: String) -> Int {
    return string.count(for: .digit)
}

// 5. Given a string, find out how many words does it consist of
// countWords(string: "xyzXYZ") == 1
// countWords(string: "Jerry") == 1
// countWords(string: "Jerry,") == 2
// countWords(string: "Jerry, ") == 2
// countWords(string: "Jerry, 123") == 3
func countWords(string: String) -> Int {
    return string.split(by: .whitespace).count
}

// 6. Given a string, find out how many words does it consist of, excluding punctuation
// countWordsExcludingPunctuation(string: "xyzXYZ") == 1
// countWordsExcludingPunctuation(string: "Jerry") == 1
// countWordsExcludingPunctuation(string: "Jerry,") == 1
// countWordsExcludingPunctuation(string: "Jerry, ") == 1
// countWordsExcludingPunctuation(string: "Jerry, 123") == 1
func countWordsExcludingPunctuation(string: String) -> Int {
    return string.split(by: .whitespace).count
}

// 7. Given a string, find out how many words does it consist of, excluding punctuation and numbers
// countWordsExcludingPunctuationAndNumbers(string: "xyzXYZ") == 1
// countWordsExcludingPunctuationAndNumbers(string: "Jerry") == 1
// countWordsExcludingPunctuationAndNumbers(string: "Jerry,") == 1
// countWordsExcludingPunctuationAndNumbers(string: "Jerry, ") == 1
// countWordsExcludingPunctuationAndNumbers(string: "Jerry, 123") == 1
func countWordsExcludingPunctuationAndNumbers(string: String) -> Int {
    return string.split(by: .whitespace).count
}

// 8. Given a string, find out how many words does it consist of, excluding punctuation, numbers and spaces
// countWordsExcludingPunctuationAndNumbersAndSpaces(string: "xyzXYZ") == 1
// countWordsExcludingPunctuationAndNumbersAndSpaces(string: "Jerry") == 1
// countWordsExcludingPunctuationAndNumbersAndSpaces(string: "Jerry,") == 1
// countWordsExcludingPunctuationAndNumbersAndSpaces(string: "Jerry, ") == 1
// countWordsExcludingPunctuationAndNumbersAndSpaces(string: "Jerry, 123") == 1
func countWordsExcludingPunctuationAndNumbersAndSpaces(string: String) -> Int {
    return string.split(by: .whitespace).count
}

// 9. Given a string, find out how many words does it consist of, excluding punctuation, numbers, spaces and special characters
// countWordsExcludingPunctuationAndNumbersAndSpacesAndSpecialCharacters(string: "xyzXYZ") == 1
// countWordsEx
return Set(string.uppercase).count // value of type 'String' has no member 'uppercase'
return string.count(for: .lowerCased) // cannot call value of non-function type 'Int'
return string.count(for: .lowerCased) // cannot infer contextual base in reference to member 'lowerCased'
return string.count(for: .upperCased) // cannot infer contextual base in reference to member 'upperCased'
return string.count(for: .upperCased) // cannot call value of non-function type 'Int'
return string.count(for: .digit) // cannot infer contextual base in reference to member 'digit'
return string.count(for: .digit) // cannot call value of non-function type 'Int'
return string.split(by: .whitespace).count // no exact matches in call to instance method 'split'
return string.split(by: .whitespace).count // cannot infer contextual base in reference to member 'whitespace'
return string.split(by: .whitespace).count // no exact matches in call to instance method 'split'
return string.split(by: .whitespace).count // cannot infer contextual base in reference to member 'whitespace'
return string.split(by: .whitespace).count // cannot infer contextual base in reference to member 'whitespace'
return string.split(by: .whitespace).count // no exact matches in call to instance method 'split'
return string.split(by: .whitespace).count // cannot infer contextual base in reference to member 'whitespace'
return string.split(by: .whitespace).count // no exact matches in call to instance method 'split'

func countDistinctCharacters(string: String) -> Int {
    var chars = Set<Character>()
    for char in string {
        chars.insert(char)
    }
    return chars.count
}

func longestPalindrome(string: String) -> String {
    var longest = ""
    for i in 0..<string.count {
        for j in i..<string.count {
            var substring = string[i..<j]
            if substring == substring.reversed() {
                if substring.count > longest.count {
                    longest = substring
                }
            }
        }
    }
    return longest
}
```swift
// Given a string, find out how many distinct characters (regardless of case) does it consist of
// countDistinctCharacters(string: "xyzXYZ") == 3
// countDistinctCharacters(string: "Jerry") == 4
func countDistinctCharacters(string: String) -> Int {
    var chars = Set<Character>()
    for char in string {
        chars.insert(char)
    }
    return chars.count
}

// 2. Given a string, find the longest palindromic substring in it.
// countDistinctCharacters(string: "xyzXYZ") == 3
// countDistinctCharacters(string: "Jerry") == 4
func longestPalindrome(string: String) -> String {
    var longest = ""
    for i in 0..<string.count {
        for j in i..<string.count {
            var substring = string[i..<j]
            if substring == substring.reversed() {
                if substring.count > longest.count {
                    longest = substring
                }
            }
        }
    }
    return longest
}

// 3. Given a string, find the longest palindromic substring in it.
// countDistinctCharacters(string: "xyzXYZ") == 3
// countDistinctCharacters(string: "Jerry") == 4
func longestPalindrome(string: String) -> String {
    var longest = ""
    for i in 0..<string.count {
        for j in i..<string.count {
            var substring = string[i..<j]
            if substring == substring.reversed() {
                if substring.count > longest.count {
                    longest = substring
                }
            }
        }
    }
    return longest
}

// 4. Given a string, find the longest palindromic substring in it.
// countDistinctCharacters(string: "xyzXYZ") == 3
// countDistinctCharacters(string: "Jerry") == 4
func longestPalindrome(string: String) -> String {
    var longest = ""
    for i in 0..<string.count {
        for j in i..<string.count {
            var substring = string[i..<j]
            if substring == substring.reversed() {
                if substring.count > longest.count {
                    longest = substring
                }
            }
        }
    }
    return longest
}

// 5. Given a string, find the longest palindromic substring in it.
// countDistinctCharacters(string: "xyzXYZ") == 3
// countDistinctCharacters(string: "Jerry") == 4
func longestPalindrome(string: String) -> String {
    var longest = ""
    for i in 0..<string.count {
        for j in i..<string.count {
            var substring = string[i..<j]
            if substring == substring.reversed() {
                if substring.count > longest.count {
                    longest = substring
                }
            }
        }
    }
    return longest
}

// 6. Given a string, find the longest palindromic substring in it.
// countDistinctCharacters(string: "xyzXYZ") == 3
// countDistinctCharacters(string: "Jerry") == 4
func longestPalindrome(string: String) -> String {
    var longest = ""
    for i in 0..<string.count {
        for j in i..<string.count {
            var substring = string[i..<j]
            if substring == substring.reversed() {
                if substring.count > longest.count {
                    longest = substring
                }
            }
        }
    }
    return longest
}

// 7. Given a string, find the longest palindromic substring in it.
// countDistinctCharacters(string: "xyzXYZ") == 3
// countDistinctCharacters(string: "Jerry") == 4
func longestPalindrome(string: String) -> String {
    var longest = ""
    for i in 0..<string.count {
        for j in i..<string.count {
            var substring = string[i..<j]
            if substring ==
var substring = string[i..<j] // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.
if substring == substring.reversed() { // binary operator '==' cannot be applied to operands of type 'String' and '[String.Element]' (aka 'Array<Character>')

func countDistinctCharacters(string: String) -> Int {
    var set = Set<Character>()
    for c in string {
        set.insert(c)
    }
    return set.count
}
```swift
// Given a string, find out how many distinct characters (regardless of case) does it consist of
// countDistinctCharacters(string: "xyzXYZ") == 3
// countDistinctCharacters(string: "Jerry") == 4
func countDistinctCharacters(string: String) -> Int {
    var set = Set<Character>()
    for c in string {
        set.insert(c)
    }
    return set.count
}

// 2. Write a function that takes a string and returns the number of words in the string.
// countWords("Hello world") == 2
// countWords("Hello world!") == 2
// countWords("Hello world!!") == 2
// countWords("Hello world!!!") == 2
// countWords("Hello world!!!!") == 2
// countWords("Hello world!!!!!") == 2
// countWords("Hello world!!!!!!") == 2
// countWords("Hello world!!!!!!!") == 2
// countWords("Hello world!!!!!!!!") == 2
// countWords("Hello world!!!!!!!!!") == 2
// countWords("Hello world!!!!!!!!!!") == 2
// countWords("Hello world!!!!!!!!!!!") == 2
// countWords("Hello world!!!!!!!!!!!!") == 2
// countWords("Hello world!!!!!!!!!!!!!") == 2
// countWords("Hello world!!!!!!!!!!!!!!") == 2
// countWords("Hello world!!!!!!!!!!!!!!!") == 2
// countWords("Hello world!!!!!!!!!!!!!!!!") == 2
// countWords("Hello world!!!!!!!!!!!!!!!!!") == 2
// countWords("Hello world!!!!!!!!!!!!!!!!!!") == 2
// countWords("Hello world!!!!!!!!!!!!!!!!!!!") == 2
// countWords("Hello world!!!!!!!!!!!!!!!!!!!!") == 2
// countWords("Hello world!!!!!!!!!!!!!!!!!!!!!") == 2
// countWords("Hello world!!!!!!!!!!!!!!!!!!!!!!") == 2
// countWords("Hello world!!!!!!!!!!!!!!!!!!!!!!!") == 2
// countWords("Hello world!!!!!!!!!!!!!!!!!!!!!!!!") == 2
// countWords("Hello world!!!!!!!!!!!!!!!!!!!!!!!!!") == 2
// countWords("Hello world!!!!!!!!!!!!!!!!!!!!!!!!!!") == 2
// countWords("Hello world!!!!!!!!!!!!!!!!!!!!!!!!!!!") == 2
// countWords("Hello world!!!!!!!!!!!!!!!!!!!!!!!!!!!!") == 2
// countWords("Hello world!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") == 2
// countWords("Hello world!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") == 2
// countWords("Hello world!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") == 2
// countWords("Hello world!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") == 2
// countWords("Hello world!
 // XCTAssertTrue failed

func parseMusic(musicString: String) -> [Int] {
    let notes = musicString.split(separator: " ").map { $0.trim() }
    var result = [Int]()
    var currentBeat = 0
    for note in notes {
        switch note {
        case "o":
            currentBeat += 4
            result.append(currentBeat)
        case "o|":
            currentBeat += 2
            result.append(currentBeat)
        case ".|":
            currentBeat += 1
            result.append(currentBeat)
        default:
            break
        }
    }
    return result
}
```swift
// Input to this function is a string representing musical notes in a special ASCII format.
// Your task is to parse this string and return array of integers corresponding to how many beats does each
// not last.
// Here is a legend:
// 'o' - whole note, lasts four beats
// 'o|' - half note, lasts two beats
// '.|' - quater note, lasts one beat
// parseMusic(musicString: "o o| .| o| o| .| .| .| .| o o") == [4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]
func parseMusic(musicString: String) -> [Int] {
    let notes = musicString.split(separator: " ").map { $0.trim() }
    var result = [Int]()
    var currentBeat = 0
    for note in notes {
        switch note {
        case "o":
            currentBeat += 4
            result.append(currentBeat)
        case "o|":
            currentBeat += 2
            result.append(currentBeat)
        case ".|":
            currentBeat += 1
            result.append(currentBeat)
        default:
            break
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------------------------------------------------------------------------
let notes = musicString.split(separator: " ").map { $0.trim() } // reference to member 'trim' cannot be resolved without a contextual type

func parseMusic(musicString: String) -> [Int] {
    var result = [Int]()
    var currentBeat = 0
    var currentNote = 0
    for char in musicString {
        if char == "o" {
            currentBeat += 4
            currentNote += 1
        } else if char == "o|" {
            currentBeat += 2
            currentNote += 1
        } else if char == ".|" {
            currentBeat += 1
            currentNote += 1
        }
        result.append(currentBeat)
    }
    return result
}
```swift
// Input to this function is a string representing musical notes in a special ASCII format.
// Your task is to parse this string and return array of integers corresponding to how many beats does each
// not last.
// Here is a legend:
// 'o' - whole note, lasts four beats
// 'o|' - half note, lasts two beats
// '.|' - quater note, lasts one beat
// parseMusic(musicString: "o o| .| o| o| .| .| .| .| o o") == [4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]
func parseMusic(musicString: String) -> [Int] {
    var result = [Int]()
    var currentBeat = 0
    var currentNote = 0
    for char in musicString {
        if char == "o" {
            currentBeat += 4
            currentNote += 1
        } else if char == "o|" {
            currentBeat += 2
            currentNote += 1
        } else if char == ".|" {
            currentBeat += 1
            currentNote += 1
        }
        result.append(currentBeat)
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ------------------
} else if char == "o|" { // binary operator '==' cannot be applied to operands of type 'Character' and 'String'
} else if char == ".|" { // binary operator '==' cannot be applied to operands of type 'Character' and 'String'

func parseMusic(musicString: String) -> [Int] {
    var result = [Int]()
    var currentBeat = 0
    var currentNote = 0
    for char in musicString {
        if char == "o" {
            currentBeat += 4
            currentNote += 1
        } else if char == "o|" {
            currentBeat += 2
            currentNote += 1
        } else if char == ".|" {
            currentBeat += 1
            currentNote += 1
        }
        result.append(currentNote)
    }
    return result
}
```swift
// Input to this function is a string representing musical notes in a special ASCII format.
// Your task is to parse this string and return array of integers corresponding to how many beats does each
// not last.
// Here is a legend:
// 'o' - whole note, lasts four beats
// 'o|' - half note, lasts two beats
// '.|' - quater note, lasts one beat
// parseMusic(musicString: "o o| .| o| o| .| .| .| .| o o") == [4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]
func parseMusic(musicString: String) -> [Int] {
    var result = [Int]()
    var currentBeat = 0
    var currentNote = 0
    for char in musicString {
        if char == "o" {
            currentBeat += 4
            currentNote += 1
        } else if char == "o|" {
            currentBeat += 2
            currentNote += 1
        } else if char == ".|" {
            currentBeat += 1
            currentNote += 1
        }
        result.append(currentNote)
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ---------------------
} else if char == "o|" { // binary operator '==' cannot be applied to operands of type 'Character' and 'String'
} else if char == ".|" { // binary operator '==' cannot be applied to operands of type 'Character' and 'String'

func parseMusic(musicString: String) -> [Int] {
    var result = [Int]()
    var currentBeat = 0
    for note in musicString {
        if note == "o" {
            currentBeat += 4
        } else if note == "o|" {
            currentBeat += 2
        } else if note == ".|" {
            currentBeat += 1
        }
        result.append(currentBeat)
    }
    return result
}
```swift
// Input to this function is a string representing musical notes in a special ASCII format.
// Your task is to parse this string and return array of integers corresponding to how many beats does each
// not last.
// Here is a legend:
// 'o' - whole note, lasts four beats
// 'o|' - half note, lasts two beats
// '.|' - quater note, lasts one beat
// parseMusic(musicString: "o o| .| o| o| .| .| .| .| o o") == [4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]
func parseMusic(musicString: String) -> [Int] {
    var result = [Int]()
    var currentBeat = 0
    for note in musicString {
        if note == "o" {
            currentBeat += 4
        } else if note == "o|" {
            currentBeat += 2
        } else if note == ".|" {
            currentBeat += 1
        }
        result.append(currentBeat)
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------------------------------------------------------------------
} else if note == "o|" { // binary operator '==' cannot be applied to operands of type 'Character' and 'String'
} else if note == ".|" { // binary operator '==' cannot be applied to operands of type 'Character' and 'String'

func parseMusic(musicString: String) -> [Int] {
    var result = [Int]()
    var currentBeat = 0
    var currentNote = 0
    var currentLength = 0
    for char in musicString {
        if char == "o" {
            currentLength = 4
        } else if char == "o|" {
            currentLength = 2
        } else if char == ".|" {
            currentLength = 1
        }
        currentBeat += 1
        currentNote += 1
        if currentBeat == currentLength {
            currentBeat = 0
            currentNote = 0
            result.append(currentNote)
        }
    }
    return result
}
```swift
// Input to this function is a string representing musical notes in a special ASCII format.
// Your task is to parse this string and return array of integers corresponding to how many beats does each
// not last.
// Here is a legend:
// 'o' - whole note, lasts four beats
// 'o|' - half note, lasts two beats
// '.|' - quater note, lasts one beat
// parseMusic(musicString: "o o| .| o| o| .| .| .| .| o o") == [4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]
func parseMusic(musicString: String) -> [Int] {
    var result = [Int]()
    var currentBeat = 0
    var currentNote = 0
    var currentLength = 0
    for char in musicString {
        if char == "o" {
            currentLength = 4
        } else if char == "o|" {
            currentLength = 2
        } else if char == ".|" {
            currentLength = 1
        }
        currentBeat += 1
        currentNote += 1
        if currentBeat == currentLength {
            currentBeat = 0
            currentNote = 0
            result.append(currentNote)
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------
} else if char == "o|" { // binary operator '==' cannot be applied to operands of type 'Character' and 'String'
} else if char == ".|" { // binary operator '==' cannot be applied to operands of type 'Character' and 'String'

func parseMusic(musicString: String) -> [Int] {
    var result = [Int]()
    var currentBeat = 0
    var currentNote = 0
    for char in musicString {
        if char == "o" {
            currentBeat += 4
            currentNote += 1
        } else if char == "o|" {
            currentBeat += 2
            currentNote += 1
        } else if char == ".|" {
            currentBeat += 1
            currentNote += 1
        }
        result.append(currentNote)
    }
    return result
}

func highestScoringWord(word: String) -> String {
    var result = ""
    var currentScore = 0
    var currentWord = ""
    for char in word {
        if char == " " {
            if currentScore < score(currentWord) {
                currentScore = score(currentWord)
                result = currentWord
            }
            currentWord = ""
        } else {
            currentWord += char
        }
    }
    if currentScore < score(currentWord) {
        currentScore = score(currentWord)
        result = currentWord
    }
    return result
}

func descendingOrder(n: Int) -> Int {
    var result = 0
    var current = n
    var digits = [Int]()
    while current > 0 {
        digits.append(current % 10)
        current /= 10
    }
    for _ in digits {
        var max = 0
        for digit in digits {
            if digit > max {
                max = digit
            }
        }
        result = result * 10 + max
        digits.remove(at: digits.firstIndex(of: max)!)
    }
    return result
}
```swift
// Input to this function is a string representing musical notes in a special ASCII format.
// Your task is to parse this string and return array of integers corresponding to how many beats does each
// not last.
// Here is a legend:
// 'o' - whole note, lasts four beats
// 'o|' - half note, lasts two beats
// '.|' - quater note, lasts one beat
// parseMusic(musicString: "o o| .| o| o| .| .| .| .| o o") == [4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]
func parseMusic(musicString: String) -> [Int] {
    var result = [Int]()
    var currentBeat = 0
    var currentNote = 0
    for char in musicString {
        if char == "o" {
            currentBeat += 4
            currentNote += 1
        } else if char == "o|" {
            currentBeat += 2
            currentNote += 1
        } else if char == ".|" {
            currentBeat += 1
            currentNote += 1
        }
        result.append(currentNote)
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// https://www.codewars.com/kata/56f699cd9400f5b7d000b887/train/swift
// Given a string of words, you need to find the highest scoring word.
// Each letter of a word scores points according to its position in the alphabet: a = 1, b = 2, c = 3 etc.
// You need to return the highest scoring word as a string.
// If two words score the same, return the word that appears earliest in the original string.
// All letters will be lowercase and all inputs will be valid.
// highestScoringWord("man i need a taxi up to ubud") == "taxi"
// highestScoringWord("what time are we climbing up to the volcano") == "volcano"
// highestScoringWord("take me to semynak") == "semynak"
func highestScoringWord(word: String) -> String {
    var result = ""
    var currentScore = 0
    var currentWord = ""
    for char in word {
        if char == " " {
            if currentScore < score(currentWord) {
                currentScore = score(currentWord)
                result = currentWord
            }
            currentWord = ""
        } else {
            currentWord += char
        }
    }
    if currentScore < score(currentWord) {
        currentScore = score(currentWord)
        result = currentWord
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// https://www.codewars.com/kata/5667e8f4e3f572a8f2000039/train/swift
// Your task is to make a function that can take any non-negative integer as an argument and return it with its digits in descending order. Essentially, rearrange the digits to create the highest possible number.
// DescendingOrder(123) == 321
// DescendingOrder(123456789) == 987654321
func descendingOrder(n: Int) -> Int {
    var result = 0
    var current = n
    var digits = [Int]()
    while current > 0 {
        digits.append(current % 10)
        current /= 10
    }
    for _ in digits {
        var max = 0
        for digit in digits {
            if digit > max {
                max = digit
            }
        }
        result = result * 10 + max
        digits.remove(at: digits.firstIndex(of: max)!)
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// https://www.codewars.com/kata/5667e8f4e3f572a8f2000039/train/swift
// Given a string of words, you need to find the highest scoring word.
// Each letter of a word scores points according to its position in the alphabet: a = 1, b = 2, c = 3 etc.
// You need to return the highest scoring word as a string.
// If two words score the same, return the word that appears earliest in
} else if char == "o|" { // binary operator '==' cannot be applied to operands of type 'Character' and 'String'
} else if char == ".|" { // binary operator '==' cannot be applied to operands of type 'Character' and 'String'
if currentScore < score(currentWord) { // cannot find 'score' in scope
currentScore = score(currentWord) // cannot find 'score' in scope
currentWord += char // cannot convert value of type 'Character' to expected argument type 'String'
if currentScore < score(currentWord) { // cannot find 'score' in scope
currentScore = score(currentWord) // cannot find 'score' in scope

func parseMusic(musicString: String) -> [Int] {
    var result = [Int]()
    var currentBeat = 0
    for note in musicString {
        if note == "o" {
            currentBeat += 4
            result.append(currentBeat)
        } else if note == "o|" {
            currentBeat += 2
            result.append(currentBeat)
        } else if note == ".|" {
            currentBeat += 1
            result.append(currentBeat)
        }
    }
    return result
}
```swift
// Input to this function is a string representing musical notes in a special ASCII format.
// Your task is to parse this string and return array of integers corresponding to how many beats does each
// not last.
// Here is a legend:
// 'o' - whole note, lasts four beats
// 'o|' - half note, lasts two beats
// '.|' - quater note, lasts one beat
// parseMusic(musicString: "o o| .| o| o| .| .| .| .| o o") == [4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]
func parseMusic(musicString: String) -> [Int] {
    var result = [Int]()
    var currentBeat = 0
    for note in musicString {
        if note == "o" {
            currentBeat += 4
            result.append(currentBeat)
        } else if note == "o|" {
            currentBeat += 2
            result.append(currentBeat)
        } else if note == ".|" {
            currentBeat += 1
            result.append(currentBeat)
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------
} else if note == "o|" { // binary operator '==' cannot be applied to operands of type 'Character' and 'String'
} else if note == ".|" { // binary operator '==' cannot be applied to operands of type 'Character' and 'String'

func parseMusic(musicString: String) -> [Int] {
    let notes = musicString.split(separator: " ").map { $0.trim() }
    var result = [Int]()
    var beat = 0
    for note in notes {
        switch note {
        case "o":
            beat += 4
            result.append(beat)
        case "o|":
            beat += 2
            result.append(beat)
        case ".|":
            beat += 1
            result.append(beat)
        default:
            break
        }
    }
    return result
}
```swift
// Input to this function is a string representing musical notes in a special ASCII format.
// Your task is to parse this string and return array of integers corresponding to how many beats does each
// not last.
// Here is a legend:
// 'o' - whole note, lasts four beats
// 'o|' - half note, lasts two beats
// '.|' - quater note, lasts one beat
// parseMusic(musicString: "o o| .| o| o| .| .| .| .| o o") == [4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]
func parseMusic(musicString: String) -> [Int] {
    let notes = musicString.split(separator: " ").map { $0.trim() }
    var result = [Int]()
    var beat = 0
    for note in notes {
        switch note {
        case "o":
            beat += 4
            result.append(beat)
        case "o|":
            beat += 2
            result.append(beat)
        case ".|":
            beat += 1
            result.append(beat)
        default:
            break
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ---------------------
let notes = musicString.split(separator: " ").map { $0.trim() } // reference to member 'trim' cannot be resolved without a contextual type

func parseMusic(musicString: String) -> [Int] {
    let arr = musicString.split(separator: " ").map { $0.trim() }
    var res = [Int]()
    for i in arr {
        switch i {
        case "o":
            res.append(4)
        case "o|":
            res.append(2)
        case ".|":
            res.append(1)
        default:
            res.append(0)
        }
    }
    return res
}

func reverseString(s: String) -> String {
    return String(s.reversed())
}

func hammingWeight(n: Int) -> Int {
    return String(UInt32(n)).count(of: "1")
}
```swift
// Input to this function is a string representing musical notes in a special ASCII format.
// Your task is to parse this string and return array of integers corresponding to how many beats does each
// not last.
// Here is a legend:
// 'o' - whole note, lasts four beats
// 'o|' - half note, lasts two beats
// '.|' - quater note, lasts one beat
// parseMusic(musicString: "o o| .| o| o| .| .| .| .| o o") == [4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]
func parseMusic(musicString: String) -> [Int] {
    let arr = musicString.split(separator: " ").map { $0.trim() }
    var res = [Int]()
    for i in arr {
        switch i {
        case "o":
            res.append(4)
        case "o|":
            res.append(2)
        case ".|":
            res.append(1)
        default:
            res.append(0)
        }
    }
    return res
}

// 10. Write a function that takes a string as input and returns the string reversed.
// Example:
// Given s = "hello", return "olleh".
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// 11. Write a function that takes an integer and returns the number of 1 bits it has.
// Example:
// Given input n = 00000000000000000000000000001011, return 3.
//
// Note:
// - `popcount` is a built-in function in C++, Java, Go, JavaScript, PHP and Python, but not in C.
// - The best solution to this problem is probably a built-in function in some languages.
// - This question is the same as 191: https://leetcode.com/problems/number-of-1-bits/
func hammingWeight(n: Int) -> Int {
    return String(UInt32(n)).count(of: "1")
}

// 12. Write a function that takes an integer and returns the number of 1 bits it has.
// Example:
// Given input n = 00000000000000000000000000001011, return 3.
//
// Note:
// - `popcount` is a built-in function in C++, Java, Go, JavaScript, PHP and Python, but not in C.
// - The best solution to this problem is probably a built-in function in some languages.
// - This question is the same as 191: https://leetcode.com/problems/number-of-1-bits/
func hammingWeight(n: Int) -> Int {
    return String(UInt32(n)).count(of: "1")
}

// 13. Write a function that takes an integer and returns the number of 1 bits it has.
// Example:
// Given input n = 00000000000000000000000000001011, return 3.
//
// Note:
// - `popcount` is a built-in function in C++, Java, Go, JavaScript, PHP and Python, but not in C.
// - The best solution to this problem is probably a built-in function in some languages.
// - This question is the same as 191: https://leetcode.com/problems/number-of-1-bits/
func hammingWeight(n: Int) -> Int {
    return String(UInt32(n)).count(of: "1")
}

// 14. Write a function that takes an integer and returns the number of 1 bits it has.
// Example:
// Given input n = 00000000000000000000000000001011, return 3.
//
// Note:
// - `popcount` is a built-in function in C++, Java, Go, JavaScript, PHP and Python, but not in C.
// - The best solution to this problem is probably a built-in function in some languages.
// - This question is the same as 191: https://leetcode.com/problems/number-of-1-bits/
func hammingWeight(n: Int) -> Int {
    return String(UInt32(n)).count(of: "1")
}

// 15. Write a function that takes an integer and returns the number of 1 bits it has.
// Example:
// Given input n = 0000000000000
let arr = musicString.split(separator: " ").map { $0.trim() } // reference to member 'trim' cannot be resolved without a contextual type
return String(UInt32(n)).count(of: "1") // cannot call value of non-function type 'Int'

func parseMusic(musicString: String) -> [Int] {
    var result = [Int]()
    var currentBeat = 0
    var currentNote = 0
    for char in musicString {
        if char == "o" {
            currentBeat += 4
            currentNote += 1
        } else if char == "o|" {
            currentBeat += 2
            currentNote += 1
        } else if char == ".|" {
            currentBeat += 1
            currentNote += 1
        }
        result.append(currentNote)
    }
    return result
}

function findOdd(A) {
    return A.find(a => A.filter(b => b === a).length % 2 !== 0)
}

function high(x){
    let alphabet = "abcdefghijklmnopqrstuvwxyz".split("")
    let words = x.split(" ")
    let scores = words.map(word => {
        let score = 0
        for (let i = 0; i < word.length; i++) {
            score += alphabet.indexOf(word[i]) + 1
        }
        return score
    })
    return words[scores.indexOf(Math.max(...scores))]
}
```swift
// Input to this function is a string representing musical notes in a special ASCII format.
// Your task is to parse this string and return array of integers corresponding to how many beats does each
// not last.
// Here is a legend:
// 'o' - whole note, lasts four beats
// 'o|' - half note, lasts two beats
// '.|' - quater note, lasts one beat
// parseMusic(musicString: "o o| .| o| o| .| .| .| .| o o") == [4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]
func parseMusic(musicString: String) -> [Int] {
    var result = [Int]()
    var currentBeat = 0
    var currentNote = 0
    for char in musicString {
        if char == "o" {
            currentBeat += 4
            currentNote += 1
        } else if char == "o|" {
            currentBeat += 2
            currentNote += 1
        } else if char == ".|" {
            currentBeat += 1
            currentNote += 1
        }
        result.append(currentNote)
    }
    return result
}

// 2.
// Given an array of integers, find the one that appears an odd number of times.
// There will always be only one integer that appears an odd number of times.
// Examples
// [7] should return 7, because it occurs 1 time (which is odd).
// [0] should return 0, because it occurs 1 time (which is odd).
// [1,1,2] should return 2, because it occurs 1 time (which is odd).
// [0,1,0,1,0] should return 0, because it occurs 3 times (which is odd).
// [1,2,2,3,3,3,4,3,3,3,2,2,1] should return 4, because it appears 1 time (which is odd).
// Notes
// There will always be only one integer that appears an odd number of times.
// Int32 is not allowed for the language
// Function name should be findOdd
function findOdd(A) {
    return A.find(a => A.filter(b => b === a).length % 2 !== 0)
}

// 3.
// Given a string of words, you need to find the highest scoring word.
// Each letter of a word scores points according to its position in the alphabet: a = 1, b = 2, c = 3 etc.
// You need to return the highest scoring word as a string.
// If two words score the same, return the word that appears earliest in the original string.
// All letters will be lowercase and all inputs will be valid.
// Examples
// high("hello") == "hello"
// high("hey") == "hey"
// high("") == ""
// high("a") == "a"
// high("bb") == "bb"
// high("code") == "code"
// high("aewfauhq3yh8y3h5dfjhy3y8573y8573y8573") == "aewfauhq3yh8y3h5dfjhy3y8573y8573"
function high(x){
    let alphabet = "abcdefghijklmnopqrstuvwxyz".split("")
    let words = x.split(" ")
    let scores = words.map(word => {
        let score = 0
        for (let i = 0; i < word.length; i++) {
            score += alphabet.indexOf(word[i]) + 1
        }
        return score
    })
    return words[scores.indexOf(Math.max(...scores))]
}

// 4.
// Given a string of words, you need to find the highest scoring word.
// Each letter of a word scores points according to its position in the alphabet: a = 1, b = 2, c = 3 etc.
// You need to return the highest scoring word as a string.
// If two words score the same, return the word that appears earliest in the original string.
// All letters will be lowercase and all inputs will be valid.
// Examples
// high("hello") == "hello"
// high("hey") == "hey"
// high("") == ""
// high("a") == "a"
// high("bb") == "bb"
// high("code") == "code"
// high("aewfauhq3yh8y3h5dfjhy3y8573y8573y8573") == "aewfauhq3yh8y3h5dfjhy3y8573
} else if char == "o|" { // binary operator '==' cannot be applied to operands of type 'Character' and 'String'
} else if char == ".|" { // binary operator '==' cannot be applied to operands of type 'Character' and 'String'
function findOdd(A) { // expansion of macro 'function()' requires leading '#'
function findOdd(A) { // generic parameter 'T' could not be inferred
function findOdd(A) { // consecutive statements on a line must be separated by ';'
function findOdd(A) { // cannot find 'A' in scope
function findOdd(A) { // cannot find 'findOdd' in scope
return A.find(a => A.filter(b => b === a).length % 2 !== 0) // cannot find 'a' in scope
return A.find(a => A.filter(b => b === a).length % 2 !== 0) // cannot find 'b' in scope
return A.find(a => A.filter(b => b === a).length % 2 !== 0) // cannot find 'a' in scope
return A.find(a => A.filter(b => b === a).length % 2 !== 0) // argument type 'Int' expected to be an instance of a class or class-constrained type
return A.find(a => A.filter(b => b === a).length % 2 !== 0) // cannot find 'A' in scope
return A.find(a => A.filter(b => b === a).length % 2 !== 0) // cannot find 'A' in scope
return A.find(a => A.filter(b => b === a).length % 2 !== 0) // argument type 'Int' expected to be an instance of a class or class-constrained type
return A.find(a => A.filter(b => b === a).length % 2 !== 0) // cannot find operator '=>' in scope
return A.find(a => A.filter(b => b === a).length % 2 !== 0) // cannot find 'b' in scope
return A.find(a => A.filter(b => b === a).length % 2 !== 0) // cannot find operator '=>' in scope
function high(x){ // cannot find 'x' in scope
function high(x){ // expansion of macro 'function()' requires leading '#'
function high(x){ // cannot find 'high' in scope
function high(x){ // generic parameter 'T' could not be inferred
function high(x){ // consecutive statements on a line must be separated by ';'
let alphabet = "abcdefghijklmnopqrstuvwxyz".split("") // missing argument label 'separator:' in call
let words = x.split(" ") // cannot find 'x' in scope
let scores = words.map(word => { // cannot find 'word' in scope
let scores = words.map(word => { // cannot find operator '=>' in scope
for (let i = 0; i < word.length; i++) { // C-style for statement has been removed in Swift 3
score += alphabet.indexOf(word[i]) + 1 // cannot find 'word' in scope
score += alphabet.indexOf(word[i]) + 1 // cannot find 'i' in scope
return words[scores.indexOf(Math.max(...scores))] // cannot find 'Math' in scope

func howManyTimes(string: String, substring: String) -> Int {
    var count = 0
    var index = 0
    while index < string.count {
        if string[index...].contains(substring) {
            count += 1
            index += substring.count
        } else {
            index += 1
        }
    }
    return count
}
```swift
// Find how many times a given substring can be found in the original string. Count overlaping cases.
// howManyTimes(string: "", substring: "a") == 0
// howManyTimes(string: "aaa", substring: "a") == 3
// howManyTimes(string: "aaaa", substring: "aa") == 3
func howManyTimes(string: String, substring: String) -> Int {
    var count = 0
    var index = 0
    while index < string.count {
        if string[index...].contains(substring) {
            count += 1
            index += substring.count
        } else {
            index += 1
        }
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ------------------------------------------------------------
if string[index...].contains(substring) { // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.

func howManyTimes(string: String, substring: String) -> Int {
    var count = 0
    var index = 0
    while index != -1 {
        index = string.firstIndex(of: substring, options: .caseInsensitive, range: (index + 1 ... string.count))
        if index != -1 {
            count += 1
        }
    }
    return count
}

func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char: char) {
            result += char
        }
    }
    return result
}
```swift
// Find how many times a given substring can be found in the original string. Count overlaping cases.
// howManyTimes(string: "", substring: "a") == 0
// howManyTimes(string: "aaa", substring: "a") == 3
// howManyTimes(string: "aaaa", substring: "aa") == 3
func howManyTimes(string: String, substring: String) -> Int {
    var count = 0
    var index = 0
    while index != -1 {
        index = string.firstIndex(of: substring, options: .caseInsensitive, range: (index + 1 ... string.count))
        if index != -1 {
            count += 1
        }
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 12. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I have a dog") == " hv dg"
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char: char) {
            result += char
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 13. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I have a dog") == " hv dg"
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char: char) {
            result += char
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 14. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I have a dog") == " hv dg"
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char: char) {
            result += char
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 15. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I have a dog") == " hv dg"
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char: char) {
            result += char
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 16. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I have a dog") == " hv dg"
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char: char) {
            result += char
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 17. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I have a dog") == " hv dg"
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char: char) {
            result += char
        }
    }
    return result
}

// ---------------------------------------
index = string.firstIndex(of: substring, options: .caseInsensitive, range: (index + 1 ... string.count)) // cannot assign value of type 'String.Index?' to type 'Int'
index = string.firstIndex(of: substring, options: .caseInsensitive, range: (index + 1 ... string.count)) // cannot infer contextual base in reference to member 'caseInsensitive'
index = string.firstIndex(of: substring, options: .caseInsensitive, range: (index + 1 ... string.count)) // extra arguments at positions #2, #3 in call
index = string.firstIndex(of: substring, options: .caseInsensitive, range: (index + 1 ... string.count)) // cannot convert value of type 'String' to expected argument type 'String.Element' (aka 'Character')
if !isVowel(char: char) { // cannot find 'isVowel' in scope
result += char // cannot convert value of type 'Character' to expected argument type 'String'

func howManyTimes(string: String, substring: String) -> Int {
    var count = 0
    var index = 0
    while index < string.count {
        index = string.firstIndex(of: substring, options: .caseInsensitive, range: (index, string.count - index))
        if index == nil {
            break
        }
        count += 1
        index += substring.count
    }
    return count
}
```swift
// Find how many times a given substring can be found in the original string. Count overlaping cases.
// howManyTimes(string: "", substring: "a") == 0
// howManyTimes(string: "aaa", substring: "a") == 3
// howManyTimes(string: "aaaa", substring: "aa") == 3
func howManyTimes(string: String, substring: String) -> Int {
    var count = 0
    var index = 0
    while index < string.count {
        index = string.firstIndex(of: substring, options: .caseInsensitive, range: (index, string.count - index))
        if index == nil {
            break
        }
        count += 1
        index += substring.count
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 11. Write a function that takes a string and returns a new string with all the vowels removed.
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 12. Write a function that takes a string and returns a new string with all the vowels removed.
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 13. Write a function that takes a string and returns a new string with all the vowels removed.
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 14. Write a function that takes a string and returns a new string with all the vowels removed.
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 15. Write a function that takes a string and returns a new string with all the vowels removed.
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 16. Write a function that takes a string and returns a new string with all the vowels removed.
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 17. Write a function that takes a string and returns a new string with all the vowels removed.
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 18. Write a function that takes a string and returns a new string with all the vowels removed.
// ----------------------------------------------------------------------------------------------------------------------

// 
index = string.firstIndex(of: substring, options: .caseInsensitive, range: (index, string.count - index)) // cannot convert value of type 'String' to expected argument type 'String.Element' (aka 'Character')
index = string.firstIndex(of: substring, options: .caseInsensitive, range: (index, string.count - index)) // cannot infer contextual base in reference to member 'caseInsensitive'
index = string.firstIndex(of: substring, options: .caseInsensitive, range: (index, string.count - index)) // cannot assign value of type 'String.Index?' to type 'Int'
index = string.firstIndex(of: substring, options: .caseInsensitive, range: (index, string.count - index)) // extra arguments at positions #2, #3 in call
if index == nil { // comparing non-optional value of type 'Int' to 'nil' always returns false

func howManyTimes(string: String, substring: String) -> Int {
    var count = 0
    var index = 0
    while index < string.count {
        index = string.index(of: substring, in: string[..<index + substring.count])
        if index == nil {
            break
        }
        count += 1
        index += substring.count
    }
    return count
}
```swift
// Find how many times a given substring can be found in the original string. Count overlaping cases.
// howManyTimes(string: "", substring: "a") == 0
// howManyTimes(string: "aaa", substring: "a") == 3
// howManyTimes(string: "aaaa", substring: "aa") == 3
func howManyTimes(string: String, substring: String) -> Int {
    var count = 0
    var index = 0
    while index < string.count {
        index = string.index(of: substring, in: string[..<index + substring.count])
        if index == nil {
            break
        }
        count += 1
        index += substring.count
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------
// 1.1.1
// Given a string, return a new string that has transformed based on the input:
// Change case of every character, ie. lower case to upper case, upper case to lower case.
// Reverse the order of words from the input.
// Note: You will have to handle multiple spaces, and leading/trailing spaces.
//
// For example:
// "Example Input" ==> "iNPUT eXAMPLE"
// "This is a test" ==> "tSET tEST IS hHI"
// "   space here   " ==> "SPACE HERE   "
// "   spaces here    " ==> "sPACES HERE    "
//
// Solution:
// 1. Split the string into words.
// 2. Reverse the order of the words.
// 3. Change the case of the words.
// 4. Join the words back into a string.
//
// ----------------------------------------------------------------------------------------------------------------------
// 1.1.2
// Given a string and a non-negative number, return a larger string that is n copies of the original string.
//
// Example:
// stringTimes("Hi", 2) == "HiHi"
// stringTimes("Hi", 3) == "HiHiHi"
// stringTimes("Hi", 1) == "Hi"
//
// Solution:
// 1. Split the string into words.
// 2. Join the words back into a string.
//
// ----------------------------------------------------------------------------------------------------------------------
// 1.1.3
// Given a string, return true if the number of appearances of "is" anywhere in the string is equal to the number of appearances of "not" anywhere in the string (case sensitive).
//
// Example:
//
// isNotNotIsNot("not not is not") → true
// isNotNotIsNot("is not is not") → false
// isNotNotIsNot("is is not not") → false
//
// Solution:
// 1. Split the string into words.
// 2. Count the number of "is" and "not" words.
// 3. Return true if the counts are equal.
//
// ----------------------------------------------------------------------------------------------------------------------
// 1.1.4
// Given a string, return the number of times that a substring appears in the string, without the substring being counted multiple times.
// (It's ok if the substring appears multiple times in the string.)
//
// Example:
//
// substrCount("aba") → 2
// substrCount("abab") → 4
// substrCount("abcabcabc") → 9
//
// Solution:
// 1. Split the string into words.
// 2. Count the number of times each word appears.
// 3. Return the sum of the counts.
//
// ----------------------------------------------------------------------------------------------------------------------
// 1.1.5
// Given a string, return the length of the largest "block" in the string.
// A block is a run of adjacent chars that are the same.
//
// Example:
//
// maxBlock("hoopla") → 2
// maxBlock("abbCCCddBBBxx")
index = string.index(of: substring, in: string[..<index + substring.count]) // cannot assign value of type 'String.Index?' to type 'Int'
index = string.index(of: substring, in: string[..<index + substring.count]) // cannot convert value of type 'String' to expected argument type 'String.Element' (aka 'Character')
index = string.index(of: substring, in: string[..<index + substring.count]) // extra argument 'in' in call
index = string.index(of: substring, in: string[..<index + substring.count]) // cannot convert value of type 'PartialRangeUpTo<Int>' to expected argument type 'Int'
if index == nil { // comparing non-optional value of type 'Int' to 'nil' always returns false

func howManyTimes(string: String, substring: String) -> Int {
    var count = 0
    var index = 0
    while index < string.count {
        index = string.firstIndex(of: substring, options: .caseInsensitive, range: (index, string.count - index))
        if index == nil {
            break
        }
        count += 1
        index += substring.count
    }
    return count
}
```swift
// Find how many times a given substring can be found in the original string. Count overlaping cases.
// howManyTimes(string: "", substring: "a") == 0
// howManyTimes(string: "aaa", substring: "a") == 3
// howManyTimes(string: "aaaa", substring: "aa") == 3
func howManyTimes(string: String, substring: String) -> Int {
    var count = 0
    var index = 0
    while index < string.count {
        index = string.firstIndex(of: substring, options: .caseInsensitive, range: (index, string.count - index))
        if index == nil {
            break
        }
        count += 1
        index += substring.count
    }
    return count
}

// 2. Write a function that takes a string and returns a string with the letters in alphabetical order.
// alphabetize("hello") == "ehllo"
// alphabetize("") == ""
// alphabetize("a") == "a"
// alphabetize("abc") == "abc"
// alphabetize("bob") == "bba"
// alphabetize("zoo") == "ooz"
// alphabetize("aardvark") == "aaarrdddvvvkkkzzz"
// alphabetize("zooom") == "oomz"
// alphabetize("zooomm") == "oommz"
// alphabetize("zoooomm") == "oommzoo"
// alphabetize("zoooommoo") == "oommzoooom"
// alphabetize("zoooommooz") == "oommzoooomz"
// alphabetize("zoooommoozoo") == "oommzoooomzoo"
// alphabetize("zoooommoozooom") == "oommzoooomzooom"
// alphabetize("zoooommoozooomm") == "oommzoooomzooomm"
// alphabetize("zoooommoozooommz") == "oommzoooomzooommz"
// alphabetize("zoooommoozooommzz") == "oommzoooomzooommzz"
// alphabetize("zoooommoozooommzzz" == "oommzoooomzooommzzz"
// alphabetize("zoooommoozooommzzzz" == "oommzoooomzooommzzzz"
// alphabetize("zoooommoozooommzzzzz" == "oommzoooomzooommzzzzz"
// alphabetize("zoooommoozooommzzzzzz" == "oommzoooomzooommzzzzzz"
// alphabetize("zoooommoozooommzzzzzzz" == "oommzoooomzooommzzzzzzz"
// alphabetize("zoooommoozooommzzzzzzzz" == "oommzoooomzooommzzzzzzzz"
// alphabetize("zoooommoozooommzzzzzzzzz" == "oommzoooomzooommzzzzzzzzz"
// alphabetize("zoooommoozooommzzzzzzzzzz" == "oommzoooomzooommzzzzzzzzzz"
// alphabetize("zoooommoozooommzzzzzzzzzzz" == "oommzoooomzooommzzzzzzzzzzz"
// alphabetize("zoooommoozooommzzzzzzzzzzzz" == "oommzoooomzooommzzzzzzzzzzzz"
// alphabetize("zoooommoozooommzzzzzzzzzzzzz" == "oommzoooomzooommzzzzzzzzzzzzz"
// alphabetize("zoooommoozooommzzzzzzzzzzzzzz" == "oommzoooomzooommzzzzzzzzzzzzzz"
// alphabetize("zoooommoozooommzzzzzzzzzzzzzzz" == "oommzoooomzooommzzzzzzzzzzzzzzz"
// alphabetize("zoooommoozooommzzzzzzzzzzzzzzzz" == "oommzoooomzooommzzzzzzzzzzzzzzzz"
// alphabetize("zoooommoozooommzzzzzzzzzzzzzzzzz" == "oommz
index = string.firstIndex(of: substring, options: .caseInsensitive, range: (index, string.count - index)) // cannot convert value of type 'String' to expected argument type 'String.Element' (aka 'Character')
index = string.firstIndex(of: substring, options: .caseInsensitive, range: (index, string.count - index)) // cannot infer contextual base in reference to member 'caseInsensitive'
index = string.firstIndex(of: substring, options: .caseInsensitive, range: (index, string.count - index)) // cannot assign value of type 'String.Index?' to type 'Int'
index = string.firstIndex(of: substring, options: .caseInsensitive, range: (index, string.count - index)) // extra arguments at positions #2, #3 in call
if index == nil { // comparing non-optional value of type 'Int' to 'nil' always returns false

func howManyTimes(string: String, substring: String) -> Int {
    let count = 0
    var index = 0
    while index < string.count {
        if string.index(of: substring, in: string[index...]) == index {
            count += 1
            index += substring.count
        } else {
            index += 1
        }
    }
    return count
}

func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

func isPalindrome(string: String) -> Bool {
    var left = 0
    var right = string.count - 1
    while left < right {
        if string[left] != string[right] {
            return false
        }
        left += 1
        right -= 1
    }
    return true
}
```swift
// Find how many times a given substring can be found in the original string. Count overlaping cases.
// howManyTimes(string: "", substring: "a") == 0
// howManyTimes(string: "aaa", substring: "a") == 3
// howManyTimes(string: "aaaa", substring: "aa") == 3
func howManyTimes(string: String, substring: String) -> Int {
    let count = 0
    var index = 0
    while index < string.count {
        if string.index(of: substring, in: string[index...]) == index {
            count += 1
            index += substring.count
        } else {
            index += 1
        }
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------
// 12. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I have a dog") == " hv dg"
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// 13. Write a function that takes a string and returns true if the string is a palindrome, and false otherwise.
// isPalindrome("racecar") == true
// isPalindrome("hello") == false
func isPalindrome(string: String) -> Bool {
    var left = 0
    var right = string.count - 1
    while left < right {
        if string[left] != string[right] {
            return false
        }
        left += 1
        right -= 1
    }
    return true
}

// ----------------------------------------------------------------------------------------------------------------------
// 14. Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels("I have a dog") == " hv dg"
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// 15. Write a function that takes a string and returns true if the string is a palindrome, and false otherwise.
// isPalindrome("racecar") == true
// isPalindrome("hello") == false
func isPalindrome(string: String) -> Bool {
    var left = 0
    var right = string.count - 1
    while left < right {
        if string[left] != string[right] {
            return false
        }
        left += 1
        right -= 1
    }
    return true
}

// ----------------------------------------------------------------------------------------------------------------------
// 16. Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels("I have a dog") == " hv dg"
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// 17. Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels("I have a dog") == " hv dg"
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char) {
if string.index(of: substring, in: string[index...]) == index { // cannot convert value of type 'String.Index?' to expected argument type 'Int'
if string.index(of: substring, in: string[index...]) == index { // cannot convert value of type 'String' to expected argument type 'String.Element' (aka 'Character')
if string.index(of: substring, in: string[index...]) == index { // extra argument 'in' in call
count += 1 // left side of mutating operator isn't mutable: 'count' is a 'let' constant
if !isVowel(char) { // cannot find 'isVowel' in scope
result += char // cannot convert value of type 'Character' to expected argument type 'String'
if string[left] != string[right] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if string[left] != string[right] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.

func howManyTimes(string: String, substring: String) -> Int {
    let count = 0
    let index = 0
    while index < string.count {
        if string[index...].contains(substring) {
            count += 1
            index += substring.count
        } else {
            index += 1
        }
    }
    return count
}
```swift
// Find how many times a given substring can be found in the original string. Count overlaping cases.
// howManyTimes(string: "", substring: "a") == 0
// howManyTimes(string: "aaa", substring: "a") == 3
// howManyTimes(string: "aaaa", substring: "aa") == 3
func howManyTimes(string: String, substring: String) -> Int {
    let count = 0
    let index = 0
    while index < string.count {
        if string[index...].contains(substring) {
            count += 1
            index += substring.count
        } else {
            index += 1
        }
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
if string[index...].contains(substring) { // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.
count += 1 // left side of mutating operator isn't mutable: 'count' is a 'let' constant
index += substring.count // left side of mutating operator isn't mutable: 'index' is a 'let' constant
index += 1 // left side of mutating operator isn't mutable: 'index' is a 'let' constant

func howManyTimes(string: String, substring: String) -> Int {
    var count = 0
    var index = 0
    while index < string.count {
        if string[index...].contains(substring) {
            count += 1
            index += substring.count
        } else {
            index += 1
        }
    }
    return count
}
```swift
// Find how many times a given substring can be found in the original string. Count overlaping cases.
// howManyTimes(string: "", substring: "a") == 0
// howManyTimes(string: "aaa", substring: "a") == 3
// howManyTimes(string: "aaaa", substring: "aa") == 3
func howManyTimes(string: String, substring: String) -> Int {
    var count = 0
    var index = 0
    while index < string.count {
        if string[index...].contains(substring) {
            count += 1
            index += substring.count
        } else {
            index += 1
        }
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------
// 10. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("abcdefghijklmnopqrstuvwxyz") == "bcdfghjklmnpqrstvwxyz"
// removeVowels("") == ""
// removeVowels("aeiou") == ""
// removeVowels("aeiouAEIOU") == ""
// removeVowels("bcdfghjklmnpqrstvwxyz") == "bcdfghjklmnpqrstvwxyz"
// removeVowels("bcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyz") == "bcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyz"
// removeVowels("bcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyz") == "bcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyz"
// removeVowels("bcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyz") == "bcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyz"
// removeVowels("bcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyz") == "bcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyz"
// removeVowels("bcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqrstvwxyzBcdfghjklmnpqr
if string[index...].contains(substring) { // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.

func howManyTimes(string: String, substring: String) -> Int {
    let count = 0
    let index = 0
    while index < string.count {
        let nextIndex = string.index(of: substring, in: string[index...])
        if nextIndex == nil {
            break
        }
        count += 1
        index = nextIndex!
    }
    return count
}

func reverseString(string: String) -> String {
    return string.reversed().join()
}

func swapCase(string: String) -> String {
    return string.map {
        if $0.isUpperCase {
            return $0.lowercased
        } else {
            return $0.uppercased
        }
    }.join()
}

func trim(string: String) -> String {
    return string.trim()
}

func trimWhitespace(string: String) -> String {
    return string.trim()
}
```swift
// Find how many times a given substring can be found in the original string. Count overlaping cases.
// howManyTimes(string: "", substring: "a") == 0
// howManyTimes(string: "aaa", substring: "a") == 3
// howManyTimes(string: "aaaa", substring: "aa") == 3
func howManyTimes(string: String, substring: String) -> Int {
    let count = 0
    let index = 0
    while index < string.count {
        let nextIndex = string.index(of: substring, in: string[index...])
        if nextIndex == nil {
            break
        }
        count += 1
        index = nextIndex!
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 2.1.2
// ----------------------------------------------------------------------------------------------------------------------

// Write a function that takes a string as input and returns the string reversed.
// reverseString("hello") == "olleh"
// reverseString("") == ""
func reverseString(string: String) -> String {
    return string.reversed().join()
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 2.1.3
// ----------------------------------------------------------------------------------------------------------------------

// Write a function that takes a string as input and returns the string with all uppercase characters replaced with lowercase characters and vice versa.
// swapCase("Hello, World!") == "hELLO, wORLD!"
// swapCase("") == ""
func swapCase(string: String) -> String {
    return string.map {
        if $0.isUpperCase {
            return $0.lowercased
        } else {
            return $0.uppercased
        }
    }.join()
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 2.1.4
// ----------------------------------------------------------------------------------------------------------------------

// Write a function that takes a string as input and returns the string with leading and trailing spaces removed.
// trim("  Hello, World!  ") == "Hello, World!"
// trim("") == ""
func trim(string: String) -> String {
    return string.trim()
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 2.1.5
// ----------------------------------------------------------------------------------------------------------------------

// Write a function that takes a string as input and returns the string with leading and trailing whitespace removed.
// trimWhitespace("  Hello, World!  ") == "Hello, World!"
// trimWhitespace("") == ""
func trimWhitespace(string: String) -> String {
    return string.trim()
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 2.1.6
// ----------------------------------------------------------------------------------------------------------------------

// Write a function that takes a string as input and returns the string with leading and trailing whitespace removed.
// trimWhitespace("  Hello, World!  ") == "Hello, World!"
// trimWhitespace("") == ""
func trimWhitespace(string: String) -> String {
    return string.trim()
}

// ---------------------
let nextIndex = string.index(of: substring, in: string[index...]) // extra argument 'in' in call
let nextIndex = string.index(of: substring, in: string[index...]) // cannot convert value of type 'String' to expected argument type 'String.Element' (aka 'Character')
count += 1 // left side of mutating operator isn't mutable: 'count' is a 'let' constant
index = nextIndex! // cannot assign to value: 'index' is a 'let' constant
return string.reversed().join() // reference to member 'join' cannot be resolved without a contextual type
if $0.isUpperCase { // value of type 'String.Element' (aka 'Character') has no member 'isUpperCase'
}.join() // value of type 'Array<_>' has no member 'join'
return string.trim() // value of type 'String' has no member 'trim'
return string.trim() // value of type 'String' has no member 'trim'

func howManyTimes(string: String, substring: String) -> Int {
    let count = 0
    var index = 0
    while index < string.count {
        index = string.firstIndex(of: substring, options: .ignoreCase, range: (index ... string.count), containing: true)
        if index == nil {
            break
        }
        count += 1
        index += substring.count
    }
    return count
}

func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}
```swift
// Find how many times a given substring can be found in the original string. Count overlaping cases.
// howManyTimes(string: "", substring: "a") == 0
// howManyTimes(string: "aaa", substring: "a") == 3
// howManyTimes(string: "aaaa", substring: "aa") == 3
func howManyTimes(string: String, substring: String) -> Int {
    let count = 0
    var index = 0
    while index < string.count {
        index = string.firstIndex(of: substring, options: .ignoreCase, range: (index ... string.count), containing: true)
        if index == nil {
            break
        }
        count += 1
        index += substring.count
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 10. Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels("") == ""
// removeVowels("abcdefghijklmnopqrstuvwxyz") == "bcdfghjklmnpqrstvwxyz"
// removeVowels("abracadabra") == "brcdbrkr"
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 11. Write a function that takes a string and returns true if the string is a palindrome, and false otherwise.
// isPalindrome("") == true
// isPalindrome("a") == true
// isPalindrome("ab") == false
// isPalindrome("aba") == true
// isPalindrome("abba") == true
// isPalindrome("abccba") == true
// isPalindrome("abccd") == false
// isPalindrome("abccdba") == true
// isPalindrome("abccddba") == true
// isPalindrome("abccdddba") == true
// isPalindrome("abccdddba") == true
// isPalindrome("abccdddba") == true
// isPalindrome("abccdddba") == true
// isPalindrome("abccdddba") == true
// isPalindrome("abccdddba") == true
// isPalindrome("abccdddba") == true
// isPalindrome("abccdddba") == true
// isPalindrome("abccdddba") == true
// isPalindrome("abccdddba") == true
// isPalindrome("abccdddba") == true
// isPalindrome("abccdddba") == true
// isPalindrome("abccdddba") == true
// isPalindrome("abccdddba") == true
// isPalindrome("abccdddba") == true
// isPalindrome("abccdddba") == true
// isPalindrome("abccdddba") == true
// isPalindrome("abccdddba") == true
// isPalindrome("abccdddba") == true
// isPalindrome("abccdddba") == true
// isPalindrome("abccdddba") == true
// isPalindrome("abccdddba") == true
// isPalindrome("abccdddba") == true
// isPalindrome("abccdddba") == true
// isPalindrome("abccdddba") == true
// isPalindrome("abccdddba") == true
// isPalindrome("abccdddba") == true
// isPalindrome("abccdddba") == true
// isPalindrome("abccdddba") == true
// isPalindrome("abccdddba") == true
// isPalindrome("abcc
index = string.firstIndex(of: substring, options: .ignoreCase, range: (index ... string.count), containing: true) // cannot convert value of type 'String' to expected argument type 'String.Element' (aka 'Character')
index = string.firstIndex(of: substring, options: .ignoreCase, range: (index ... string.count), containing: true) // cannot infer contextual base in reference to member 'ignoreCase'
index = string.firstIndex(of: substring, options: .ignoreCase, range: (index ... string.count), containing: true) // cannot assign value of type 'String.Index?' to type 'Int'
index = string.firstIndex(of: substring, options: .ignoreCase, range: (index ... string.count), containing: true) // extra arguments at positions #2, #3, #4 in call
if index == nil { // comparing non-optional value of type 'Int' to 'nil' always returns false
count += 1 // left side of mutating operator isn't mutable: 'count' is a 'let' constant
if !isVowel(char) { // cannot find 'isVowel' in scope
result += char // cannot convert value of type 'Character' to expected argument type 'String'

func sortNumbers(numbers: String) -> String {
    let sorted = numbers.split(separator: " ").sorted()
    return String(sorted)
}
```swift
// Input is a space-delimited string of numberals from 'zero' to 'nine'.
// Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'.
// Return the string with numbers sorted from smallest to largest
// sortNumbers(numbers: "three one five") == "one three five"
func sortNumbers(numbers: String) -> String {
    let sorted = numbers.split(separator: " ").sorted()
    return String(sorted)
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
return String(sorted) // no exact matches in call to initializer

func sortNumbers(numbers: String) -> String {
    let sorted = numbers.split(separator: " ").sorted()
    return String(sorted)
}
```swift
// Input is a space-delimited string of numberals from 'zero' to 'nine'.
// Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'.
// Return the string with numbers sorted from smallest to largest
// sortNumbers(numbers: "three one five") == "one three five"
func sortNumbers(numbers: String) -> String {
    let sorted = numbers.split(separator: " ").sorted()
    return String(sorted)
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
return String(sorted) // no exact matches in call to initializer

func sortNumbers(numbers: String) -> String {
    let nums = numbers.split(separator: " ").map { Int($0) }
    return String(nums.sorted())
}
```swift
// Input is a space-delimited string of numberals from 'zero' to 'nine'.
// Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'.
// Return the string with numbers sorted from smallest to largest
// sortNumbers(numbers: "three one five") == "one three five"
func sortNumbers(numbers: String) -> String {
    let nums = numbers.split(separator: " ").map { Int($0) }
    return String(nums.sorted())
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
return String(nums.sorted()) // no exact matches in call to initializer
return String(nums.sorted()) // referencing instance method 'sorted()' on 'Sequence' requires that 'Int?' conform to 'Comparable'

func sortNumbers(numbers: String) -> String {
    let sortedNumbers = numbers.split(separator: " ").sorted()
    return String(sortedNumbers)
}
```swift
// Input is a space-delimited string of numberals from 'zero' to 'nine'.
// Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'.
// Return the string with numbers sorted from smallest to largest
// sortNumbers(numbers: "three one five") == "one three five"
func sortNumbers(numbers: String) -> String {
    let sortedNumbers = numbers.split(separator: " ").sorted()
    return String(sortedNumbers)
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
return String(sortedNumbers) // no exact matches in call to initializer

func sortNumbers(numbers: String) -> String {
    let sortedNumbers = numbers.split(separator: " ").sorted()
    return String(sortedNumbers)
}
```swift
// Input is a space-delimited string of numberals from 'zero' to 'nine'.
// Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'.
// Return the string with numbers sorted from smallest to largest
// sortNumbers(numbers: "three one five") == "one three five"
func sortNumbers(numbers: String) -> String {
    let sortedNumbers = numbers.split(separator: " ").sorted()
    return String(sortedNumbers)
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
return String(sortedNumbers) // no exact matches in call to initializer

func sortNumbers(numbers: String) -> String {
    let sorted = numbers.split(separator: " ").sorted()
    return sorted.map { $0 }.joined(separator: " ")
}
```swift
// Input is a space-delimited string of numberals from 'zero' to 'nine'.
// Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'.
// Return the string with numbers sorted from smallest to largest
// sortNumbers(numbers: "three one five") == "one three five"
func sortNumbers(numbers: String) -> String {
    let sorted = numbers.split(separator: " ").sorted()
    return sorted.map { $0 }.joined(separator: " ")
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // XCTAssertTrue failed

func sortNumbers(numbers: String) -> String {
    let sortedNumbers = numbers.split(separator: " ").sorted()
    return sortedNumbers.map { $0 }.joined(separator: " ")
}
```swift
// Input is a space-delimited string of numberals from 'zero' to 'nine'.
// Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'.
// Return the string with numbers sorted from smallest to largest
// sortNumbers(numbers: "three one five") == "one three five"
func sortNumbers(numbers: String) -> String {
    let sortedNumbers = numbers.split(separator: " ").sorted()
    return sortedNumbers.map { $0 }.joined(separator: " ")
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // XCTAssertTrue failed

func sortNumbers(numbers: String) -> String {
    let sortedNumbers = numbers.split(separator: " ").sorted()
    return sortedNumbers.joined(separator: " ")
}
```swift
// Input is a space-delimited string of numberals from 'zero' to 'nine'.
// Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'.
// Return the string with numbers sorted from smallest to largest
// sortNumbers(numbers: "three one five") == "one three five"
func sortNumbers(numbers: String) -> String {
    let sortedNumbers = numbers.split(separator: " ").sorted()
    return sortedNumbers.joined(separator: " ")
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // XCTAssertTrue failed

func sortNumbers(numbers: String) -> String {
    let sorted = numbers.split(separator: " ").sorted()
    return sorted.map { $0 }.joined(separator: " ")
}
```swift
// Input is a space-delimited string of numberals from 'zero' to 'nine'.
// Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'.
// Return the string with numbers sorted from smallest to largest
// sortNumbers(numbers: "three one five") == "one three five"
func sortNumbers(numbers: String) -> String {
    let sorted = numbers.split(separator: " ").sorted()
    return sorted.map { $0 }.joined(separator: " ")
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // XCTAssertTrue failed

func sortNumbers(numbers: String) -> String {
    let sortedNumbers = numbers.split(separator: " ").sorted()
    return sortedNumbers.joined(separator: " ")
}
```swift
// Input is a space-delimited string of numberals from 'zero' to 'nine'.
// Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'.
// Return the string with numbers sorted from smallest to largest
// sortNumbers(numbers: "three one five") == "one three five"
func sortNumbers(numbers: String) -> String {
    let sortedNumbers = numbers.split(separator: " ").sorted()
    return sortedNumbers.joined(separator: " ")
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // XCTAssertTrue failed

func findClosestElements(numbers: [Double]) -> (Double, Double) {
    var min = Double.infinity
    var min1 = Double.infinity
    var min2 = Double.infinity
    var min3 = Double.infinity
    for i in 0..<numbers.count {
        if numbers[i] < min {
            min3 = min2
            min2 = min1
            min1 = min
            min = numbers[i]
        } else if numbers[i] < min1 {
            min3 = min2
            min2 = min1
            min1 = numbers[i]
        } else if numbers[i] < min2 {
            min3 = min2
            min2 = numbers[i]
        } else if numbers[i] < min3 {
            min3 = numbers[i]
        }
    }
    return (min, min3)
}

func mostFrequentCharacter(string: String) -> String {
    var count = [Int](repeating: 0, count: 256)
    for i in string.utf8.map {
        count[i] += 1
    }
    var max = 0
    var maxChar = ""
    for i in 0..<count.count {
        if count[i] > max {
            max = count[i]
            maxChar = String(c: i)
        }
    }
    return maxChar
}

func isPalindrome(string: String) -> Bool {
    var reversed = ""
    for i in string.reversed() {
        reversed += i
    }
    return string == reversed
}

func leastFrequentCharacter(string: String) -> String {
    var count = [Int](repeating: 0, count: 256)
    for i in string.utf8.map {
        count[i] += 1
    }
    var min = Int.max
    var minChar = ""
    for i in 0..<count.count {
        if count[i] < min {
            min = count[i]
            minChar = String(c: i)
        }
    }
    return minChar
}
```swift
// From a supplied array of numbers (of length at least two) select and return two that are the closest to each
// other and return them in order (smaller number, larger number).
// findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.2]) == (2.0, 2.2)
// findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.0]) == (2.0, 2.0)
func findClosestElements(numbers: [Double]) -> (Double, Double) {
    var min = Double.infinity
    var min1 = Double.infinity
    var min2 = Double.infinity
    var min3 = Double.infinity
    for i in 0..<numbers.count {
        if numbers[i] < min {
            min3 = min2
            min2 = min1
            min1 = min
            min = numbers[i]
        } else if numbers[i] < min1 {
            min3 = min2
            min2 = min1
            min1 = numbers[i]
        } else if numbers[i] < min2 {
            min3 = min2
            min2 = numbers[i]
        } else if numbers[i] < min3 {
            min3 = numbers[i]
        }
    }
    return (min, min3)
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 10. Write a function that takes a string as a parameter and returns the letter that appears the most
// often.
// mostFrequentCharacter("abracadabra") == "a"
func mostFrequentCharacter(string: String) -> String {
    var count = [Int](repeating: 0, count: 256)
    for i in string.utf8.map {
        count[i] += 1
    }
    var max = 0
    var maxChar = ""
    for i in 0..<count.count {
        if count[i] > max {
            max = count[i]
            maxChar = String(c: i)
        }
    }
    return maxChar
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 11. Write a function that takes a string as a parameter and returns true if the string is a palindrome,
// false otherwise.
// isPalindrome("abba") == true
// isPalindrome("abab") == false
func isPalindrome(string: String) -> Bool {
    var reversed = ""
    for i in string.reversed() {
        reversed += i
    }
    return string == reversed
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 12. Write a function that takes a string as a parameter and returns the letter that appears the least
// often.
// leastFrequentCharacter("abracadabra") == "a"
func leastFrequentCharacter(string: String) -> String {
    var count = [Int](repeating: 0, count: 256)
    for i in string.utf8.map {
        count[i] += 1
    }
    var min = Int.max
    var minChar = ""
    for i in 0..<count.count {
        if count[i] < min {
            min = count[i]
            minChar = String(c: i)
        }
    }
    return minChar
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 13. Write a function that takes a string as a parameter and returns the letter that appears the most
// often.
// mostFrequentCharacter("abracadabra") == "a"
func mostFrequentCharacter(string: String) -> String {
    var count = [Int](repeating: 0, count: 256)
    for i in string.utf8.map {
        count[i] += 1
    }
    var max = 0
    var maxChar = ""
    for i in 0..<count.count {
        if count[i] > max {
            max = count[i]
            maxChar = String(c: i)
        }
for i in string.utf8.map { // for-in loop requires '((String.UTF8View.Element) throws -> T) throws -> [T]' (aka '((UInt8) throws -> T) throws -> Array<T>') to conform to 'Sequence'
for i in string.utf8.map { // generic parameter 'T' could not be inferred
maxChar = String(c: i) // no exact matches in call to initializer
reversed += i // cannot convert value of type 'String.Element' (aka 'Character') to expected argument type 'String'
for i in string.utf8.map { // for-in loop requires '((String.UTF8View.Element) throws -> T) throws -> [T]' (aka '((UInt8) throws -> T) throws -> Array<T>') to conform to 'Sequence'
for i in string.utf8.map { // generic parameter 'T' could not be inferred
minChar = String(c: i) // no exact matches in call to initializer

func findClosestElements(numbers: [Double]) -> (Double, Double) {
    let sorted = numbers.sorted()
    let first = sorted[0]
    let last = sorted.last!
    let diff = first - last
    let index = sorted.firstIndex(of: first)
    let result = sorted[index!]
    let result2 = sorted[index! + 1]
    return (result, result2)
}

func everyOtherCharacter(string: String) -> String {
    let result = ""
    for i in 0..<string.count {
        if i % 2 == 0 {
            result += string[i]
        }
    }
    return result
}
```swift
// From a supplied array of numbers (of length at least two) select and return two that are the closest to each
// other and return them in order (smaller number, larger number).
// findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.2]) == (2.0, 2.2)
// findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.0]) == (2.0, 2.0)
func findClosestElements(numbers: [Double]) -> (Double, Double) {
    let sorted = numbers.sorted()
    let first = sorted[0]
    let last = sorted.last!
    let diff = first - last
    let index = sorted.firstIndex(of: first)
    let result = sorted[index!]
    let result2 = sorted[index! + 1]
    return (result, result2)
}

// ----------------------------------------------------------------------------------------------------------------------

// 1.2.1.1
// Write a function that takes a string as an argument and returns a new string that contains every other character in the
// original string.
// everyOtherCharacter("Codecademy") == "Cdmdm"
// everyOtherCharacter("Hello world!") == "Hlo wrd!"
func everyOtherCharacter(string: String) -> String {
    let result = ""
    for i in 0..<string.count {
        if i % 2 == 0 {
            result += string[i]
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// 1.2.1.2
// Write a function that takes a string as an argument and returns a new string that contains every other character in the
// original string.
// everyOtherCharacter("Codecademy") == "Cdmdm"
// everyOtherCharacter("Hello world!") == "Hlo wrd!"
func everyOtherCharacter(string: String) -> String {
    let result = ""
    for i in 0..<string.count {
        if i % 2 == 0 {
            result += string[i]
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// 1.2.1.3
// Write a function that takes a string as an argument and returns a new string that contains every other character in the
// original string.
// everyOtherCharacter("Codecademy") == "Cdmdm"
// everyOtherCharacter("Hello world!") == "Hlo wrd!"
func everyOtherCharacter(string: String) -> String {
    let result = ""
    for i in 0..<string.count {
        if i % 2 == 0 {
            result += string[i]
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// 1.2.1.4
// Write a function that takes a string as an argument and returns a new string that contains every other character in the
// original string.
// everyOtherCharacter("Codecademy") == "Cdmdm"
// everyOtherCharacter("Hello world!") == "Hlo wrd!"
func everyOtherCharacter(string: String) -> String {
    let result = ""
    for i in 0..<string.count {
        if i % 2 == 0 {
            result += string[i]
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// 1.2.1.5
// Write a function that takes a string as an argument and returns a new string that contains every other character in the
// original string.
// everyOtherCharacter("Codecademy") == "Cdmdm"
// everyOtherCharacter("Hello world!") == "Hlo wrd!"
func everyOtherCharacter(string: String) -> String {
    let result = ""
    for i in 0..<string.count {
        if i % 2 == 0 {
            result += string[i]
        }
    }
let diff = first - last // initialization of immutable value 'diff' was never used; consider replacing with assignment to '_' or removing it
result += string[i] // no exact matches in call to subscript

func findClosestElements(numbers: [Double]) -> (Double, Double) {
    var min = Double.infinity
    var min1 = Double.infinity
    var min2 = Double.infinity
    var min3 = Double.infinity
    for i in numbers {
        if i < min {
            min3 = min2
            min2 = min1
            min1 = min
            min = i
        } else if i < min1 {
            min3 = min2
            min2 = min1
            min1 = i
        } else if i < min2 {
            min3 = min2
            min2 = i
        } else if i < min3 {
            min3 = i
        }
    }
    return (min, min3)
}
```swift
// From a supplied array of numbers (of length at least two) select and return two that are the closest to each
// other and return them in order (smaller number, larger number).
// findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.2]) == (2.0, 2.2)
// findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.0]) == (2.0, 2.0)
func findClosestElements(numbers: [Double]) -> (Double, Double) {
    var min = Double.infinity
    var min1 = Double.infinity
    var min2 = Double.infinity
    var min3 = Double.infinity
    for i in numbers {
        if i < min {
            min3 = min2
            min2 = min1
            min1 = min
            min = i
        } else if i < min1 {
            min3 = min2
            min2 = min1
            min1 = i
        } else if i < min2 {
            min3 = min2
            min2 = i
        } else if i < min3 {
            min3 = i
        }
    }
    return (min, min3)
}

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------
 // XCTAssertTrue failed

func findClosestElements(numbers: [Double]) -> (Double, Double) {
    var minDiff = Double.infinity
    var minDiffPair: (Double, Double) = (Double.infinity, Double.infinity)
    for i in 0..<numbers.count-1 {
        for j in i+1..<numbers.count {
            let diff = abs(numbers[i] - numbers[j])
            if diff < minDiff {
                minDiff = diff
                minDiffPair = (numbers[i], numbers[j])
            }
        }
    }
    return minDiffPair
}

func reverseString(s: String) -> String {
    return String(s.reversed())
}

func countOnes(n: Int) -> Int {
    var count = 0
    while n > 0 {
        count += n & 1
        n >>= 1
    }
    return count
}

func countOnesUnsigned(n: UInt) -> Int {
    var count = 0
    while n > 0 {
        count += n & 1
        n >>= 1
    }
    return count
}
```swift
// From a supplied array of numbers (of length at least two) select and return two that are the closest to each
// other and return them in order (smaller number, larger number).
// findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.2]) == (2.0, 2.2)
// findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.0]) == (2.0, 2.0)
func findClosestElements(numbers: [Double]) -> (Double, Double) {
    var minDiff = Double.infinity
    var minDiffPair: (Double, Double) = (Double.infinity, Double.infinity)
    for i in 0..<numbers.count-1 {
        for j in i+1..<numbers.count {
            let diff = abs(numbers[i] - numbers[j])
            if diff < minDiff {
                minDiff = diff
                minDiffPair = (numbers[i], numbers[j])
            }
        }
    }
    return minDiffPair
}

// 1.1.11
// Write a function that takes a string as input and returns the string reversed.
// Example:
// Given s = "hello", return "olleh".
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// 1.1.12
// Write a function that takes an integer and returns the number of 1 bits it has.
// Example:
// The 32-bit integer 11 has binary representation
// 00000000000000000000000000001011
// so the function should return 3.
func countOnes(n: Int) -> Int {
    var count = 0
    while n > 0 {
        count += n & 1
        n >>= 1
    }
    return count
}

// 1.1.13
// Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).
// Example:
// The 32-bit integer ’11' has binary representation
// 00000000000000000000000000001011, so the function should return 3.
func countOnesUnsigned(n: UInt) -> Int {
    var count = 0
    while n > 0 {
        count += n & 1
        n >>= 1
    }
    return count
}

// 1.1.14
// Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).
// Example:
// The 32-bit integer ’11' has binary representation
// 00000000000000000000000000001011, so the function should return 3.
func countOnesUnsigned(n: UInt) -> Int {
    var count = 0
    while n > 0 {
        count += n & 1
        n >>= 1
    }
    return count
}

// 1.1.15
// Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).
// Example:
// The 32-bit integer ’11' has binary representation
// 00000000000000000000000000001011, so the function should return 3.
func countOnesUnsigned(n: UInt) -> Int {
    var count = 0
    while n > 0 {
        count += n & 1
        n >>= 1
    }
    return count
}

// 1.1.16
// Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).
// Example:
// The 32-bit integer ’11' has binary representation
// 00000000000000000000000000001011, so the function should return 3.
func countOnesUnsigned(n: UInt) -> Int {
    var count = 0
    while n > 0 {
        count += n & 1
        n >>= 1
    }
    return count
}

// 1.1.17
// Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight
n >>= 1 // left side of mutating operator isn't mutable: 'n' is a 'let' constant
count += n & 1 // cannot convert value of type 'UInt' to expected argument type 'Int'
n >>= 1 // left side of mutating operator isn't mutable: 'n' is a 'let' constant

func findClosestElements(numbers: [Double]) -> (Double, Double) {
    var minDiff = Double.infinity
    var minDiffPair: (Double, Double) = (Double.infinity, Double.infinity)
    for i in 0..<numbers.count - 1 {
        for j in i + 1..<numbers.count {
            let diff = abs(numbers[i] - numbers[j])
            if diff < minDiff {
                minDiff = diff
                minDiffPair = (numbers[i], numbers[j])
            }
        }
    }
    return minDiffPair
}
```swift
// From a supplied array of numbers (of length at least two) select and return two that are the closest to each
// other and return them in order (smaller number, larger number).
// findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.2]) == (2.0, 2.2)
// findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.0]) == (2.0, 2.0)
func findClosestElements(numbers: [Double]) -> (Double, Double) {
    var minDiff = Double.infinity
    var minDiffPair: (Double, Double) = (Double.infinity, Double.infinity)
    for i in 0..<numbers.count - 1 {
        for j in i + 1..<numbers.count {
            let diff = abs(numbers[i] - numbers[j])
            if diff < minDiff {
                minDiff = diff
                minDiffPair = (numbers[i], numbers[j])
            }
        }
    }
    return minDiffPair
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 10. Write a function that takes a string as input and returns the string reversed.
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 11. Given an array of integers, return a new array with each value doubled.
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 12. Given two strings, a and b, create a bigger string made of the first char of a, the first char of b, the second char of a, the second char of b, and so on. Any leftover chars go at the end of the result.
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 13. Given a string, return a new string made of every other char starting with the first, so "Hello" yields "Hlo".
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 14. Given two strings, append them together (known as "concatenation") and return the result. However, if the strings are different lengths, omit chars from the longer string so it is the same length as the shorter string. So "Hello" and "Hi" yield "loHi". The strings may be any length.
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 15. Given a string, return a new string made of every other char starting with the first, so "Hello" yields "Hlo".
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 16. Given two strings, append them together (known as "concatenation") and return the result. However, if the strings are different lengths, omit chars from the longer string so it is the same length as the shorter string. So
 // XCTAssertTrue failed

func findClosestElements(numbers: [Double]) -> (Double, Double) {
    var minDiff = Double.infinity
    var minPair = (Double.infinity, Double.infinity)
    for i in 0..<numbers.count {
        for j in i+1..<numbers.count {
            let diff = abs(numbers[i] - numbers[j])
            if diff < minDiff {
                minDiff = diff
                minPair = (numbers[i], numbers[j])
            }
        }
    }
    return minPair
}
```swift
// From a supplied array of numbers (of length at least two) select and return two that are the closest to each
// other and return them in order (smaller number, larger number).
// findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.2]) == (2.0, 2.2)
// findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.0]) == (2.0, 2.0)
func findClosestElements(numbers: [Double]) -> (Double, Double) {
    var minDiff = Double.infinity
    var minPair = (Double.infinity, Double.infinity)
    for i in 0..<numbers.count {
        for j in i+1..<numbers.count {
            let diff = abs(numbers[i] - numbers[j])
            if diff < minDiff {
                minDiff = diff
                minPair = (numbers[i], numbers[j])
            }
        }
    }
    return minPair
}

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------
 // XCTAssertTrue failed

func findClosestElements(numbers: [Double]) -> (Double, Double) {
    var minDiff = Double.infinity
    var minDiffPair = (Double.infinity, Double.infinity)
    for i in 0..<numbers.count-1 {
        for j in i+1..<numbers.count {
            let diff = abs(numbers[i] - numbers[j])
            if diff < minDiff {
                minDiff = diff
                minDiffPair = (numbers[i], numbers[j])
            }
        }
    }
    return minDiffPair
}

func sumOfPositives(numbers: [Int]) -> Int {
    var sum = 0
    for number in numbers {
        if number > 0 {
            sum += number
        }
    }
    return sum
}

func largestDifference(numbers: [Int]) -> Int {
    var max = Int.min
    var min = Int.max
    for number in numbers {
        if number > max {
            max = number
        }
        if number < min {
            min = number
        }
    }
    return max - min
}

func mean(numbers: [Int]) -> Double {
    var sum = 0
    for number in numbers {
        sum += number
    }
    return Double(sum) / Double(numbers.count)
}

func median(numbers: [Int]) -> Double {
    var sortedNumbers = numbers.sorted()
    if sortedNumbers.count % 2 == 0 {
        return Double(sortedNumbers[sortedNumbers.count/2-1] + sortedNumbers[sortedNumbers.count/2]) / 2
    } else {
        return Double(sortedNumbers[sortedNumbers.count/2])
    }
}
```swift
// From a supplied array of numbers (of length at least two) select and return two that are the closest to each
// other and return them in order (smaller number, larger number).
// findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.2]) == (2.0, 2.2)
// findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.0]) == (2.0, 2.0)
func findClosestElements(numbers: [Double]) -> (Double, Double) {
    var minDiff = Double.infinity
    var minDiffPair = (Double.infinity, Double.infinity)
    for i in 0..<numbers.count-1 {
        for j in i+1..<numbers.count {
            let diff = abs(numbers[i] - numbers[j])
            if diff < minDiff {
                minDiff = diff
                minDiffPair = (numbers[i], numbers[j])
            }
        }
    }
    return minDiffPair
}

// ----------------------------------------------------------------------------------------------------------------------

// 2. Given an array of integers, return the sum of all the positive integers in the array.
// sumOfPositives([1, 2, 3, -1, -2, -3]) == 6
// sumOfPositives([-1, 2, 3, -1, -2, -3]) == 0
func sumOfPositives(numbers: [Int]) -> Int {
    var sum = 0
    for number in numbers {
        if number > 0 {
            sum += number
        }
    }
    return sum
}

// ----------------------------------------------------------------------------------------------------------------------

// 3. Given an array of integers, return the difference between the largest and smallest integers in the array.
// largestDifference([1, 2, 3, 4, 5]) == 4
// largestDifference([5, 4, 3, 2, 1]) == 4
func largestDifference(numbers: [Int]) -> Int {
    var max = Int.min
    var min = Int.max
    for number in numbers {
        if number > max {
            max = number
        }
        if number < min {
            min = number
        }
    }
    return max - min
}

// ----------------------------------------------------------------------------------------------------------------------

// 4. Given an array of integers, return the mean (average) of the integers.
// mean([1, 2, 3, 4, 5]) == 3
// mean([1, 2, 3, 4, 5, 6]) == 3.5
func mean(numbers: [Int]) -> Double {
    var sum = 0
    for number in numbers {
        sum += number
    }
    return Double(sum) / Double(numbers.count)
}

// ----------------------------------------------------------------------------------------------------------------------

// 5. Given an array of integers, return the median (middle) value of the integers.
// median([1, 2, 3, 4, 5]) == 3
// median([1, 2, 3, 4, 5, 6]) == 3.5
func median(numbers: [Int]) -> Double {
    var sortedNumbers = numbers.sorted()
    if sortedNumbers.count % 2 == 0 {
        return Double(sortedNumbers[sortedNumbers.count/2-1] + sortedNumbers[sortedNumbers.count/2]) / 2
    } else {
        return Double(sortedNumbers[sortedNumbers.count/2])
    }
}

// ----------------------------------------------------------------------------------------------------------------------

// 6. Given an array of integers, return the mode (most common number) of the integers.
// mode([1, 2, 3, 4, 5]) == 1
// mode([1, 2, 3, 4, 5, 6]) == 1
// mode([1, 2, 3, 3, 3, 4, 5]) == 3
func mode(numbers: [Int])
var sortedNumbers = numbers.sorted() // variable 'sortedNumbers' was never mutated; consider changing to 'let' constant
 // XCTAssertTrue failed

func findClosestElements(numbers: [Double]) -> (Double, Double) {
    var minDiff = Double.infinity
    var first = 0
    var second = 0
    for i in 0..<numbers.count {
        for j in i+1..<numbers.count {
            let diff = abs(numbers[i] - numbers[j])
            if diff < minDiff {
                minDiff = diff
                first = i
                second = j
            }
        }
    }
    return (numbers[first], numbers[second])
}

func findFirstUniqueChar(s: String) -> Int {
    var chars = [Character]()
    var counts = [Int]()
    for char in s {
        if !chars.contains(char) {
            chars.append(char)
            counts.append(1)
        } else {
            var index = chars.firstIndex(of: char)!
            counts[index] += 1
        }
    }
    for i in 0..<counts.count {
        if counts[i] == 1 {
            return i
        }
    }
    return -1
}
```swift
// From a supplied array of numbers (of length at least two) select and return two that are the closest to each
// other and return them in order (smaller number, larger number).
// findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.2]) == (2.0, 2.2)
// findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.0]) == (2.0, 2.0)
func findClosestElements(numbers: [Double]) -> (Double, Double) {
    var minDiff = Double.infinity
    var first = 0
    var second = 0
    for i in 0..<numbers.count {
        for j in i+1..<numbers.count {
            let diff = abs(numbers[i] - numbers[j])
            if diff < minDiff {
                minDiff = diff
                first = i
                second = j
            }
        }
    }
    return (numbers[first], numbers[second])
}

// ----------------------------------------------------------------------------------------------------------------------

// 1.2.3
// Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.
// s = "leetcode"
// findFirstUniqueChar(s: s) == 0
// s = "loveleetcode"
// findFirstUniqueChar(s: s) == 2
func findFirstUniqueChar(s: String) -> Int {
    var chars = [Character]()
    var counts = [Int]()
    for char in s {
        if !chars.contains(char) {
            chars.append(char)
            counts.append(1)
        } else {
            var index = chars.firstIndex(of: char)!
            counts[index] += 1
        }
    }
    for i in 0..<counts.count {
        if counts[i] == 1 {
            return i
        }
    }
    return -1
}

// ----------------------------------------------------------------------------------------------------------------------

// 1.2.4
// Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.
// s = "leetcode"
// findFirstUniqueChar(s: s) == 0
// s = "loveleetcode"
// findFirstUniqueChar(s: s) == 2
func findFirstUniqueChar(s: String) -> Int {
    var chars = [Character]()
    var counts = [Int]()
    for char in s {
        if !chars.contains(char) {
            chars.append(char)
            counts.append(1)
        } else {
            var index = chars.firstIndex(of: char)!
            counts[index] += 1
        }
    }
    for i in 0..<counts.count {
        if counts[i] == 1 {
            return i
        }
    }
    return -1
}

// ----------------------------------------------------------------------------------------------------------------------

// 1.2.5
// Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.
// s = "leetcode"
// findFirstUniqueChar(s: s) == 0
// s = "loveleetcode"
// findFirstUniqueChar(s: s) == 2
func findFirstUniqueChar(s: String) -> Int {
    var chars = [Character]()
    var counts = [Int]()
    for char in s {
        if !chars.contains(char) {
            chars.append(char)
            counts.append(1)
        } else {
            var index = chars.firstIndex(of: char)!
            counts[index] += 1
        }
    }
    for i in 0..<counts.count {
        if counts[i] == 1 {
            return i
        }
    }
    return -1
}

// ----------------------------------------------------------------------------------------------------------------------

// 1.2.6
// Given a string, find the first non-
var index = chars.firstIndex(of: char)! // variable 'index' was never mutated; consider changing to 'let' constant
 // XCTAssertTrue failed

func findClosestElements(numbers: [Double]) -> (Double, Double) {
    var minDiff = Double.infinity
    var minPair = (Double.infinity, Double.infinity)
    for i in 0..<numbers.count {
        for j in i+1..<numbers.count {
            let diff = abs(numbers[i] - numbers[j])
            if diff < minDiff {
                minDiff = diff
                minPair = (numbers[i], numbers[j])
            }
        }
    }
    return minPair
}
```swift
// From a supplied array of numbers (of length at least two) select and return two that are the closest to each
// other and return them in order (smaller number, larger number).
// findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.2]) == (2.0, 2.2)
// findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.0]) == (2.0, 2.0)
func findClosestElements(numbers: [Double]) -> (Double, Double) {
    var minDiff = Double.infinity
    var minPair = (Double.infinity, Double.infinity)
    for i in 0..<numbers.count {
        for j in i+1..<numbers.count {
            let diff = abs(numbers[i] - numbers[j])
            if diff < minDiff {
                minDiff = diff
                minPair = (numbers[i], numbers[j])
            }
        }
    }
    return minPair
}

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------
 // XCTAssertTrue failed

func findClosestElements(numbers: [Double]) -> (Double, Double) {
    let sortedNumbers = numbers.sorted()
    let first = sortedNumbers[0]
    let last = sortedNumbers[sortedNumbers.count - 1]
    let middle = sortedNumbers[sortedNumbers.count / 2]
    let distanceToFirst = abs(first - middle)
    let distanceToLast = abs(last - middle)
    if distanceToFirst < distanceToLast {
        return (first, last)
    } else {
        return (last, first)
    }
}

func reverseString(s: String) -> String {
    return String(s.reversed())
}

func singleNumber(nums: [Int]) -> Int {
    return nums.reduce(0, { acc, num in
        acc ^ num
    })
}

func singleNumber2(nums: [Int]) -> Int {
    var ones = 0
    var twos = 0
    for num in nums {
        ones = (ones ^ num) & ~twos
        twos = (twos ^ num) & ~ones
    }
    return ones
}

func singleNumber3(nums: [Int]) -> Int {
    var ones = 0
    var twos = 0
    var threes = 0
    for num in nums {
        ones = (ones ^ num) & ~threes
        twos = (twos ^ num) & ~ones
        threes = twos & ones
    }
    return ones
}

func singleNumber4(nums: [Int]) -> Int {
    var ones = 0
    var twos = 0
    var threes = 0
    for num in nums {
        ones = (ones ^ num) & ~threes
        twos = (twos ^ num) & ~ones
        threes = ones & twos
    }
    return ones
}

func singleNumber5(nums: [Int]) -> Int {
    var ones = 0
    var twos = 0
    var threes = 0
    for num in nums {
        ones = (ones ^ num) & ~threes
        twos = (twos ^ num) & ~ones
        threes = ones & twos
    }
    return ones
}
```swift
// From a supplied array of numbers (of length at least two) select and return two that are the closest to each
// other and return them in order (smaller number, larger number).
// findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.2]) == (2.0, 2.2)
// findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.0]) == (2.0, 2.0)
func findClosestElements(numbers: [Double]) -> (Double, Double) {
    let sortedNumbers = numbers.sorted()
    let first = sortedNumbers[0]
    let last = sortedNumbers[sortedNumbers.count - 1]
    let middle = sortedNumbers[sortedNumbers.count / 2]
    let distanceToFirst = abs(first - middle)
    let distanceToLast = abs(last - middle)
    if distanceToFirst < distanceToLast {
        return (first, last)
    } else {
        return (last, first)
    }
}

// 2. Write a function that takes a string as input and returns the string reversed.
// Example:
// Given s = "hello", return "olleh".
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// 3. Given an array of integers, every element appears twice except for one. Find that single one.
// Note:
// Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?
// Example:
// Input: [2,2,1]
// Output: 1
func singleNumber(nums: [Int]) -> Int {
    return nums.reduce(0, { acc, num in
        acc ^ num
    })
}

// 4. Given an array of integers, every element appears three times except for one. Find that single one.
// Note:
// Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?
// Example:
// Input: [2,2,3,2]
// Output: 3
func singleNumber2(nums: [Int]) -> Int {
    var ones = 0
    var twos = 0
    for num in nums {
        ones = (ones ^ num) & ~twos
        twos = (twos ^ num) & ~ones
    }
    return ones
}

// 5. Given an array of integers, every element appears three times except for one. Find that single one.
// Note:
// Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?
// Example:
// Input: [2,2,3,2]
// Output: 3
func singleNumber3(nums: [Int]) -> Int {
    var ones = 0
    var twos = 0
    var threes = 0
    for num in nums {
        ones = (ones ^ num) & ~threes
        twos = (twos ^ num) & ~ones
        threes = twos & ones
    }
    return ones
}

// 6. Given a non-empty array of integers, every element appears three times except for one, which appears exactly once. Find that single one.
// Note:
// Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?
// Example:
// Input: [2,2,3,2]
// Output: 3
func singleNumber4(nums: [Int]) -> Int {
    var ones = 0
    var twos = 0
    var threes = 0
    for num in nums {
        ones = (ones ^ num) & ~threes
        twos = (twos ^ num) & ~ones
        threes = ones & twos
    }
    return ones
}

// 7. Given an array of integers, every element appears three times except for one. Find that single one.
// Note:
// Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?
// Example:
// Input: [2,2,3,2]
// Output: 3
func singleNumber5(nums: [Int]) -> Int {
    var ones = 0
    var twos = 0
    var threes = 0
    for num in nums {
        ones = (ones ^ num) & ~threes
        twos = (twos ^ num) & ~ones
        threes = ones & twos
    }
    return ones
}

// 8. Given an array of integers, every element appears three times except for one. Find that single one.
// Note:
// Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?
// Example:
// Input: [2,2,3,2]
// Output: 3
func singleNumber6(
 // XCTAssertTrue failed

func rescaleToUnit(numbers: [Double]) -> [Double] {
    let min = numbers.min() ?? 0.0
    let max = numbers.max() ?? 0.0
    return numbers.map { $0 - min }.map { $0 / (max - min) }
}

func removeVowels(input: String) -> String {
    return input.filter { !"aeiouAEIOU".contains(Character($0)) }
}

func maxSubArray(numbers: [Double]) -> Double {
    var max = numbers.first() ?? 0.0
    var current = 0.0
    for number in numbers {
        current = max(current + number, number)
        max = max(current, max)
    }
    return max
}
```swift
// Given array of numbers (of at least two elements), apply a linear transform to that array,
// such that the smallest number will become 0 and the largest will become 1
// rescaleToUnit(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == [0.0, 0.25, 0.5, 0.75, 1.0]
func rescaleToUnit(numbers: [Double]) -> [Double] {
    let min = numbers.min() ?? 0.0
    let max = numbers.max() ?? 0.0
    return numbers.map { $0 - min }.map { $0 / (max - min) }
}

// ----------------------------------------------------------------------------------------------------------------------

// Given a string, return a string with all the vowels removed.
// removeVowels("I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
func removeVowels(input: String) -> String {
    return input.filter { !"aeiouAEIOU".contains(Character($0)) }
}

// ----------------------------------------------------------------------------------------------------------------------

// Given an array of numbers, return the largest sum of any contiguous subarray of the array.
// maxSubArray([-2, 1, -3, 4, -1, 2, 1, -5, 4]) == 6
// maxSubArray([-1, -2, -3, -4, -5]) == -1
func maxSubArray(numbers: [Double]) -> Double {
    var max = numbers.first() ?? 0.0
    var current = 0.0
    for number in numbers {
        current = max(current + number, number)
        max = max(current, max)
    }
    return max
}

// ----------------------------------------------------------------------------------------------------------------------

// Given an array of numbers, return the largest sum of any contiguous subarray of the array.
// maxSubArray([-2, 1, -3, 4, -1, 2, 1, -5, 4]) == 6
// maxSubArray([-1, -2, -3, -4, -5]) == -1
func maxSubArray(numbers: [Double]) -> Double {
    var max = numbers.first() ?? 0.0
    var current = 0.0
    for number in numbers {
        current = max(current + number, number)
        max = max(current, max)
    }
    return max
}

// ----------------------------------------------------------------------------------------------------------------------

// Given an array of numbers, return the largest sum of any contiguous subarray of the array.
// maxSubArray([-2, 1, -3, 4, -1, 2, 1, -5, 4]) == 6
// maxSubArray([-1, -2, -3, -4, -5]) == -1
func maxSubArray(numbers: [Double]) -> Double {
    var max = numbers.first() ?? 0.0
    var current = 0.0
    for number in numbers {
        current = max(current + number, number)
        max = max(current, max)
    }
    return max
}

// ----------------------------------------------------------------------------------------------------------------------

// Given an array of numbers, return the largest sum of any contiguous subarray of the array.
// maxSubArray([-2, 1, -3, 4, -1, 2, 1, -5, 4]) == 6
// maxSubArray([-1, -2, -3, -4, -5]) == -1
func maxSubArray(numbers: [Double]) -> Double {
    var max = numbers.first() ?? 0.0
    var current = 0.0
    for number in numbers {
        current = max(current + number, number)
        max = max(current, max)
    }
    return max
}

// ------
return input.filter { !"aeiouAEIOU".contains(Character($0)) } // missing argument label 'extendedGraphemeClusterLiteral:' in call
var max = numbers.first() ?? 0.0 // cannot call value of non-function type 'Double?'

func rescaleToUnit(numbers: [Double]) -> [Double] {
    return numbers.map { $0 / numbers.max() }
}

func rescaleToMean(numbers: [Double]) -> Double {
    return numbers.reduce(0.0) { $0 + $1 } / numbers.count
}

func rescaleToMedian(numbers: [Double]) -> Double {
    return numbers.sorted().median()
}

func rescaleToMode(numbers: [Double]) -> Double {
    return numbers.mode()
}

func rescaleToRange(numbers: [Double]) -> Double {
    return numbers.max() - numbers.min()
}

func rescaleToStandardDeviation(numbers: [Double]) -> Double {
    return numbers.standardDeviation()
}

func rescaleToVariance(numbers: [Double]) -> Double {
    return numbers.variance()
}

func rescaleToSkewness(numbers: [Double]) -> Double {
    return numbers.skewness()
}

func rescaleToKurtosis(numbers: [Double]) -> Double {
    return numbers.kurtosis()
}

func rescaleToEntropy(numbers: [Double]) -> Double {
    return numbers.entropy()
}
```swift
// Given array of numbers (of at least two elements), apply a linear transform to that array,
// such that the smallest number will become 0 and the largest will become 1
// rescaleToUnit(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == [0.0, 0.25, 0.5, 0.75, 1.0]
func rescaleToUnit(numbers: [Double]) -> [Double] {
    return numbers.map { $0 / numbers.max() }
}

// Given an array of numbers, return the mean
// rescaleToMean(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == 3.0
func rescaleToMean(numbers: [Double]) -> Double {
    return numbers.reduce(0.0) { $0 + $1 } / numbers.count
}

// Given an array of numbers, return the median
// rescaleToMedian(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == 3.0
func rescaleToMedian(numbers: [Double]) -> Double {
    return numbers.sorted().median()
}

// Given an array of numbers, return the mode
// rescaleToMode(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == 2.0
func rescaleToMode(numbers: [Double]) -> Double {
    return numbers.mode()
}

// Given an array of numbers, return the range
// rescaleToRange(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == 3.0
func rescaleToRange(numbers: [Double]) -> Double {
    return numbers.max() - numbers.min()
}

// Given an array of numbers, return the standard deviation
// rescaleToStandardDeviation(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == 1.0
func rescaleToStandardDeviation(numbers: [Double]) -> Double {
    return numbers.standardDeviation()
}

// Given an array of numbers, return the variance
// rescaleToVariance(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == 1.0
func rescaleToVariance(numbers: [Double]) -> Double {
    return numbers.variance()
}

// Given an array of numbers, return the skewness
// rescaleToSkewness(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == 0.0
func rescaleToSkewness(numbers: [Double]) -> Double {
    return numbers.skewness()
}

// Given an array of numbers, return the kurtosis
// rescaleToKurtosis(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == 0.0
func rescaleToKurtosis(numbers: [Double]) -> Double {
    return numbers.kurtosis()
}

// Given an array of numbers, return the entropy
// rescaleToEntropy(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == 0.0
func rescaleToEntropy(numbers: [Double]) -> Double {
    return numbers.entropy()
}

// Given an array of numbers, return the entropy
// rescaleToEntropy(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == 0.0
func rescaleToEntropy(numbers: [Double]) -> Double {
    return numbers.entropy()
}

// Given an array of numbers, return the entropy
// rescaleToEntropy(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == 0.0
func rescaleToEntropy(numbers: [Double]) -> Double {
    return numbers.entropy()
}

// Given an array of numbers, return the entropy
// rescaleToEntropy(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == 0.0
func rescaleToEntropy(numbers: [Double]) -> Double {
    return numbers.entropy()
}

// Given an array of numbers, return the entropy
// rescaleToEntropy(numbers: [1.0, 2.0, 3.0, 4.0, 5.
return numbers.map { $0 / numbers.max() } // value of optional type 'Double?' must be unwrapped to a value of type 'Double'
return numbers.reduce(0.0) { $0 + $1 } / numbers.count // cannot convert value of type 'Int' to expected argument type 'Double'
return numbers.sorted().median() // value of type '[Double]' has no member 'median'
return numbers.mode() // value of type '[Double]' has no member 'mode'
return numbers.max() - numbers.min() // binary operator '-' cannot be applied to two 'Double?' operands
return numbers.standardDeviation() // value of type '[Double]' has no member 'standardDeviation'
return numbers.variance() // value of type '[Double]' has no member 'variance'
return numbers.skewness() // value of type '[Double]' has no member 'skewness'
return numbers.kurtosis() // value of type '[Double]' has no member 'kurtosis'
return numbers.entropy() // value of type '[Double]' has no member 'entropy'

func rescaleToUnit(numbers: [Double]) -> [Double] {
    let min = numbers.min() ?? 0.0
    let max = numbers.max() ?? 0.0
    let range = max - min
    return numbers.map { $0 - min }.map { $0 / range }
}
```swift
// Given array of numbers (of at least two elements), apply a linear transform to that array,
// such that the smallest number will become 0 and the largest will become 1
// rescaleToUnit(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == [0.0, 0.25, 0.5, 0.75, 1.0]
func rescaleToUnit(numbers: [Double]) -> [Double] {
    let min = numbers.min() ?? 0.0
    let max = numbers.max() ?? 0.0
    let range = max - min
    return numbers.map { $0 - min }.map { $0 / range }
}

// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------

func rescaleToUnit(numbers: [Double]) -> [Double] {
    let min = numbers.min()!
    let max = numbers.max()!
    return numbers.map { $0 - min }.map { $0 / (max - min) }
}

func reverseArray(numbers: [Double]) -> [Double] {
    return numbers.reversed()
}
```swift
// Given array of numbers (of at least two elements), apply a linear transform to that array,
// such that the smallest number will become 0 and the largest will become 1
// rescaleToUnit(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == [0.0, 0.25, 0.5, 0.75, 1.0]
func rescaleToUnit(numbers: [Double]) -> [Double] {
    let min = numbers.min()!
    let max = numbers.max()!
    return numbers.map { $0 - min }.map { $0 / (max - min) }
}

// Given an array of numbers, return a new array with the same numbers, but with the numbers
// in reverse order.
// reverseArray([1, 2, 3, 4, 5]) == [5, 4, 3, 2, 1]
func reverseArray(numbers: [Double]) -> [Double] {
    return numbers.reversed()
}

// Given an array of numbers, return a new array with the same numbers, but with the numbers
// in reverse order.
// reverseArray([1, 2, 3, 4, 5]) == [5, 4, 3, 2, 1]
func reverseArray(numbers: [Double]) -> [Double] {
    return numbers.reversed()
}

// Given an array of numbers, return a new array with the same numbers, but with the numbers
// in reverse order.
// reverseArray([1, 2, 3, 4, 5]) == [5, 4, 3, 2, 1]
func reverseArray(numbers: [Double]) -> [Double] {
    return numbers.reversed()
}

// Given an array of numbers, return a new array with the same numbers, but with the numbers
// in reverse order.
// reverseArray([1, 2, 3, 4, 5]) == [5, 4, 3, 2, 1]
func reverseArray(numbers: [Double]) -> [Double] {
    return numbers.reversed()
}

// Given an array of numbers, return a new array with the same numbers, but with the numbers
// in reverse order.
// reverseArray([1, 2, 3, 4, 5]) == [5, 4, 3, 2, 1]
func reverseArray(numbers: [Double]) -> [Double] {
    return numbers.reversed()
}

// Given an array of numbers, return a new array with the same numbers, but with the numbers
// in reverse order.
// reverseArray([1, 2, 3, 4, 5]) == [5, 4, 3, 2, 1]
func reverseArray(numbers: [Double]) -> [Double] {
    return numbers.reversed()
}

// Given an array of numbers, return a new array with the same numbers, but with the numbers
// in reverse order.
// reverseArray([1, 2, 3, 4, 5]) == [5, 4, 3, 2, 1]
func reverseArray(numbers: [Double]) -> [Double] {
    return numbers.reversed()
}

// Given an array of numbers, return a new array with the same numbers, but with the numbers
// in reverse order.
// reverseArray([1, 2, 3, 4, 5]) == [5, 4, 3, 2, 1]
func reverseArray(numbers: [Double]) -> [Double] {
    return numbers.reversed()
}

// Given an array of numbers, return a new array with the same numbers, but with the numbers
// in reverse order.
// reverseArray([1, 2, 3, 4, 5]) == [5, 4, 3, 2, 1]
func reverseArray(numbers: [Double]) -> [Double] {
    return numbers.reversed()
}

// Given an array of numbers, return a new array with the same numbers, but with the numbers
// in reverse order.
// reverseArray([1, 2, 3, 4, 5]) == [5, 4, 3, 2, 1]
func reverseArray(numbers: [Double]) -> [Double] {
    return numbers.reversed()
}

// Given an array of numbers, return a new array with the same numbers, but with the numbers
// in reverse order.
// reverseArray([1, 2, 3, 4, 5]) == [5, 4, 3, 2, 1]
func reverseArray(numbers: [Double]) -> [Double] {
    return numbers.reversed()
}

// Given an array of numbers, return

func rescaleToUnit(numbers: [Double]) -> [Double] {
    let min = numbers.min()!
    let max = numbers.max()!
    return numbers.map { $0 - min }.map { $0 / (max - min) }
}
```swift
// Given array of numbers (of at least two elements), apply a linear transform to that array,
// such that the smallest number will become 0 and the largest will become 1
// rescaleToUnit(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == [0.0, 0.25, 0.5, 0.75, 1.0]
func rescaleToUnit(numbers: [Double]) -> [Double] {
    let min = numbers.min()!
    let max = numbers.max()!
    return numbers.map { $0 - min }.map { $0 / (max - min) }
}

// Given array of numbers (of at least two elements), apply a linear transform to that array,
// such that the smallest number will become 0 and the largest will become 1
// rescaleToUnit(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == [0.0, 0.25, 0.5, 0.75, 1.0]
func rescaleToUnit(numbers: [Double]) -> [Double] {
    let min = numbers.min()!
    let max = numbers.max()!
    return numbers.map { $0 - min }.map { $0 / (max - min) }
}

// Given array of numbers (of at least two elements), apply a linear transform to that array,
// such that the smallest number will become 0 and the largest will become 1
// rescaleToUnit(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == [0.0, 0.25, 0.5, 0.75, 1.0]
func rescaleToUnit(numbers: [Double]) -> [Double] {
    let min = numbers.min()!
    let max = numbers.max()!
    return numbers.map { $0 - min }.map { $0 / (max - min) }
}

// Given array of numbers (of at least two elements), apply a linear transform to that array,
// such that the smallest number will become 0 and the largest will become 1
// rescaleToUnit(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == [0.0, 0.25, 0.5, 0.75, 1.0]
func rescaleToUnit(numbers: [Double]) -> [Double] {
    let min = numbers.min()!
    let max = numbers.max()!
    return numbers.map { $0 - min }.map { $0 / (max - min) }
}

// Given array of numbers (of at least two elements), apply a linear transform to that array,
// such that the smallest number will become 0 and the largest will become 1
// rescaleToUnit(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == [0.0, 0.25, 0.5, 0.75, 1.0]
func rescaleToUnit(numbers: [Double]) -> [Double] {
    let min = numbers.min()!
    let max = numbers.max()!
    return numbers.map { $0 - min }.map { $0 / (max - min) }
}

// Given array of numbers (of at least two elements), apply a linear transform to that array,
// such that the smallest number will become 0 and the largest will become 1
// rescaleToUnit(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == [0.0, 0.25, 0.5, 0.75, 1.0]
func rescaleToUnit(numbers: [Double]) -> [Double] {
    let min = numbers.min()!
    let max = numbers.max()!
    return numbers.map { $0 - min }.map { $0 / (max - min) }
}

// Given array of numbers (of at least two elements), apply a linear transform to that array,
// such that the smallest number will become 0 and the largest will become 1
// rescaleToUnit(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == [0.0, 0.25, 0.5, 0.75, 1.0]
func rescaleToUnit(numbers: [Double]) -> [Double] {
    let min = numbers.min()!
    let max = numbers.max()!
    return numbers.map { $

func rescaleToUnit(numbers: [Double]) -> [Double] {
    let min = numbers.min()!
    let max = numbers.max()!
    return numbers.map { $0 - min }.map { $0 / (max - min) }
}

func rescaleToMean(numbers: [Double]) -> Double {
    let sum = numbers.reduce(0.0, { $0 + $1 })
    return sum / numbers.count
}

func rescaleToMedian(numbers: [Double]) -> Double {
    let sorted = numbers.sorted()
    let middle = sorted.count / 2
    return sorted[middle]
}

func rescaleToMode(numbers: [Double]) -> Double {
    let sorted = numbers.sorted()
    let mode = sorted.first(where: { sorted.count(for: $0) == sorted.count(for: $0) })!
    return mode
}

func rescaleToRange(numbers: [Double]) -> Double {
    let min = numbers.min()!
    let max = numbers.max()!
    return max - min
}

func rescaleToStandardDeviation(numbers: [Double]) -> Double {
    let mean = rescaleToMean(numbers: numbers)
    let squaredDifferences = numbers.map { $0 - mean }.map { $0 * $0 }
    let sumSquaredDifferences = squaredDifferences.reduce(0.0, { $0 + $1 })
    return sqrt(sumSquaredDifferences / numbers.count)
}
```swift
// Given array of numbers (of at least two elements), apply a linear transform to that array,
// such that the smallest number will become 0 and the largest will become 1
// rescaleToUnit(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == [0.0, 0.25, 0.5, 0.75, 1.0]
func rescaleToUnit(numbers: [Double]) -> [Double] {
    let min = numbers.min()!
    let max = numbers.max()!
    return numbers.map { $0 - min }.map { $0 / (max - min) }
}

// ----------------------------------------------------------------------------------------------------------------------

// Given an array of numbers, return the mean (average) of the numbers
// rescaleToMean(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == 3.0
func rescaleToMean(numbers: [Double]) -> Double {
    let sum = numbers.reduce(0.0, { $0 + $1 })
    return sum / numbers.count
}

// ----------------------------------------------------------------------------------------------------------------------

// Given an array of numbers, return the median (middle number) of the numbers
// rescaleToMedian(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == 3.0
func rescaleToMedian(numbers: [Double]) -> Double {
    let sorted = numbers.sorted()
    let middle = sorted.count / 2
    return sorted[middle]
}

// ----------------------------------------------------------------------------------------------------------------------

// Given an array of numbers, return the mode (most common number) of the numbers
// rescaleToMode(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == 3.0
func rescaleToMode(numbers: [Double]) -> Double {
    let sorted = numbers.sorted()
    let mode = sorted.first(where: { sorted.count(for: $0) == sorted.count(for: $0) })!
    return mode
}

// ----------------------------------------------------------------------------------------------------------------------

// Given an array of numbers, return the range (difference between the smallest and largest number) of the numbers
// rescaleToRange(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == 4.0
func rescaleToRange(numbers: [Double]) -> Double {
    let min = numbers.min()!
    let max = numbers.max()!
    return max - min
}

// ----------------------------------------------------------------------------------------------------------------------

// Given an array of numbers, return the standard deviation (average of the absolute differences from the mean) of the numbers
// rescaleToStandardDeviation(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == 1.0
func rescaleToStandardDeviation(numbers: [Double]) -> Double {
    let mean = rescaleToMean(numbers: numbers)
    let squaredDifferences = numbers.map { $0 - mean }.map { $0 * $0 }
    let sumSquaredDifferences = squaredDifferences.reduce(0.0, { $0 + $1 })
    return sqrt(sumSquaredDifferences / numbers.count)
}

// ----------------------------------------------------------------------------------------------------------------------

// Given an array of numbers, return the variance (average of the squared differences from the mean) of the numbers
// rescaleToVariance(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == 1.0
func rescaleToVariance(numbers: [Double]) -> Double {
    let mean = rescaleToMean(numbers: numbers)
    let squaredDifferences = numbers.map { $0 - mean
return sum / numbers.count // cannot convert value of type 'Int' to expected argument type 'Double'
let mode = sorted.first(where: { sorted.count(for: $0) == sorted.count(for: $0) })! // cannot call value of non-function type 'Int'
let mode = sorted.first(where: { sorted.count(for: $0) == sorted.count(for: $0) })! // cannot call value of non-function type 'Int'
return sqrt(sumSquaredDifferences / numbers.count) // cannot convert value of type 'Int' to expected argument type 'Double'

func rescaleToUnit(numbers: [Double]) -> [Double] {
    let min = numbers.min()!
    let max = numbers.max()!
    return numbers.map { $0 - min }.map { $0 / (max - min) }
}
```swift
// Given array of numbers (of at least two elements), apply a linear transform to that array,
// such that the smallest number will become 0 and the largest will become 1
// rescaleToUnit(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == [0.0, 0.25, 0.5, 0.75, 1.0]
func rescaleToUnit(numbers: [Double]) -> [Double] {
    let min = numbers.min()!
    let max = numbers.max()!
    return numbers.map { $0 - min }.map { $0 / (max - min) }
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: -
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: -
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: -
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: -
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: -
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: -
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: -
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: -
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: -
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: -
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK

func rescaleToUnit(numbers: [Double]) -> [Double] {
    let min = numbers.min()!
    let max = numbers.max()!
    return numbers.map { $0 - min }.map { $0 / (max - min) }
}
```swift
// Given array of numbers (of at least two elements), apply a linear transform to that array,
// such that the smallest number will become 0 and the largest will become 1
// rescaleToUnit(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == [0.0, 0.25, 0.5, 0.75, 1.0]
func rescaleToUnit(numbers: [Double]) -> [Double] {
    let min = numbers.min()!
    let max = numbers.max()!
    return numbers.map { $0 - min }.map { $0 / (max - min) }
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 2.2.2.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1

func rescaleToUnit(numbers: [Double]) -> [Double] {
    let min = numbers.min()!
    let max = numbers.max()!
    let range = max - min
    return numbers.map { number in
        (number - min) / range
    }
}
```swift
// Given array of numbers (of at least two elements), apply a linear transform to that array,
// such that the smallest number will become 0 and the largest will become 1
// rescaleToUnit(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == [0.0, 0.25, 0.5, 0.75, 1.0]
func rescaleToUnit(numbers: [Double]) -> [Double] {
    let min = numbers.min()!
    let max = numbers.max()!
    let range = max - min
    return numbers.map { number in
        (number - min) / range
    }
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 1.2.2.3.1.2.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.

func rescaleToUnit(numbers: [Double]) -> [Double] {
    let min = numbers.min()!
    let max = numbers.max()!
    let range = max - min
    return numbers.map { number in
        (number - min) / range
    }
}

func mean(numbers: [Double]) -> Double {
    return numbers.reduce(0.0, { $0 + $1 }) / numbers.count
}

func median(numbers: [Double]) -> Double {
    let sorted = numbers.sorted()
    let middle = sorted.count / 2
    return sorted[middle]
}

func mode(numbers: [Double]) -> Double {
    let sorted = numbers.sorted()
    let mode = sorted.first(where: { sorted.count(for: $0) == sorted.count(for: $0) })!
    return mode
}

func range(numbers: [Double]) -> Double {
    let sorted = numbers.sorted()
    return sorted.last()! - sorted.first()!
}

func standardDeviation(numbers: [Double]) -> Double {
    let mean = mean(numbers: numbers)
    let squaredDiffs = numbers.map { number in
        (number - mean) * (number - mean)
    }
    let sum = squaredDiffs.reduce(0.0, { $0 + $1 })
    return sqrt(sum / numbers.count)
}

func variance(numbers: [Double]) -> Double {
    return standardDeviation(numbers: numbers) * standardDeviation(numbers: numbers)
}

func skewness(numbers: [Double]) -> Double {
    let mean = mean(numbers: numbers)
    let squaredDiffs = numbers.map { number in
        (number - mean) * (number - mean)
    }
    let sum = squaredDiffs.reduce(0.0, { $0 + $1 })
    return sum / numbers.count
}
```swift
// Given array of numbers (of at least two elements), apply a linear transform to that array,
// such that the smallest number will become 0 and the largest will become 1
// rescaleToUnit(numbers: [1.0, 2.0, 3.0, 4.0, 5.0]) == [0.0, 0.25, 0.5, 0.75, 1.0]
func rescaleToUnit(numbers: [Double]) -> [Double] {
    let min = numbers.min()!
    let max = numbers.max()!
    let range = max - min
    return numbers.map { number in
        (number - min) / range
    }
}

// ----------------------------------------------------------------------------------------------------------------------

// Given an array of numbers, return the mean
// mean([1, 2, 3, 4, 5]) == 3.0
func mean(numbers: [Double]) -> Double {
    return numbers.reduce(0.0, { $0 + $1 }) / numbers.count
}

// ----------------------------------------------------------------------------------------------------------------------

// Given an array of numbers, return the median
// median([1, 2, 3, 4, 5]) == 3.0
func median(numbers: [Double]) -> Double {
    let sorted = numbers.sorted()
    let middle = sorted.count / 2
    return sorted[middle]
}

// ----------------------------------------------------------------------------------------------------------------------

// Given an array of numbers, return the mode
// mode([1, 2, 3, 4, 5]) == 1.0
func mode(numbers: [Double]) -> Double {
    let sorted = numbers.sorted()
    let mode = sorted.first(where: { sorted.count(for: $0) == sorted.count(for: $0) })!
    return mode
}

// ----------------------------------------------------------------------------------------------------------------------

// Given an array of numbers, return the range
// range([1, 2, 3, 4, 5]) == 4.0
func range(numbers: [Double]) -> Double {
    let sorted = numbers.sorted()
    return sorted.last()! - sorted.first()!
}

// ----------------------------------------------------------------------------------------------------------------------

// Given an array of numbers, return the standard deviation
// standardDeviation([1, 2, 3, 4, 5]) == 1.0
func standardDeviation(numbers: [Double]) -> Double {
    let mean = mean(numbers: numbers)
    let squaredDiffs = numbers.map { number in
        (number - mean) * (number - mean)
    }
    let sum = squaredDiffs.reduce(0.0, { $0 + $1 })
    return sqrt(sum / numbers.count)
}

// ----------------------------------------------------------------------------------------------------------------------

// Given an array of numbers, return the variance
// variance([1, 2, 3, 4, 5]) == 1.0
func variance(numbers: [Double]) -> Double {
    return standardDeviation(numbers: numbers) * standardDeviation(numbers: numbers)
}

// ----------------------------------------------------------------------------------------------------------------------

// Given an array of numbers, return the skewness
// skewness([1, 2, 3, 4, 5]) == 0.0
func skewness(numbers: [Double]) -> Double {
    let mean = mean(numbers: numbers)
    let squaredDiffs = numbers.map { number in
        (number - mean) * (number - mean)
    }
    let sum = squaredDiffs.reduce(0.0, { $0 + $1 })
    return sum / numbers.count
}

// ---------------------------------------------------------------------
return numbers.reduce(0.0, { $0 + $1 }) / numbers.count // cannot convert value of type 'Int' to expected argument type 'Double'
let mode = sorted.first(where: { sorted.count(for: $0) == sorted.count(for: $0) })! // cannot call value of non-function type 'Int'
let mode = sorted.first(where: { sorted.count(for: $0) == sorted.count(for: $0) })! // cannot call value of non-function type 'Int'
return sorted.last()! - sorted.first()! // cannot call value of non-function type 'Double?'
return sorted.last()! - sorted.first()! // cannot call value of non-function type 'Double?'
return sqrt(sum / numbers.count) // cannot convert value of type 'Int' to expected argument type 'Double'
return sum / numbers.count // cannot convert value of type 'Int' to expected argument type 'Double'

func filterIntegers(values: [AnyHashable]) -> [Int] {
    return values.filter {
        if let int = Int(try! $0 as! NSNumber) {
            return true
        } else {
            return false
        }
    }
}
```swift
// Filter given array of any swiftthon values only for integers
// filterIntegers(values: ["a", 3.14, 5]) == [5]
// filterIntegers(values: [1, 2, 3, "abc", [:] as [AnyHashable : AnyHashable], [] as [AnyHashable]]) == [1, 2, 3]
func filterIntegers(values: [AnyHashable]) -> [Int] {
    return values.filter {
        if let int = Int(try! $0 as! NSNumber) {
            return true
        } else {
            return false
        }
    }
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
return values.filter { // cannot convert return expression of type '[AnyHashable]' to return type '[Int]'

func filterIntegers(values: [AnyHashable]) -> [Int] {
    return values.filter {
        switch $0 {
            case .number(of: Int.self):
                return true
            default:
                return false
        }
    }
}
```swift
// Filter given array of any swiftthon values only for integers
// filterIntegers(values: ["a", 3.14, 5]) == [5]
// filterIntegers(values: [1, 2, 3, "abc", [:] as [AnyHashable : AnyHashable], [] as [AnyHashable]]) == [1, 2, 3]
func filterIntegers(values: [AnyHashable]) -> [Int] {
    return values.filter {
        switch $0 {
            case .number(of: Int.self):
                return true
            default:
                return false
        }
    }
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
return values.filter { // cannot convert return expression of type '[AnyHashable]' to return type '[Int]'
case .number(of: Int.self): // type 'Int.Type' cannot conform to '_ErrorCodeProtocol'
case .number(of: Int.self): // type 'AnyHashable' has no member 'number'

func filterIntegers(values: [AnyHashable]) -> [Int] {
    return values.filter {
        switch $0 {
        case let i as Int:
            return true
        default:
            return false
        }
    }
}
```swift
// Filter given array of any swiftthon values only for integers
// filterIntegers(values: ["a", 3.14, 5]) == [5]
// filterIntegers(values: [1, 2, 3, "abc", [:] as [AnyHashable : AnyHashable], [] as [AnyHashable]]) == [1, 2, 3]
func filterIntegers(values: [AnyHashable]) -> [Int] {
    return values.filter {
        switch $0 {
        case let i as Int:
            return true
        default:
            return false
        }
    }
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// ---------------------------------
return values.filter { // cannot convert return expression of type '[AnyHashable]' to return type '[Int]'

func filterIntegers(values: [AnyHashable]) -> [Int] {
    return values.filter {
        if let int = Int(try? $0 as! NSNumber) {
            return true
        } else {
            return false
        }
    }
}
```swift
// Filter given array of any swiftthon values only for integers
// filterIntegers(values: ["a", 3.14, 5]) == [5]
// filterIntegers(values: [1, 2, 3, "abc", [:] as [AnyHashable : AnyHashable], [] as [AnyHashable]]) == [1, 2, 3]
func filterIntegers(values: [AnyHashable]) -> [Int] {
    return values.filter {
        if let int = Int(try? $0 as! NSNumber) {
            return true
        } else {
            return false
        }
    }
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 10. Write a function that takes a string and returns a new string with all vowels removed.
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 11. Write a function that takes a string and returns a new string with all non-alphabetic characters removed.
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 12. Write a function that takes a string and returns a new string with all non-alphabetic characters removed.
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 13. Write a function that takes a string and returns a new string with all non-alphabetic characters removed.
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 14. Write a function that takes a string and returns a new string with all non-alphabetic characters removed.
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 15. Write a function that takes a string and returns a new string with all non-alphabetic characters removed.
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 16. Write a function that takes a string and returns a new string with all non-alphabetic characters removed.
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 17. Write a function that takes a string and returns a new string with all non-alphabetic characters removed.
// ---------------------------------------------------------------------------------------------------
return values.filter { // cannot convert return expression of type '[AnyHashable]' to return type '[Int]'
if let int = Int(try? $0 as! NSNumber) { // value of optional type 'NSNumber?' not unwrapped; did you mean to use 'try!' or chain with '?'?

func filterIntegers(values: [AnyHashable]) -> [Int] {
    return values.compactMap {
        if let int = Int(try! $0) {
            return int
        } else {
            return nil
        }
    }
}
```swift
// Filter given array of any swiftthon values only for integers
// filterIntegers(values: ["a", 3.14, 5]) == [5]
// filterIntegers(values: [1, 2, 3, "abc", [:] as [AnyHashable : AnyHashable], [] as [AnyHashable]]) == [1, 2, 3]
func filterIntegers(values: [AnyHashable]) -> [Int] {
    return values.compactMap {
        if let int = Int(try! $0) {
            return int
        } else {
            return nil
        }
    }
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
if let int = Int(try! $0) { // cannot convert value of type 'AnyHashable' to expected argument type 'String'

func filterIntegers(values: [AnyHashable]) -> [Int] {
    return values.filter {
        if let int = Int(try! $0) {
            return true
        } else {
            return false
        }
    }
}
```swift
// Filter given array of any swiftthon values only for integers
// filterIntegers(values: ["a", 3.14, 5]) == [5]
// filterIntegers(values: [1, 2, 3, "abc", [:] as [AnyHashable : AnyHashable], [] as [AnyHashable]]) == [1, 2, 3]
func filterIntegers(values: [AnyHashable]) -> [Int] {
    return values.filter {
        if let int = Int(try! $0) {
            return true
        } else {
            return false
        }
    }
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
return values.filter { // cannot convert return expression of type '[AnyHashable]' to return type '[Int]'
if let int = Int(try! $0) { // cannot convert value of type 'AnyHashable' to expected argument type 'String'

func filterIntegers(values: [AnyHashable]) -> [Int] {
    return values.filter {
        switch $0 {
        case let n as Int:
            return true
        default:
            return false
        }
    }
}
```swift
// Filter given array of any swiftthon values only for integers
// filterIntegers(values: ["a", 3.14, 5]) == [5]
// filterIntegers(values: [1, 2, 3, "abc", [:] as [AnyHashable : AnyHashable], [] as [AnyHashable]]) == [1, 2, 3]
func filterIntegers(values: [AnyHashable]) -> [Int] {
    return values.filter {
        switch $0 {
        case let n as Int:
            return true
        default:
            return false
        }
    }
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
return values.filter { // cannot convert return expression of type '[AnyHashable]' to return type '[Int]'

func filterIntegers(values: [AnyHashable]) -> [Int] {
    return values.filter {
        if let int = Int(try! $0 as! NSNumber) {
            return true
        } else {
            return false
        }
    }
}
```swift
// Filter given array of any swiftthon values only for integers
// filterIntegers(values: ["a", 3.14, 5]) == [5]
// filterIntegers(values: [1, 2, 3, "abc", [:] as [AnyHashable : AnyHashable], [] as [AnyHashable]]) == [1, 2, 3]
func filterIntegers(values: [AnyHashable]) -> [Int] {
    return values.filter {
        if let int = Int(try! $0 as! NSNumber) {
            return true
        } else {
            return false
        }
    }
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
return values.filter { // cannot convert return expression of type '[AnyHashable]' to return type '[Int]'

func filterIntegers(values: [AnyHashable]) -> [Int] {
    return values.filter {
        if let int = Int(try? $0.description) {
            return true
        } else {
            return false
        }
    }
}
```swift
// Filter given array of any swiftthon values only for integers
// filterIntegers(values: ["a", 3.14, 5]) == [5]
// filterIntegers(values: [1, 2, 3, "abc", [:] as [AnyHashable : AnyHashable], [] as [AnyHashable]]) == [1, 2, 3]
func filterIntegers(values: [AnyHashable]) -> [Int] {
    return values.filter {
        if let int = Int(try? $0.description) {
            return true
        } else {
            return false
        }
    }
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 11. Write a function that takes a string and returns a string with the first letter capitalized.
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 12. Write a function that takes a string and returns a string with the first letter of each word capitalized.
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 13. Write a function that takes a string and returns a string with the first letter of each word capitalized.
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 14. Write a function that takes a string and returns a string with the first letter of each word capitalized.
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 15. Write a function that takes a string and returns a string with the first letter of each word capitalized.
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 16. Write a function that takes a string and returns a string with the first letter of each word capitalized.
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 17. Write a function that takes a string and returns a string with the first letter of each word capitalized.
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 18. Write a function that takes a string and returns a string with the first letter of each word capitalized.
// ----------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------------------------------------------------------------------
return values.filter { // cannot convert return expression of type '[AnyHashable]' to return type '[Int]'
if let int = Int(try? $0.description) { // value of optional type 'String?' not unwrapped; did you mean to use 'try!' or chain with '?'?

func filterIntegers(values: [AnyHashable]) -> [Int] {
    return values.filter {
        let value = $0 as? Int
        return value != nil
    } as! [Int]
}
```swift
// Filter given array of any swiftthon values only for integers
// filterIntegers(values: ["a", 3.14, 5]) == [5]
// filterIntegers(values: [1, 2, 3, "abc", [:] as [AnyHashable : AnyHashable], [] as [AnyHashable]]) == [1, 2, 3]
func filterIntegers(values: [AnyHashable]) -> [Int] {
    return values.filter {
        let value = $0 as? Int
        return value != nil
    } as! [Int]
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

func strlen(string: String) -> Int {
    return string.count
}

func isEmpty(string: String) -> Bool {
    return string.isEmpty
}

func isNotEmpty(string: String) -> Bool {
    return !string.isEmpty
}

func isWhitespace(string: String) -> Bool {
    return string.isEmpty || string.trim().isEmpty
}

func isNotWhitespace(string: String) -> Bool {
    return !string.isEmpty && !string.trim().isEmpty
}

func isEmptyOrWhitespace(string: String) -> Bool {
    return string.isEmpty || string.trim().isEmpty
}

func isNotEmptyOrWhitespace(string: String) -> Bool {
    return !string.isEmpty && !string.trim().isEmpty
}

func isEmptyOrWhitespaceOrEmpty(string: String) -> Bool {
    return string.isEmpty || string.trim().isEmpty || string.isEmpty
}

func isNotEmptyOrWhitespaceOrEmpty(string: String) -> Bool {
    return !string.isEmpty && !string.trim().isEmpty || string.isEmpty
}
```swift
// Return length of given string
// strlen(string: "") == 0
// strlen(string: "abc") == 3
func strlen(string: String) -> Int {
    return string.count
}

// Return true if given string is empty
// strlen(string: "") == true
// strlen(string: "abc") == false
func isEmpty(string: String) -> Bool {
    return string.isEmpty
}

// Return true if given string is not empty
// strlen(string: "") == false
// strlen(string: "abc") == true
func isNotEmpty(string: String) -> Bool {
    return !string.isEmpty
}

// Return true if given string is empty or contains only whitespace characters
// strlen(string: "") == true
// strlen(string: " ") == true
// strlen(string: "  ") == true
// strlen(string: " a ") == true
// strlen(string: " a b ") == true
// strlen(string: " a b ") == false
func isWhitespace(string: String) -> Bool {
    return string.isEmpty || string.trim().isEmpty
}

// Return true if given string is not empty or contains only whitespace characters
// strlen(string: "") == false
// strlen(string: " ") == false
// strlen(string: "  ") == false
// strlen(string: " a ") == false
// strlen(string: " a b ") == false
// strlen(string: " a b ") == true
func isNotWhitespace(string: String) -> Bool {
    return !string.isEmpty && !string.trim().isEmpty
}

// Return true if given string is empty or contains only whitespace characters
// strlen(string: "") == true
// strlen(string: " ") == true
// strlen(string: "  ") == true
// strlen(string: " a ") == true
// strlen(string: " a b ") == true
// strlen(string: " a b ") == false
func isEmptyOrWhitespace(string: String) -> Bool {
    return string.isEmpty || string.trim().isEmpty
}

// Return true if given string is not empty or contains only whitespace characters
// strlen(string: "") == false
// strlen(string: " ") == false
// strlen(string: "  ") == false
// strlen(string: " a ") == false
// strlen(string: " a b ") == false
// strlen(string: " a b ") == true
func isNotEmptyOrWhitespace(string: String) -> Bool {
    return !string.isEmpty && !string.trim().isEmpty
}

// Return true if given string is empty or contains only whitespace characters
// strlen(string: "") == true
// strlen(string: " ") == true
// strlen(string: "  ") == true
// strlen(string: " a ") == true
// strlen(string: " a b ") == true
// strlen(string: " a b ") == false
func isEmptyOrWhitespaceOrEmpty(string: String) -> Bool {
    return string.isEmpty || string.trim().isEmpty || string.isEmpty
}

// Return true if given string is not empty or contains only whitespace characters
// strlen(string: "") == false
// strlen(string: " ") == false
// strlen(string: "  ") == false
// strlen(string: " a ") == false
// strlen(string: " a b ") == false
// strlen(string: " a b ") == true
func isNotEmptyOrWhitespaceOrEmpty(string: String) -> Bool {
    return !string.isEmpty && !string.trim().isEmpty || string.isEmpty
}

// Return true if given string is empty or contains only whitespace characters
// strlen(string: "") == true
// strlen(string: " ") == true
// strlen(string: "  ") == true
// strlen(string: " a ") == true
// strlen(string: " a b ") == true
// strlen(string: " a b ") == false
func isEmptyOrWhitespaceOrEmptyOrEmpty(string: String) -> Bool {
    return
return string.isEmpty || string.trim().isEmpty // value of type 'String' has no member 'trim'
return !string.isEmpty && !string.trim().isEmpty // value of type 'String' has no member 'trim'
return string.isEmpty || string.trim().isEmpty // value of type 'String' has no member 'trim'
return !string.isEmpty && !string.trim().isEmpty // value of type 'String' has no member 'trim'
return string.isEmpty || string.trim().isEmpty || string.isEmpty // value of type 'String' has no member 'trim'
return !string.isEmpty && !string.trim().isEmpty || string.isEmpty // value of type 'String' has no member 'trim'

func strlen(string: String) -> Int {
    return string.count
}

func strchr(string: String, c: Character) -> String {
    return string.first(where: { $0 == c }) ?? ""
}

func strrchr(string: String, c: Character) -> String {
    return string.last(where: { $0 == c }) ?? ""
}

func strstr(string: String, substring: String) -> String {
    return string.first(where: { substring.contains($0) }) ?? ""
}

func strrstr(string: String, substring: String) -> String {
    return string.last(where: { substring.contains($0) }) ?? ""
}
```swift
// Return length of given string
// strlen(string: "") == 0
// strlen(string: "abc") == 3
func strlen(string: String) -> Int {
    return string.count
}

// Return the first character of the given string
// strchr(string: "", c: 'a') == ""
// strchr(string: "abc", c: 'a') == "a"
func strchr(string: String, c: Character) -> String {
    return string.first(where: { $0 == c }) ?? ""
}

// Return the last character of the given string
// strrchr(string: "", c: 'a') == ""
// strrchr(string: "abc", c: 'a') == "a"
func strrchr(string: String, c: Character) -> String {
    return string.last(where: { $0 == c }) ?? ""
}

// Return the first occurrence of the given character in the given string
// strchr(string: "", c: 'a') == ""
// strchr(string: "abc", c: 'a') == "a"
// strchr(string: "abc", c: 'b') == "b"
// strchr(string: "abc", c: 'c') == "c"
// strchr(string: "abc", c: 'd') == ""
func strchr(string: String, c: Character) -> String {
    return string.first(where: { $0 == c }) ?? ""
}

// Return the last occurrence of the given character in the given string
// strrchr(string: "", c: 'a') == ""
// strrchr(string: "abc", c: 'a') == "a"
// strrchr(string: "abc", c: 'b') == "b"
// strrchr(string: "abc", c: 'c') == "c"
// strrchr(string: "abc", c: 'd') == ""
func strrchr(string: String, c: Character) -> String {
    return string.last(where: { $0 == c }) ?? ""
}

// Return the first occurrence of the given substring in the given string
// strstr(string: "", substring: "") == ""
// strstr(string: "abc", substring: "") == "abc"
// strstr(string: "abc", substring: "a") == "a"
// strstr(string: "abc", substring: "b") == "b"
// strstr(string: "abc", substring: "c") == "c"
// strstr(string: "abc", substring: "d") == ""
func strstr(string: String, substring: String) -> String {
    return string.first(where: { substring.contains($0) }) ?? ""
}

// Return the last occurrence of the given substring in the given string
// strrstr(string: "", substring: "") == ""
// strrstr(string: "abc", substring: "") == "abc"
// strrstr(string: "abc", substring: "a") == "a"
// strrstr(string: "abc", substring: "b") == "b"
// strrstr(string: "abc", substring: "c") == "c"
// strrstr(string: "abc", substring: "d") == ""
func strrstr(string: String, substring: String) -> String {
    return string.last(where: { substring.contains($0) }) ?? ""
}

// Return the first occurrence of the given character in the given string
// strchr(string: "", c: 'a') == ""
// strchr(string: "abc", c: 'a') == "a"
// strchr(string: "abc", c: 'b') == "b"
// strchr(string: "abc", c: 'c') == "c"
// strchr(string: "abc", c: 'd') == ""
func strchr(string: String, c: Character) -> String {
    return string.first(where: { $0 == c }) ?? ""
}

// Return the last
return string.first(where: { $0 == c }) ?? "" // binary operator '??' cannot be applied to operands of type 'String.Element?' (aka 'Optional<Character>') and 'String'
return string.first(where: { $0 == c }) ?? "" // no '??' candidates produce the expected contextual result type 'String'
return string.last(where: { $0 == c }) ?? "" // binary operator '??' cannot be applied to operands of type 'String.Element?' (aka 'Optional<Character>') and 'String'
return string.last(where: { $0 == c }) ?? "" // no '??' candidates produce the expected contextual result type 'String'
return string.first(where: { substring.contains($0) }) ?? "" // no '??' candidates produce the expected contextual result type 'String'
return string.first(where: { substring.contains($0) }) ?? "" // binary operator '??' cannot be applied to operands of type 'String.Element?' (aka 'Optional<Character>') and 'String'
return string.last(where: { substring.contains($0) }) ?? "" // binary operator '??' cannot be applied to operands of type 'String.Element?' (aka 'Optional<Character>') and 'String'
return string.last(where: { substring.contains($0) }) ?? "" // no '??' candidates produce the expected contextual result type 'String'

func strlen(string: String) -> Int {
    return string.count
}
```swift
// Return length of given string
// strlen(string: "") == 0
// strlen(string: "abc") == 3
func strlen(string: String) -> Int {
    return string.count
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ---------------------------------------------

func strlen(string: String) -> Int {
    return string.count
}
```swift
// Return length of given string
// strlen(string: "") == 0
// strlen(string: "abc") == 3
func strlen(string: String) -> Int {
    return string.count
}

// -----------------------------------------------------------------------------
// 1.1.2.2.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1

func strlen(string: String) -> Int {
    return string.count
}
```swift
// Return length of given string
// strlen(string: "") == 0
// strlen(string: "abc") == 3
func strlen(string: String) -> Int {
    return string.count
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ---------------------------------------------

func strlen(string: String) -> Int {
    return string.count
}

func firstChar(string: String) -> String {
    return string.first!
}

func lastChar(string: String) {
    return string.last!
}

func substring(string: String, start: Int, length: Int) -> String {
    return string.substring(start: start, length: length)
}

func substring(string: String, start: Int) -> String {
    return string.substring(start: start)
}
```swift
// Return length of given string
// strlen(string: "") == 0
// strlen(string: "abc") == 3
func strlen(string: String) -> Int {
    return string.count
}

// Return the first character of a string
// firstChar("abc") == "a"
func firstChar(string: String) -> String {
    return string.first!
}

// Return the last character of a string
// lastChar("abc") == "c"
func lastChar(string: String) {
    return string.last!
}

// Return the substring of a string
// substring("abc", 1, 2) == "bc"
func substring(string: String, start: Int, length: Int) -> String {
    return string.substring(start: start, length: length)
}

// Return the substring of a string
// substring("abc", 1) == "bc"
func substring(string: String, start: Int) -> String {
    return string.substring(start: start)
}

// Return the substring of a string
// substring("abc", 1, 2) == "bc"
func substring(string: String, start: Int, length: Int) -> String {
    return string.substring(start: start, length: length)
}

// Return the substring of a string
// substring("abc", 1) == "bc"
func substring(string: String, start: Int) -> String {
    return string.substring(start: start)
}

// Return the substring of a string
// substring("abc", 1, 2) == "bc"
func substring(string: String, start: Int) -> String {
    return string.substring(start: start)
}

// Return the substring of a string
// substring("abc", 1, 2) == "bc"
func substring(string: String, start: Int) -> String {
    return string.substring(start: start)
}

// Return the substring of a string
// substring("abc", 1, 2) == "bc"
func substring(string: String, start: Int) -> String {
    return string.substring(start: start)
}

// Return the substring of a string
// substring("abc", 1, 2) == "bc"
func substring(string: String, start: Int) -> String {
    return string.substring(start: start)
}

// Return the substring of a string
// substring("abc", 1, 2) == "bc"
func substring(string: String, start: Int) -> String {
    return string.substring(start: start)
}

// Return the substring of a string
// substring("abc", 1, 2) == "bc"
func substring(string: String, start: Int) -> String {
    return string.substring(start: start)
}

// Return the substring of a string
// substring("abc", 1, 2) == "bc"
func substring(string: String, start: Int) -> String {
    return string.substring(start: start)
}

// Return the substring of a string
// substring("abc", 1, 2) == "bc"
func substring(string: String, start: Int) -> String {
    return string.substring(start: start)
}

// Return the substring of a string
// substring("abc", 1, 2) == "bc"
func substring(string: String, start: Int) -> String {
    return string.substring(start: start)
}

// Return the substring of a string
// substring("abc", 1, 2) == "bc"
func substring(string: String, start: Int) -> String {
    return string.substring(start: start)
}

// Return the substring of a string
// substring("abc", 1, 2) == "bc"
func substring(string: String, start: Int) -> String {
    return string.substring(start: start)
}

// Return the substring of a string
// substring("abc", 1, 2) == "bc"
func substring(string: String, start: Int) -> String {
    return string.
return string.first! // cannot convert return expression of type 'String.Element' (aka 'Character') to return type 'String'
return string.last! // unexpected non-void return value in void function
return string.substring(start: start, length: length) // no exact matches in call to instance method 'substring'
return string.substring(start: start) // no exact matches in call to instance method 'substring'

func strlen(string: String) -> Int {
    return string.count
}
```swift
// Return length of given string
// strlen(string: "") == 0
// strlen(string: "abc") == 3
func strlen(string: String) -> Int {
    return string.count
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

func strlen(string: String) -> Int {
    return string.count
}
```swift
// Return length of given string
// strlen(string: "") == 0
// strlen(string: "abc") == 3
func strlen(string: String) -> Int {
    return string.count
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

func strlen(string: String) -> Int {
    return string.count
}
```swift
// Return length of given string
// strlen(string: "") == 0
// strlen(string: "abc") == 3
func strlen(string: String) -> Int {
    return string.count
}

// -----------------------------------------------------------------------------
// 2. Write a function that takes a string and returns a new string with all
//    characters in reverse order.
//
//    strrev(string: "") == ""
//    strrev(string: "abc") == "cba"
//    strrev(string: "abcdef") == "fedcba"
//
//    Note: You can use the built-in `reverse` function, but don't use it.
//
//    Hint: You can use the `for` loop to iterate over the string.
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 3. Write a function that takes a string and returns a new string with all
//    characters in reverse order.
//
//    strrev(string: "") == ""
//    strrev(string: "abc") == "cba"
//    strrev(string: "abcdef") == "fedcba"
//
//    Note: You can use the built-in `reverse` function, but don't use it.
//
//    Hint: You can use the `for` loop to iterate over the string.
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 4. Write a function that takes a string and returns a new string with all
//    characters in reverse order.
//
//    strrev(string: "") == ""
//    strrev(string: "abc") == "cba"
//    strrev(string: "abcdef") == "fedcba"
//
//    Note: You can use the built-in `reverse` function, but don't use it.
//
//    Hint: You can use the `for` loop to iterate over the string.
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 5. Write a function that takes a string and returns a new string with all
//    characters in reverse order.
//
//    strrev(string: "") == ""
//    strrev(string: "abc") == "cba"
//    strrev(string: "abcdef") == "fedcba"
//
//    Note: You can use the built-in `reverse` function, but don't use it.
//
//    Hint: You can use the `for` loop to iterate over the string.
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 6. Write a function that takes a string and returns a new string with all
//    characters in reverse order.
//
//    strrev(string: "") == ""
//    strrev(string: "abc") == "cba"
//    strrev(string: "abcdef") == "fedcba"
//
//    Note: You can use the built-in `reverse` function, but don't use it.
//
//    Hint: You can use the `for` loop to iterate over the string.
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 7. Write a function that takes a string and returns a new string with all
//    characters in reverse order.
//
//    strrev(string: "") == ""
//    strrev(string

func strlen(string: String) -> Int {
    return string.count
}
```swift
// Return length of given string
// strlen(string: "") == 0
// strlen(string: "abc") == 3
func strlen(string: String) -> Int {
    return string.count
}

// -----------------------------------------------------------------------------
// 1.1.2.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1

func largestDivisor(n: Int) -> Int {
    for i in (1...n).reversed {
        if n % i == 0 {
            return i
        }
    }
    return 1
}

func reverseString(s: String) -> String {
    return String(s.reversed())
}

func productExceptSelf(nums: [Int]) -> [Int] {
    var result = [1]
    for i in 1...nums.count {
        result.append(result[i - 1] * nums[i - 1])
    }
    var right = 1
    for i in (nums.count - 1...1).reversed {
        result[i] = result[i] * right
        right *= nums[i]
    }
    return result
}

func missingNumber(nums: [Int]) -> Int {
    var sum = 0
    for num in nums {
        sum += num
    }
    return (nums.count * (nums.count + 1) / 2) - sum
}
```swift
// For a given number n, find the largest number that divides n evenly, smaller than n
// largestDivisor(n: 15) == 5
func largestDivisor(n: Int) -> Int {
    for i in (1...n).reversed {
        if n % i == 0 {
            return i
        }
    }
    return 1
}

// 2. Write a function that takes a string as input and returns the string reversed.
// reverseString("hello") == "olleh"
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// 3. Given an array nums of n integers where n > 1,  return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].
// productExceptSelf(nums: [1, 2, 3, 4]) == [24, 12, 8, 6]
func productExceptSelf(nums: [Int]) -> [Int] {
    var result = [1]
    for i in 1...nums.count {
        result.append(result[i - 1] * nums[i - 1])
    }
    var right = 1
    for i in (nums.count - 1...1).reversed {
        result[i] = result[i] * right
        right *= nums[i]
    }
    return result
}

// 4. Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array.
// missingNumber(nums: [3, 0, 1]) == 2
func missingNumber(nums: [Int]) -> Int {
    var sum = 0
    for num in nums {
        sum += num
    }
    return (nums.count * (nums.count + 1) / 2) - sum
}

// 5. Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array.
// missingNumber(nums: [3, 0, 1]) == 2
func missingNumber(nums: [Int]) -> Int {
    var sum = 0
    for num in nums {
        sum += num
    }
    return (nums.count * (nums.count + 1) / 2) - sum
}

// 6. Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array.
// missingNumber(nums: [3, 0, 1]) == 2
func missingNumber(nums: [Int]) -> Int {
    var sum = 0
    for num in nums {
        sum += num
    }
    return (nums.count * (nums.count + 1) / 2) - sum
}

// 7. Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array.
// missingNumber(nums: [3, 0, 1]) == 2
func missingNumber(nums: [Int]) -> Int {
    var sum = 0
    for num in nums {
        sum += num
    }
    return (nums.count * (nums.count + 1) / 2) - sum
}

// 8. Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array.
// missingNumber(nums: [3, 0, 1]) == 2
func missingNumber(nums: [Int]) -> Int {
    var sum = 0
    for num in nums {
        sum += num
    }
    return (nums.count * (nums.count + 1) / 2) - sum
}

// 9. Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array.
// missingNumber(nums: [3, 0, 1]) == 2
func missingNumber(nums: [Int]) -> Int {
    var sum = 0
    for num in nums {
        sum += num
    }
    return (nums.
for i in (1...n).reversed { // no 'reversed' overloads produce result type that conforms to 'Sequence'
for i in (nums.count - 1...1).reversed { // no 'reversed' overloads produce result type that conforms to 'Sequence'

func largestDivisor(n: Int) -> Int {
    for i in (1...n).reversed {
        if n % i == 0 {
            return i
        }
    }
    return 1
}

func reverseString(s: String) -> String {
    return String(s.reversed())
}

func numberOf1Bits(n: Int) -> Int {
    var count = 0
    while n > 0 {
        count += n & 1
        n >>= 1
    }
    return count
}

func numberOf1Bits(n: UInt) -> Int {
    var count = 0
    while n > 0 {
        count += n & 1
        n >>= 1
    }
    return count
}
```swift
// For a given number n, find the largest number that divides n evenly, smaller than n
// largestDivisor(n: 15) == 5
func largestDivisor(n: Int) -> Int {
    for i in (1...n).reversed {
        if n % i == 0 {
            return i
        }
    }
    return 1
}

// ----------------------------------------------------------------------------------------------------------------------
// 11. Write a function that takes a string as input and returns the string reversed.
// Example:
// Given s = "hello", return "olleh".
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// ----------------------------------------------------------------------------------------------------------------------
// 12. Write a function that takes an integer and returns the number of 1 bits it has.
// Example:
// The 32-bit integer 11 has binary representation
// 00000000000000000000000000001111
// so the function should return 3.
func numberOf1Bits(n: Int) -> Int {
    var count = 0
    while n > 0 {
        count += n & 1
        n >>= 1
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------
// 13. Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).
// Example:
// The 32-bit integer ’11' has binary representation
// 00000000000000000000000000001111
// so the function should return 3.
func numberOf1Bits(n: UInt) -> Int {
    var count = 0
    while n > 0 {
        count += n & 1
        n >>= 1
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------
// 14. Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).
// Example:
// The 32-bit integer ’11' has binary representation
// 00000000000000000000000000001111
// so the function should return 3.
func numberOf1Bits(n: UInt) -> Int {
    var count = 0
    while n > 0 {
        count += n & 1
        n >>= 1
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------
// 15. Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).
// Example:
// The 32-bit integer ’11' has binary representation
// 00000000000000000000000000001111
// so the function should return 3.
func numberOf1Bits(n: UInt) -> Int {
    var count = 0
    while n > 0 {
        count += n & 1
        n >>= 1
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------
// 16. Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).
// Example:
// The 32-bit integer ’
for i in (1...n).reversed { // no 'reversed' overloads produce result type that conforms to 'Sequence'
n >>= 1 // left side of mutating operator isn't mutable: 'n' is a 'let' constant
count += n & 1 // cannot convert value of type 'UInt' to expected argument type 'Int'
n >>= 1 // left side of mutating operator isn't mutable: 'n' is a 'let' constant

func largestDivisor(n: Int) -> Int {
    for i in (1...n).reversed {
        if n % i == 0 {
            return i
        }
    }
    return 1
}

func isPrime(n: Int) -> Bool {
    if n == 1 {
        return false
    }
    for i in (2...n) {
        if n % i == 0 {
            return false
        }
    }
    return true
}

func sumTo(n: Int) -> Int {
    var sum = 0
    for i in (0...n) {
        sum += i
    }
    return sum
}

func factorial(n: Int) -> Int {
    var result = 1
    for i in (1...n) {
        result *= i
    }
    return result
}

func factorial(n: Int) -> [Int] {
    var result = [1]
    for i in (1...n) {
        result.append(result[i - 1] * i)
    }
    return result
}

func fibonacci(n: Int) -> [Int] {
    var result = [1, 1]
    for i in (2...n) {
        result.append(result[i - 1] + result[i - 2])
    }
    return result
}
```swift
// For a given number n, find the largest number that divides n evenly, smaller than n
// largestDivisor(n: 15) == 5
func largestDivisor(n: Int) -> Int {
    for i in (1...n).reversed {
        if n % i == 0 {
            return i
        }
    }
    return 1
}

// 2. Write a function that takes a number as an argument and returns a Boolean
// indicating whether the number is a prime number.
// isPrime(n: 15) == false
func isPrime(n: Int) -> Bool {
    if n == 1 {
        return false
    }
    for i in (2...n) {
        if n % i == 0 {
            return false
        }
    }
    return true
}

// 3. Write a function that takes a number as an argument and returns the
// sum of all numbers from 0 to the number.
// sumTo(n: 10) == 55
func sumTo(n: Int) -> Int {
    var sum = 0
    for i in (0...n) {
        sum += i
    }
    return sum
}

// 4. Write a function that takes a number as an argument and returns the
// factorial of that number.
// factorial(n: 5) == 120
func factorial(n: Int) -> Int {
    var result = 1
    for i in (1...n) {
        result *= i
    }
    return result
}

// 5. Write a function that takes a number as an argument and returns the
// factorial of the first n numbers.
// factorial(n: 5) == [1, 1, 2, 6, 24]
func factorial(n: Int) -> [Int] {
    var result = [1]
    for i in (1...n) {
        result.append(result[i - 1] * i)
    }
    return result
}

// 6. Write a function that takes a number as an argument and returns the
// Fibonacci sequence up to that number.
// fibonacci(n: 5) == [1, 1, 2, 3, 5]
func fibonacci(n: Int) -> [Int] {
    var result = [1, 1]
    for i in (2...n) {
        result.append(result[i - 1] + result[i - 2])
    }
    return result
}

// 7. Write a function that takes a number as an argument and returns the
// Fibonacci sequence up to the nth number.
// fibonacci(n: 5) == [1, 1, 2, 3, 5]
func fibonacci(n: Int) -> [Int] {
    var result = [1, 1]
    for i in (2...n) {
        result.append(result[i - 1] + result[i - 2])
    }
    return result
}

// 8. Write a function that takes a number as an argument and returns the
// Fibonacci sequence up to the nth number.
// fibonacci(n: 5) == [1, 1, 2, 3, 5]
func fibonacci(n: Int) -> [Int] {
    var result = [1, 1]
    for i in (2...n) {
        result.append(result[i - 1] + result[i - 2])
    }
    return result
}

// 9. Write a function that takes a number as an argument and returns the
// Fibonacci sequence up to the nth number.
// fibonacci(n: 5) == [1, 1, 2, 3, 5]
func fibonacci(n: Int) -> [Int] {
    var result = [1, 1]
    for i in (2...n) {
        result.append(result[i - 1] + result[i - 2])
    }
    return result
}

// 10. Write a function that takes a number as an argument and returns the
// Fibonacci sequence up to the nth number.
// fibonacci(n: 5) == [1, 1, 2, 3, 5]
for i in (1...n).reversed { // no 'reversed' overloads produce result type that conforms to 'Sequence'

func largestDivisor(n: Int) -> Int {
    for i in (1...n) {
        if n % i == 0 {
            return i
        }
    }
    return 1
}

func reverseString(string: String) -> String {
    return string.reversed().join()
}

func stringFromNumber(number: Int) -> String {
    return String(number)
}

func stringLength(string: String) -> Int {
    return string.count
}

func numberOfVowels(string: String) -> Int {
    return string.count(..., where: \Character.isVowel)
}

func numberOfConsonants(string: String) -> Int {
    return string.count(..., where: \Character.isConsonant)
}

func numberOfUpperCaseLetters(string: String) -> Int {
    return string.count(..., where: \Character.isUpperCase)
}

func numberOfLowerCaseLetters(string: String) -> Int {
    return string.count(..., where: \Character.isLowercase)
}

func numberOfDigits(string: String) -> Int {
    return string.count(..., where: \Character.isDigit)
}

func numberOfWords(string: String) -> Int {
    return string.split(..., options: .trimLeading | .trimTrailing).count
}
```swift
// For a given number n, find the largest number that divides n evenly, smaller than n
// largestDivisor(n: 15) == 5
func largestDivisor(n: Int) -> Int {
    for i in (1...n) {
        if n % i == 0 {
            return i
        }
    }
    return 1
}

// 11. Write a function that takes a string as parameter and returns a new string that
// contains all the characters of the input string in reverse order.
// reverseString("Hello") == "olleH"
func reverseString(string: String) -> String {
    return string.reversed().join()
}

// 12. Write a function that takes a number as parameter and returns a new string that
// contains the number as a string.
// stringFromNumber(123) == "123"
func stringFromNumber(number: Int) -> String {
    return String(number)
}

// 13. Write a function that takes a string as parameter and returns the number of
// characters in the string.
// stringLength("Hello") == 5
func stringLength(string: String) -> Int {
    return string.count
}

// 14. Write a function that takes a string as parameter and returns the number of
// vowels in the string.
// numberOfVowels("Hello") == 2
func numberOfVowels(string: String) -> Int {
    return string.count(..., where: \Character.isVowel)
}

// 15. Write a function that takes a string as parameter and returns the number of
// consonants in the string.
// numberOfConsonants("Hello") == 3
func numberOfConsonants(string: String) -> Int {
    return string.count(..., where: \Character.isConsonant)
}

// 16. Write a function that takes a string as parameter and returns the number of
// uppercase letters in the string.
// numberOfUpperCaseLetters("Hello") == 1
func numberOfUpperCaseLetters(string: String) -> Int {
    return string.count(..., where: \Character.isUpperCase)
}

// 17. Write a function that takes a string as parameter and returns the number of
// lowercase letters in the string.
// numberOfLowerCaseLetters("Hello") == 5
func numberOfLowerCaseLetters(string: String) -> Int {
    return string.count(..., where: \Character.isLowercase)
}

// 18. Write a function that takes a string as parameter and returns the number of
// digits in the string.
// numberOfDigits("Hello") == 0
func numberOfDigits(string: String) -> Int {
    return string.count(..., where: \Character.isDigit)
}

// 19. Write a function that takes a string as parameter and returns the number of
// words in the string.
// numberOfWords("Hello world") == 2
func numberOfWords(string: String) -> Int {
    return string.split(..., options: .trimLeading | .trimTrailing).count
}

// 20. Write a function that takes a string as parameter and returns the number of
// words in the string.
// numberOfWords("Hello world") == 2
func numberOfWords(string: String) -> Int {
    return string.split(..., options: .trimLeading | .trimTrailing).count
}

// 21. Write a function that takes a string as parameter and returns the number of
// words in the string.
// numberOfWords("Hello world") == 2
func numberOfWords(string: String) -> Int {
    return string.split(..., options: .trimLeading | .trimTrailing).count
}

// 22. Write a function that takes a string as parameter and returns the number of
// words in the string.
// numberOfWords("Hello world") == 2
func numberOfWords(string: String) -> Int {
    return string.split(..., options: .trimLeading | .trimTrailing).count
}

// 23. Write a function that takes a string as parameter and returns the number of
// words in the string.
// numberOfWords(
return string.reversed().join() // reference to member 'join' cannot be resolved without a contextual type
return string.count(..., where: \Character.isVowel) // value of type 'Character' has no member 'isVowel'
return string.count(..., where: \Character.isVowel) // cannot call value of non-function type 'Int'
return string.count(..., where: \Character.isConsonant) // cannot call value of non-function type 'Int'
return string.count(..., where: \Character.isConsonant) // value of type 'Character' has no member 'isConsonant'
return string.count(..., where: \Character.isUpperCase) // cannot call value of non-function type 'Int'
return string.count(..., where: \Character.isUpperCase) // value of type 'Character' has no member 'isUpperCase'
return string.count(..., where: \Character.isLowercase) // cannot call value of non-function type 'Int'
return string.count(..., where: \Character.isDigit) // value of type 'Character' has no member 'isDigit'
return string.count(..., where: \Character.isDigit) // cannot call value of non-function type 'Int'
return string.split(..., options: .trimLeading | .trimTrailing).count // no exact matches in call to instance method 'split'

func largestDivisor(n: Int) -> Int {
    for i in (1...n) {
        if n % i == 0 {
            return i
        }
    }
    return 1
}

func zeroPad(n: Int) -> Int {
    var result = 0
    var i = 1
    while n > 0 {
        result = result * 10 + n % 10
        n /= 10
    }
    return result
}
```swift
// For a given number n, find the largest number that divides n evenly, smaller than n
// largestDivisor(n: 15) == 5
func largestDivisor(n: Int) -> Int {
    for i in (1...n) {
        if n % i == 0 {
            return i
        }
    }
    return 1
}

// 10. Write a function that takes a number as an argument, and returns a new number where the digits of the new number are all the same as the original number.
// zeroPad(n: 100) == 100
// zeroPad(n: 1234) == 1234
func zeroPad(n: Int) -> Int {
    var result = 0
    var i = 1
    while n > 0 {
        result = result * 10 + n % 10
        n /= 10
    }
    return result
}

// 11. Write a function that takes a number as an argument, and returns a new number where the digits of the new number are all the same as the original number.
// zeroPad(n: 100) == 100
// zeroPad(n: 1234) == 1234
func zeroPad(n: Int) -> Int {
    var result = 0
    var i = 1
    while n > 0 {
        result = result * 10 + n % 10
        n /= 10
    }
    return result
}

// 12. Write a function that takes a number as an argument, and returns a new number where the digits of the new number are all the same as the original number.
// zeroPad(n: 100) == 100
// zeroPad(n: 1234) == 1234
func zeroPad(n: Int) -> Int {
    var result = 0
    var i = 1
    while n > 0 {
        result = result * 10 + n % 10
        n /= 10
    }
    return result
}

// 13. Write a function that takes a number as an argument, and returns a new number where the digits of the new number are all the same as the original number.
// zeroPad(n: 100) == 100
// zeroPad(n: 1234) == 1234
func zeroPad(n: Int) -> Int {
    var result = 0
    var i = 1
    while n > 0 {
        result = result * 10 + n % 10
        n /= 10
    }
    return result
}

// 14. Write a function that takes a number as an argument, and returns a new number where the digits of the new number are all the same as the original number.
// zeroPad(n: 100) == 100
// zeroPad(n: 1234) == 1234
func zeroPad(n: Int) -> Int {
    var result = 0
    var i = 1
    while n > 0 {
        result = result * 10 + n % 10
        n /= 10
    }
    return result
}

// 15. Write a function that takes a number as an argument, and returns a new number where the digits of the new number are all the same as the original number.
// zeroPad(n: 100) == 100
// zeroPad(n: 1234) == 1234
func zeroPad(n: Int) -> Int {
    var result = 0
    var i = 1
    while n > 0 {
        result = result * 10 + n % 10
        n /= 10
    }
    return result
}

// 16. Write a function that takes a number as an argument, and returns a new number where the digits of the new number are all the same as the original number.
// zeroPad(n: 100) == 100
// zeroPad(n: 1234) == 1234
func zeroPad(n: Int) -> Int {
    var result = 0
    var i = 1
    while n > 0 {
        result = result * 10 + n % 10
        n /= 10
    }
    return
n /= 10 // left side of mutating operator isn't mutable: 'n' is a 'let' constant

func largestDivisor(n: Int) -> Int {
    for i in (1...n).reversed {
        if n % i == 0 {
            return i
        }
    }
    return 1
}

func reverseString(s: String) -> String {
    return String(s.reversed())
}
```swift
// For a given number n, find the largest number that divides n evenly, smaller than n
// largestDivisor(n: 15) == 5
func largestDivisor(n: Int) -> Int {
    for i in (1...n).reversed {
        if n % i == 0 {
            return i
        }
    }
    return 1
}

// 2. Write a function that takes a string as input and returns the string reversed.
// reverseString("hello") == "olleh"
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// 3. Given an array nums of n integers where n > 1,  return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].
// Example:
// Input:  [1,2,3,4]
// Output: [24,12,8,6]
// Constraint: It's guaranteed that the product of the elements of any prefix or suffix of the array (including the whole array) fits in a 32 bit integer.
// Note: Please solve it without division and in O(n).
// Follow up:
// Could you solve it with constant space complexity? (The output array does not count as extra space for the purpose of space complexity analysis.)

// 4. Given an array of integers, return indices of the two numbers such that they add up to a specific target.
// You may assume that each input would have exactly one solution, and you may not use the same element twice.
// Example:
// Given nums = [2, 7, 11, 15], target = 9,
// Because nums[0] + nums[1] = 2 + 7 = 9,
// return [0, 1].

// 5. Given a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1.
// Example:
// s = "leetcode"
// return 0.
// s = "loveleetcode"
// return 2.

// 6. Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.
// Example:
// Input: "babad"
// Output: "bab"
// Note: "aba" is also a valid answer.
// Input: "cbbd"
// Output: "bb"

// 7. Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.
// Example:
// Input: "babad"
// Output: "bab"
// Note: "aba" is also a valid answer.
// Input: "cbbd"
// Output: "bb"

// 8. Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.
// Example:
// Input: "babad"
// Output: "bab"
// Note: "aba" is also a valid answer.
// Input: "cbbd"
// Output: "bb"

// 9. Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.
// Example:
// Input: "babad"
// Output: "bab"
// Note: "aba" is also a valid answer.
// Input: "cbbd"
// Output: "bb"

// 10. Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.
// Example:
// Input: "babad"
// Output: "bab"
// Note: "aba" is also a valid answer.
// Input: "cbbd"
// Output: "bb"

// 11. Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.
// Example:
// Input: "babad"
// Output: "bab"
// Note: "aba" is also a valid answer.
// Input: "cbbd"
// Output: "bb"

// 12. Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 10
for i in (1...n).reversed { // no 'reversed' overloads produce result type that conforms to 'Sequence'

func largestDivisor(n: Int) -> Int {
    for i in (1...n) {
        if n % i == 0 {
            return i
        }
    }
    return 1
}

func reverseString(s: String) -> String {
    return String(s.reversed())
}

func productExceptSelf(nums: [Int]) -> [Int] {
    var result = [1]
    for i in 1...nums.count {
        result.append(result[i-1] * nums[i-1])
    }
    var right = 1
    for i in (nums.count-1...0) {
        result[i] = result[i] * right
        right *= nums[i]
    }
    return result
}

func missingNumber(nums: [Int]) -> Int {
    var sum = 0
    for i in nums {
        sum += i
    }
    return (1...nums.count).sum() - sum
}

func missingNumber2(nums: [Int]) -> Int {
    var sum = 0
    for i in nums {
        sum += i
    }
    return (1...nums.count).sum() - sum
}

func missingNumber3(nums: [Int]) -> Int {
    var sum = 0
    for i in nums {
        sum += i
    }
    return (1...nums.count).sum() - sum
}

func missingNumber4(nums: [Int]) -> Int {
    var sum = 0
    for i in nums {
        sum += i
    }
    return (1...nums.count).sum() - sum
}

func missingNumber5(nums: [Int]) -> Int {
    var sum = 0
    for i in nums {
        sum += i
    }
    return (1...nums.count).sum() - sum
}

func missingNumber6(nums: [Int]) -> Int {
    var sum = 0
    for i in nums {
        sum += i
    }
    return (1...nums.count).sum() - sum
}
```swift
// For a given number n, find the largest number that divides n evenly, smaller than n
// largestDivisor(n: 15) == 5
func largestDivisor(n: Int) -> Int {
    for i in (1...n) {
        if n % i == 0 {
            return i
        }
    }
    return 1
}

// 2. Write a function that takes a string as input and returns the string reversed.
// reverseString("hello") == "olleh"
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// 3. Given an array nums of n integers where n > 1,  return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].
// productExceptSelf(nums: [1, 2, 3, 4]) == [24, 12, 8, 6]
func productExceptSelf(nums: [Int]) -> [Int] {
    var result = [1]
    for i in 1...nums.count {
        result.append(result[i-1] * nums[i-1])
    }
    var right = 1
    for i in (nums.count-1...0) {
        result[i] = result[i] * right
        right *= nums[i]
    }
    return result
}

// 4. Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array.
// missingNumber(nums: [3, 0, 1]) == 2
func missingNumber(nums: [Int]) -> Int {
    var sum = 0
    for i in nums {
        sum += i
    }
    return (1...nums.count).sum() - sum
}

// 5. Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array.
// missingNumber2(nums: [3, 0, 1]) == 2
func missingNumber2(nums: [Int]) -> Int {
    var sum = 0
    for i in nums {
        sum += i
    }
    return (1...nums.count).sum() - sum
}

// 6. Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array.
// missingNumber3(nums: [3, 0, 1]) == 2
func missingNumber3(nums: [Int]) -> Int {
    var sum = 0
    for i in nums {
        sum += i
    }
    return (1...nums.count).sum() - sum
}

// 7. Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array.
// missingNumber4(nums: [3, 0, 1]) == 2
func missingNumber4(nums: [Int]) -> Int {
    var sum = 0
    for i in nums {
        sum += i
    }
    return (1...nums.count).sum() - sum
}

// 8. Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array.
// missingNumber5(nums: [3, 0, 1]) == 2
func missingNumber5(nums: [Int]) -> Int {
    var sum = 0
    for i in nums {
        sum += i
    }
    return (1...nums.count).sum() - sum
}

// 9. Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array.
// missingNumber6(nums: [3, 0, 1]) == 2
func missingNumber6(nums: [Int]) -> Int {
    var sum = 0
    for i in nums {
        sum += i
    }
    return (1...nums.count).sum() - sum
}

// 10. Given an array nums containing n distinct numbers
return (1...nums.count).sum() - sum // value of type 'ClosedRange<Int>' has no member 'sum'
return (1...nums.count).sum() - sum // value of type 'ClosedRange<Int>' has no member 'sum'
return (1...nums.count).sum() - sum // value of type 'ClosedRange<Int>' has no member 'sum'
return (1...nums.count).sum() - sum // value of type 'ClosedRange<Int>' has no member 'sum'
return (1...nums.count).sum() - sum // value of type 'ClosedRange<Int>' has no member 'sum'
return (1...nums.count).sum() - sum // value of type 'ClosedRange<Int>' has no member 'sum'

func largestDivisor(n: Int) -> Int {
    for i in (1...n) {
        if n % i == 0 {
            return i
        }
    }
    return 1
}

func reverseString(s: String) -> String {
    return String(s.reversed())
}

func countBits(n: Int) -> Int {
    return String(n).filter(Character.isOne).count
}
```swift
// For a given number n, find the largest number that divides n evenly, smaller than n
// largestDivisor(n: 15) == 5
func largestDivisor(n: Int) -> Int {
    for i in (1...n) {
        if n % i == 0 {
            return i
        }
    }
    return 1
}

// 12. Write a function that takes a string as input and returns the string reversed.
// reverseString("hello") == "olleh"
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// 13. Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number.
// Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case
func countBits(n: Int) -> Int {
    return String(n).filter(Character.isOne).count
}

// 14. Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number.
// Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case
func countBits(n: Int) -> Int {
    return String(n).filter(Character.isOne).count
}

// 15. Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number.
// Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case
func countBits(n: Int) -> Int {
    return String(n).filter(Character.isOne).count
}

// 16. Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number.
// Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case
func countBits(n: Int) -> Int {
    return String(n).filter(Character.isOne).count
}

// 17. Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number.
// Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case
func countBits(n: Int) -> Int {
    return String(n).filter(Character.isOne).count
}

// 18. Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number.
// Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case
func countBits(n: Int) -> Int {
    return String(n).filter(Character.isOne).count
}

// 19. Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number.
// Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case
func countBits(n: Int) -> Int {
    return String(n).filter(Character.isOne).count
}

// 20. Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number.
// Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case
func countBits(n: Int) -> Int {
    return String(n).filter(Character.isOne).count
}

// 21. Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number.
// Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case
func countBits(n: Int) -> Int {
    return String(n
return String(n).filter(Character.isOne).count // type 'Character' has no member 'isOne'

func largestDivisor(n: Int) -> Int {
    for i in (1...n) {
        if n % i == 0 {
            return i
        }
    }
    return 1
}

func reverseString(s: String) -> String {
    return String(s.reversed())
}

func findNumbers(nums: [Int]) -> Int {
    var count = 0
    for num in nums {
        if String(num).count % 2 == 0 {
            count += 1
        }
    }
    return count
}
```swift
// For a given number n, find the largest number that divides n evenly, smaller than n
// largestDivisor(n: 15) == 5
func largestDivisor(n: Int) -> Int {
    for i in (1...n) {
        if n % i == 0 {
            return i
        }
    }
    return 1
}

// 2. Write a function that takes a string as input and returns the string reversed.
// reverseString("hello") == "olleh"
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// 3. Given an array nums of integers, return how many of them contain an even number of digits.
// findNumbers([12,345,2,6,7896]) == 2
// findNumbers([555,901,482,1771]) == 1
func findNumbers(nums: [Int]) -> Int {
    var count = 0
    for num in nums {
        if String(num).count % 2 == 0 {
            count += 1
        }
    }
    return count
}

// 4. Given an array nums of integers, return how many of them contain an even number of digits.
// findNumbers([12,345,2,6,7896]) == 2
// findNumbers([555,901,482,1771]) == 1
func findNumbers(nums: [Int]) -> Int {
    var count = 0
    for num in nums {
        if String(num).count % 2 == 0 {
            count += 1
        }
    }
    return count
}

// 5. Given an array nums of integers, return how many of them contain an even number of digits.
// findNumbers([12,345,2,6,7896]) == 2
// findNumbers([555,901,482,1771]) == 1
func findNumbers(nums: [Int]) -> Int {
    var count = 0
    for num in nums {
        if String(num).count % 2 == 0 {
            count += 1
        }
    }
    return count
}

// 6. Given an array nums of integers, return how many of them contain an even number of digits.
// findNumbers([12,345,2,6,7896]) == 2
// findNumbers([555,901,482,1771]) == 1
func findNumbers(nums: [Int]) -> Int {
    var count = 0
    for num in nums {
        if String(num).count % 2 == 0 {
            count += 1
        }
    }
    return count
}

// 7. Given an array nums of integers, return how many of them contain an even number of digits.
// findNumbers([12,345,2,6,7896]) == 2
// findNumbers([555,901,482,1771]) == 1
func findNumbers(nums: [Int]) -> Int {
    var count = 0
    for num in nums {
        if String(num).count % 2 == 0 {
            count += 1
        }
    }
    return count
}

// 8. Given an array nums of integers, return how many of them contain an even number of digits.
// findNumbers([12,345,2,6,7896]) == 2
// findNumbers([555,901,482,1771]) == 1
func findNumbers(nums: [Int]) -> Int {
    var count = 0
    for num in nums {
        if String(num).count % 2 == 0 {
            count += 1
        }
    }
    return count
}

// 9. Given an array nums of integers, return how many of them contain an even number of digits.
// findNumbers([12,345,2,6,7896]) == 2
// findNumbers([555,901,482,1771]) == 1
 // XCTAssertTrue failed

func largestDivisor(n: Int) -> Int {
    for i in (1...n).reversed {
        if n % i == 0 {
            return i
        }
    }
    return 1
}

func reverseString(s: String) -> String {
    return String(s.reversed())
}

func isIsomorphic(s: String, t: String) -> Bool {
    var sDict = [Character: Character]()
    var tDict = [Character: Character]()
    for i in 0..<s.count {
        if sDict[s[i]] == nil {
            sDict[s[i]] = t[i]
        } else if sDict[s[i]] != t[i] {
            return false
        }
        if tDict[t[i]] == nil {
            tDict[t[i]] = s[i]
        } else if tDict[t[i]] != s[i] {
            return false
        }
    }
    return true
}

func firstUniqChar(s: String) -> Int {
    var sDict = [Character: Int]()
    for i in 0..<s.count {
        if sDict[s[i]] == nil {
            sDict[s[i]] = i
        } else {
            sDict[s[i]] = -1
        }
    }
    var minIndex = Int.max
    for (key, value) in sDict {
        if value != -1 && value < minIndex {
            minIndex = value
        }
    }
    return minIndex == Int.max ? -1 : minIndex
}

func longestPalindrome(s: String) -> String {
    var maxLength = 0
    var maxString = ""
    for i in 0..<s.count {
        for j in i..<s.count {
            var subString = s[i..<j]
            if subString.length == j - i + 1 && subString == subString.reversed() {
                if subString.length > maxLength {
                    maxLength = subString.length
                    maxString = subString
                }
            }
        }
    }
    return maxString
}
```swift
// For a given number n, find the largest number that divides n evenly, smaller than n
// largestDivisor(n: 15) == 5
func largestDivisor(n: Int) -> Int {
    for i in (1...n).reversed {
        if n % i == 0 {
            return i
        }
    }
    return 1
}

// 2. Write a function that takes a string as input and returns the string reversed.
// reverseString("hello") == "olleh"
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// 3. Given two strings s and t, determine if they are isomorphic.
// Two strings s and t are isomorphic if the characters in s can be replaced to get t.
// All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters may map to the same character, but a character may map to itself.
// isIsomorphic(s: "egg", t: "add") == true
// isIsomorphic(s: "foo", t: "bar") == false
// isIsomorphic(s: "paper", t: "title") == true
func isIsomorphic(s: String, t: String) -> Bool {
    var sDict = [Character: Character]()
    var tDict = [Character: Character]()
    for i in 0..<s.count {
        if sDict[s[i]] == nil {
            sDict[s[i]] = t[i]
        } else if sDict[s[i]] != t[i] {
            return false
        }
        if tDict[t[i]] == nil {
            tDict[t[i]] = s[i]
        } else if tDict[t[i]] != s[i] {
            return false
        }
    }
    return true
}

// 4. Given a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1.
// firstUniqChar("leetcode") == 0
// firstUniqChar("loveleetcode") == 2
func firstUniqChar(s: String) -> Int {
    var sDict = [Character: Int]()
    for i in 0..<s.count {
        if sDict[s[i]] == nil {
            sDict[s[i]] = i
        } else {
            sDict[s[i]] = -1
        }
    }
    var minIndex = Int.max
    for (key, value) in sDict {
        if value != -1 && value < minIndex {
            minIndex = value
        }
    }
    return minIndex == Int.max ? -1 : minIndex
}

// 5. Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.
// longestPalindrome("babad") == "bab"
// longestPalindrome("cbbd") == "bb"
func longestPalindrome(s: String) -> String {
    var maxLength = 0
    var maxString = ""
    for i in 0..<s.count {
        for j in i..<s.count {
            var subString = s[i..<j]
            if subString.length == j - i + 1 && subString == subString.reversed() {
                if subString.length > maxLength {
                    maxLength = subString.length
                    maxString = subString
                }
            }
        }
    }
    return maxString
}

// 6. Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.
// longestPalindrome("babad") == "bab"
// longestPalindrome("cbbd") == "bb"
func longestPalindrome(s: String) -> String {
    var maxLength = 0
    var maxString = ""
    for i in 0..<s.count {
        for j in i..<s.count {
            var subString = s[i..<j]
            if subString.length == j - i + 1 && subString == subString.reversed() {
for i in (1...n).reversed { // no 'reversed' overloads produce result type that conforms to 'Sequence'
if sDict[s[i]] == nil { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
sDict[s[i]] = t[i] // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
sDict[s[i]] = t[i] // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
} else if sDict[s[i]] != t[i] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
} else if sDict[s[i]] != t[i] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if tDict[t[i]] == nil { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
tDict[t[i]] = s[i] // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
tDict[t[i]] = s[i] // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
} else if tDict[t[i]] != s[i] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
} else if tDict[t[i]] != s[i] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if sDict[s[i]] == nil { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
sDict[s[i]] = i // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
sDict[s[i]] = -1 // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
for (key, value) in sDict { // immutable value 'key' was never used; consider replacing with '_' or removing it
var subString = s[i..<j] // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.
if subString.length == j - i + 1 && subString == subString.reversed() { // value of type 'String' has no member 'length'
if subString.length == j - i + 1 && subString == subString.reversed() { // cannot convert value of type 'ReversedCollection<String>' to expected argument type 'String'
if subString.length > maxLength { // value of type 'String' has no member 'length'
maxLength = subString.length // value of type 'String' has no member 'length'

func factorize(n: Int) -> [Int] {
    var result = [Int]()
    var i = 2
    while i <= n {
        if n % i == 0 {
            result.append(i)
            n /= i
        } else {
            i += 1
        }
    }
    return result
}
```swift
// Return array of prime factors of given integer in the order from smallest to largest.
// Each of the factors should be arrayed number of times corresponding to how many times it appeares in factorization.
// Input number should be equal to the product of all factors
// factorize(n: 8) == [2, 2, 2]
// factorize(n: 25) == [5, 5]
// factorize(n: 70) == [2, 5, 7]
func factorize(n: Int) -> [Int] {
    var result = [Int]()
    var i = 2
    while i <= n {
        if n % i == 0 {
            result.append(i)
            n /= i
        } else {
            i += 1
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
n /= i // left side of mutating operator isn't mutable: 'n' is a 'let' constant

func factorize(n: Int) -> [Int] {
    var factors = [Int]()
    var i = 2
    while i <= n {
        if n % i == 0 {
            factors.append(i)
            n /= i
        } else {
            i += 1
        }
    }
    return factors
}
```swift
// Return array of prime factors of given integer in the order from smallest to largest.
// Each of the factors should be arrayed number of times corresponding to how many times it appeares in factorization.
// Input number should be equal to the product of all factors
// factorize(n: 8) == [2, 2, 2]
// factorize(n: 25) == [5, 5]
// factorize(n: 70) == [2, 5, 7]
func factorize(n: Int) -> [Int] {
    var factors = [Int]()
    var i = 2
    while i <= n {
        if n % i == 0 {
            factors.append(i)
            n /= i
        } else {
            i += 1
        }
    }
    return factors
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------------------------------------
n /= i // left side of mutating operator isn't mutable: 'n' is a 'let' constant

func factorize(n: Int) -> [Int] {
    var result = [Int]()
    var i = 2
    while i <= n {
        if n % i == 0 {
            result.append(i)
            n /= i
        } else {
            i += 1
        }
    }
    return result
}

func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char.isVowel() {
            continue
        }
        result += char
    }
    return result
}
```swift
// Return array of prime factors of given integer in the order from smallest to largest.
// Each of the factors should be arrayed number of times corresponding to how many times it appeares in factorization.
// Input number should be equal to the product of all factors
// factorize(n: 8) == [2, 2, 2]
// factorize(n: 25) == [5, 5]
// factorize(n: 70) == [2, 5, 7]
func factorize(n: Int) -> [Int] {
    var result = [Int]()
    var i = 2
    while i <= n {
        if n % i == 0 {
            result.append(i)
            n /= i
        } else {
            i += 1
        }
    }
    return result
}

// 2.
// Write a function that takes a string and returns a new string with all vowels removed.
// The function should be case-insensitive, so "Um..." should return "m...".
// removeVowels("Um...") == "m..."
// removeVowels("Hello, world!") == "Hll, wrld!"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char.isVowel() {
            continue
        }
        result += char
    }
    return result
}

// 3.
// Write a function that takes a string and returns a new string with all the vowels removed.
// The function should be case-insensitive, so "Um..." should return "m...".
// removeVowels("Um...") == "m..."
// removeVowels("Hello, world!") == "Hll, wrld!"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char.isVowel() {
            continue
        }
        result += char
    }
    return result
}

// 4.
// Write a function that takes a string and returns a new string with all the vowels removed.
// The function should be case-insensitive, so "Um..." should return "m...".
// removeVowels("Um...") == "m..."
// removeVowels("Hello, world!") == "Hll, wrld!"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char.isVowel() {
            continue
        }
        result += char
    }
    return result
}

// 5.
// Write a function that takes a string and returns a new string with all the vowels removed.
// The function should be case-insensitive, so "Um..." should return "m...".
// removeVowels("Um...") == "m..."
// removeVowels("Hello, world!") == "Hll, wrld!"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char.isVowel() {
            continue
        }
        result += char
    }
    return result
}

// 6.
// Write a function that takes a string and returns a new string with all the vowels removed.
// The function should be case-insensitive, so "Um..." should return "m...".
// removeVowels("Um...") == "m..."
// removeVowels("Hello, world!") == "Hll, wrld!"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char.isVowel() {
            continue
        }
        result += char
    }
    return result
}

// 7.
// Write a function that takes a string and returns a new string with all the vowels removed.
// The function should be case-insensitive, so "Um..." should return "m...".
// removeVowels("Um...") == "m..."
// removeVowels("Hello, world!") == "Hll, wrld!"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char.isVowel() {
            continue
        }
        result += char
    }
    return result
}
n /= i // left side of mutating operator isn't mutable: 'n' is a 'let' constant
if char.isVowel() { // value of type 'Character' has no member 'isVowel'
result += char // cannot convert value of type 'Character' to expected argument type 'String'

func factorize(n: Int) -> [Int] {
    var factors = [Int]()
    var i = 2
    while n > 1 {
        while n % i == 0 {
            factors.append(i)
            n /= i
        }
        i += 1
    }
    return factors
}
```swift
// Return array of prime factors of given integer in the order from smallest to largest.
// Each of the factors should be arrayed number of times corresponding to how many times it appeares in factorization.
// Input number should be equal to the product of all factors
// factorize(n: 8) == [2, 2, 2]
// factorize(n: 25) == [5, 5]
// factorize(n: 70) == [2, 5, 7]
func factorize(n: Int) -> [Int] {
    var factors = [Int]()
    var i = 2
    while n > 1 {
        while n % i == 0 {
            factors.append(i)
            n /= i
        }
        i += 1
    }
    return factors
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------------------------------------------------
n /= i // left side of mutating operator isn't mutable: 'n' is a 'let' constant

func factorize(n: Int) -> [Int] {
    var result = [Int]()
    var i = 2
    while i <= n {
        if n % i == 0 {
            result.append(i)
            n /= i
        } else {
            i += 1
        }
    }
    return result
}
```swift
// Return array of prime factors of given integer in the order from smallest to largest.
// Each of the factors should be arrayed number of times corresponding to how many times it appeares in factorization.
// Input number should be equal to the product of all factors
// factorize(n: 8) == [2, 2, 2]
// factorize(n: 25) == [5, 5]
// factorize(n: 70) == [2, 5, 7]
func factorize(n: Int) -> [Int] {
    var result = [Int]()
    var i = 2
    while i <= n {
        if n % i == 0 {
            result.append(i)
            n /= i
        } else {
            i += 1
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
n /= i // left side of mutating operator isn't mutable: 'n' is a 'let' constant

func factorize(n: Int) -> [Int] {
    var factors = [Int]()
    var i = 2
    while i * i <= n {
        if n % i == 0 {
            factors.append(i)
            n /= i
        } else {
            i += 1
        }
    }
    if n > 1 {
        factors.append(n)
    }
    return factors
}
```swift
// Return array of prime factors of given integer in the order from smallest to largest.
// Each of the factors should be arrayed number of times corresponding to how many times it appeares in factorization.
// Input number should be equal to the product of all factors
// factorize(n: 8) == [2, 2, 2]
// factorize(n: 25) == [5, 5]
// factorize(n: 70) == [2, 5, 7]
func factorize(n: Int) -> [Int] {
    var factors = [Int]()
    var i = 2
    while i * i <= n {
        if n % i == 0 {
            factors.append(i)
            n /= i
        } else {
            i += 1
        }
    }
    if n > 1 {
        factors.append(n)
    }
    return factors
}

// ----------------------------------------------------------------------------------------------------------------------

// 1. Write a function that takes a string and returns a new string with all vowels removed.
// Input: "Hello, world!"
// Output: "Hll, wrld!"
// Input: "aeiou"
// Output: ""
// Input: ""
// Output: ""
// Input: "a"
// Output: ""
// Input: "A"
// Output: ""
// Input: "Ae"
// Output: ""
// Input: "aeiouAEIOU"
// Output: ""
// Input: "aeiouAEIOU12345"
// Output: "12345"
// Input: "aeiouAEIOU12345!@#$%^&*()"
// Output: "12345!@#$%^&*()"
// Input: "aeiouAEIOU12345!@#$%^&*()12345!@#$%^&*()"
// Output: ""
// Input: "aeiouAEIOU12345!@#$%^&*()12345!@#$%^&*()12345!@#$%^&*()"
// Output: ""
// Input: "aeiouAEIOU12345!@#$%^&*()12345!@#$%^&*()12345!@#$%^&*()12345!@#$%^&*()"
// Output: ""
// Input: "aeiouAEIOU12345!@#$%^&*()12345!@#$%^&*()12345!@#$%^&*()12345!@#$%^&*()12345!@#$%^&*()"
// Output: ""
// Input: "aeiouAEIOU12345!@#$%^&*()12345!@#$%^&*()12345!@#$%^&*()12345!@#$%^&*()12345!@#$%^&*()12345!@#$%^&*()"
// Output: ""
// Input: "aeiouAEIOU12345!@#$%^&*()12345!@#$%^&*()12345!@#$%^&*()12345!@#$%^&*()12345!@#$%^&*()12345!@#$%^&*()12345!@#$%^&*()12345!@#$%^&*()"
// Output: ""
// Input: "aeiouAEIOU12345!@#$%^&*()12345!@#$%^&*()12345!@#$%^&*()12345!@#$%^&*()12345!@#$%^&*()12345!@#$%^&*()12345!@#$%^&*()12345!@#$%^&*()12345!@#$%^&*()12345!@#$%^&*()12345!@#$%^&*()12345!@#$%^&*()12345!@#$%^&*()12345!@#$%^&*()12345!@#$%^&*()12345!
n /= i // left side of mutating operator isn't mutable: 'n' is a 'let' constant

func factorize(n: Int) -> [Int] {
    var factors = [Int]()
    var i = 2
    while i <= n {
        if n % i == 0 {
            factors.append(i)
            n /= i
        } else {
            i += 1
        }
    }
    return factors
}
```swift
// Return array of prime factors of given integer in the order from smallest to largest.
// Each of the factors should be arrayed number of times corresponding to how many times it appeares in factorization.
// Input number should be equal to the product of all factors
// factorize(n: 8) == [2, 2, 2]
// factorize(n: 25) == [5, 5]
// factorize(n: 70) == [2, 5, 7]
func factorize(n: Int) -> [Int] {
    var factors = [Int]()
    var i = 2
    while i <= n {
        if n % i == 0 {
            factors.append(i)
            n /= i
        } else {
            i += 1
        }
    }
    return factors
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
n /= i // left side of mutating operator isn't mutable: 'n' is a 'let' constant

func factorize(n: Int) -> [Int] {
    var factors = [Int]()
    var i = 2
    while n > 1 {
        if n % i == 0 {
            factors.append(i)
            n /= i
        } else {
            i += 1
        }
    }
    return factors
}
```swift
// Return array of prime factors of given integer in the order from smallest to largest.
// Each of the factors should be arrayed number of times corresponding to how many times it appeares in factorization.
// Input number should be equal to the product of all factors
// factorize(n: 8) == [2, 2, 2]
// factorize(n: 25) == [5, 5]
// factorize(n: 70) == [2, 5, 7]
func factorize(n: Int) -> [Int] {
    var factors = [Int]()
    var i = 2
    while n > 1 {
        if n % i == 0 {
            factors.append(i)
            n /= i
        } else {
            i += 1
        }
    }
    return factors
}

// ----------------------------------------------------------------------------------------------------------------------

// 1. Write a function that takes a string as input and returns the string reversed.
// Example:
// Given s = "hello", return "olleh".

// ----------------------------------------------------------------------------------------------------------------------

// 2. Given an array of integers, return indices of the two numbers such that they add up to a specific target.
// You may assume that each input would have exactly one solution, and you may not use the same element twice.
// Example:
// Given nums = [2, 7, 11, 15], target = 9,
// Because nums[0] + nums[1] = 2 + 7 = 9,
// return [0, 1].

// ----------------------------------------------------------------------------------------------------------------------

// 3. Given an array of integers, return indices of the two numbers such that they add up to a specific target.
// You may assume that each input would have exactly one solution, and you may not use the same element twice.
// Example:
// Given nums = [2, 7, 11, 15], target = 9,
// Because nums[0] + nums[1] = 2 + 7 = 9,
// return [0, 1].

// ----------------------------------------------------------------------------------------------------------------------

// 4. Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
// Note: For the purpose of this problem, we define empty string as valid palindrome.
// Example 1:
// Input: "A man, a plan, a canal: Panama"
// Output: true
// Example 2:
// Input: "race a car"
// Output: false

// ----------------------------------------------------------------------------------------------------------------------

// 5. Given an array of integers, return indices of the two numbers such that they add up to a specific target.
// You may assume that each input would have exactly one solution, and you may not use the same element twice.
// Example:
// Given nums = [2, 7, 11, 15], target = 9,
// Because nums[0] + nums[1] = 2 + 7 = 9,
// return [0, 1].

// ----------------------------------------------------------------------------------------------------------------------

// 6. Given an array of integers, return indices of the two numbers such that they add up to a specific target.
// You may assume that each input would have exactly one solution, and you may not use the same element twice.
// Example:
// Given nums = [2, 7, 11, 15], target = 9,
// Because nums[0] + nums[1] = 2 + 7 = 9,
// return [0, 1].

// ----------------------------------------------------------------------------------------------------------------------

// 7. Given an array of integers, return indices of the two numbers such that they add up to a specific target.
// You may assume that each input would have exactly one solution,
n /= i // left side of mutating operator isn't mutable: 'n' is a 'let' constant

func factorize(n: Int) -> [Int] {
    var result = [Int]()
    var i = 2
    while n > 1 {
        while n % i == 0 {
            result.append(i)
            n /= i
        }
        i += 1
    }
    return result
}
```swift
// Return array of prime factors of given integer in the order from smallest to largest.
// Each of the factors should be arrayed number of times corresponding to how many times it appeares in factorization.
// Input number should be equal to the product of all factors
// factorize(n: 8) == [2, 2, 2]
// factorize(n: 25) == [5, 5]
// factorize(n: 70) == [2, 5, 7]
func factorize(n: Int) -> [Int] {
    var result = [Int]()
    var i = 2
    while n > 1 {
        while n % i == 0 {
            result.append(i)
            n /= i
        }
        i += 1
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ---
n /= i // left side of mutating operator isn't mutable: 'n' is a 'let' constant

func factorize(n: Int) -> [Int] {
    var result = [Int]()
    var i = 2
    while i <= n {
        if n % i == 0 {
            result.append(i)
            n /= i
        } else {
            i += 1
        }
    }
    return result
}
```swift
// Return array of prime factors of given integer in the order from smallest to largest.
// Each of the factors should be arrayed number of times corresponding to how many times it appeares in factorization.
// Input number should be equal to the product of all factors
// factorize(n: 8) == [2, 2, 2]
// factorize(n: 25) == [5, 5]
// factorize(n: 70) == [2, 5, 7]
func factorize(n: Int) -> [Int] {
    var result = [Int]()
    var i = 2
    while i <= n {
        if n % i == 0 {
            result.append(i)
            n /= i
        } else {
            i += 1
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// 1. Write a function that takes a string and returns a new string with all vowels removed.
// Input: "Hello World"
// Output: "Hll Wrld"
// Input: "Hello World!"
// Output: "Hll Wrld!"
// Input: "Hello World!!!"
// Output: "Hll Wrld!!!"
// Input: "Hello World!!!!"
// Output: "Hll Wrld!!!!"
// Input: "Hello World!!!!!"
// Output: "Hll Wrld!!!!!"
// Input: "Hello World!!!!!!"
// Output: "Hll Wrld!!!!!!"
// Input: "Hello World!!!!!!!"
// Output: "Hll Wrld!!!!!!!"
// Input: "Hello World!!!!!!!!"
// Output: "Hll Wrld!!!!!!!!"
// Input: "Hello World!!!!!!!!!"
// Output: "Hll Wrld!!!!!!!!!"
// Input: "Hello World!!!!!!!!!!"
// Output: "Hll Wrld!!!!!!!!!!"
// Input: "Hello World!!!!!!!!!!!"
// Output: "Hll Wrld!!!!!!!!!!!"
// Input: "Hello World!!!!!!!!!!!!"
// Output: "Hll Wrld!!!!!!!!!!!!"
// Input: "Hello World!!!!!!!!!!!!!"
// Output: "Hll Wrld!!!!!!!!!!!!!"
// Input: "Hello World!!!!!!!!!!!!!!"
// Output: "Hll Wrld!!!!!!!!!!!!!!"
// Input: "Hello World!!!!!!!!!!!!!!!"
// Output: "Hll Wrld!!!!!!!!!!!!!!!"
// Input: "Hello World!!!!!!!!!!!!!!!!"
// Output: "Hll Wrld!!!!!!!!!!!!!!!!"
// Input: "Hello World!!!!!!!!!!!!!!!!!"
// Output: "Hll Wrld!!!!!!!!!!!!!!!!!"
// Input: "Hello World!!!!!!!!!!!!!!!!!!"
// Output: "Hll Wrld!!!!!!!!!!!!!!!!!!"
// Input: "Hello World!!!!!!!!!!!!!!!!!!!"
// Output: "Hll Wrld!!!!!!!!!!!!!!!!!!!"
// Input: "Hello World!!!!!!!!!!!!!!!!!!!!"
// Output: "Hll Wrld!!!!!!!!!!!!!!!!!!!!"
// Input: "Hello World!!!!!!!!!!!!!!!!!!!!!"
// Output: "Hll Wrld!!!!!!!!!!!!!!!!!!!!!"
// Input: "Hello World!!!!!!!!!!!!!!!!!!!!!!
n /= i // left side of mutating operator isn't mutable: 'n' is a 'let' constant

func removeDuplicates(numbers: [Int]) -> [Int] {
    var result = [Int]()
    for number in numbers {
        if !result.contains(number) {
            result.append(number)
        }
    }
    return result
}
```swift
// From an array of integers, remove all elements that occur more than once.
// Keep order of elements left the same as in the input.
// removeDuplicates(numbers: [1, 2, 3, 2, 4]) == [1, 3, 4]
func removeDuplicates(numbers: [Int]) -> [Int] {
    var result = [Int]()
    for number in numbers {
        if !result.contains(number) {
            result.append(number)
        }
    }
    return result
}

// -----------------------------------------------------------------------------

// 1.1
// Given two strings, write a method to decide if one is a permutation of the other.
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation("abcd", "dabc") == true
// permutation(
 // XCTAssertTrue failed

func removeDuplicates(numbers: [Int]) -> [Int] {
    var result = [Int]()
    for number in numbers {
        if !result.contains(number) {
            result.append(number)
        }
    }
    return result
}

func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char: char) {
            result += char
        }
    }
    return result
}
```swift
// From an array of integers, remove all elements that occur more than once.
// Keep order of elements left the same as in the input.
// removeDuplicates(numbers: [1, 2, 3, 2, 4]) == [1, 3, 4]
func removeDuplicates(numbers: [Int]) -> [Int] {
    var result = [Int]()
    for number in numbers {
        if !result.contains(number) {
            result.append(number)
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 2. Write a function that takes a string and returns a new string with all the
// vowels removed.
// removeVowels("I love apples!") == " lv pls!"
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char: char) {
            result += char
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 3. Write a function that takes a string and returns a new string with all the
// vowels removed.
// removeVowels("I love apples!") == " lv pls!"
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char: char) {
            result += char
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 4. Write a function that takes a string and returns a new string with all the
// vowels removed.
// removeVowels("I love apples!") == " lv pls!"
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char: char) {
            result += char
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 5. Write a function that takes a string and returns a new string with all the
// vowels removed.
// removeVowels("I love apples!") == " lv pls!"
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char: char) {
            result += char
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 6. Write a function that takes a string and returns a new string with all the
// vowels removed.
// removeVowels("I love apples!") == " lv pls!"
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char: char) {
            result += char
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 7. Write a function that takes a string and returns a new string with all the
// vowels removed.
// removeVowels("I love apples!") == " lv pls!"
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char: char) {
            result += char
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 8. Write a function that takes a string and returns a new string with all the
// vowels removed.
// removeVowels("I love apples!") == " lv pls!"
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char: char) {
            result += char
        }
    }
    return result
}

// ------------------
if !isVowel(char: char) { // cannot find 'isVowel' in scope
result += char // cannot convert value of type 'Character' to expected argument type 'String'

func removeDuplicates(numbers: [Int]) -> [Int] {
    var result = [Int]()
    for number in numbers {
        if !result.contains(number) {
            result.append(number)
        }
    }
    return result
}

func vowelFree(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

func charCount(string: String) -> Int {
    var result = 0
    for char in string {
        result += 1
    }
    return result
}
```swift
// From an array of integers, remove all elements that occur more than once.
// Keep order of elements left the same as in the input.
// removeDuplicates(numbers: [1, 2, 3, 2, 4]) == [1, 3, 4]
func removeDuplicates(numbers: [Int]) -> [Int] {
    var result = [Int]()
    for number in numbers {
        if !result.contains(number) {
            result.append(number)
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.2.1
// -----------------------------------------------------------------------------
// Given a string, return a new string with all the vowels removed.
// vowelFree("Hello, world!") == "Hllwlr!"
func vowelFree(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.2.2
// -----------------------------------------------------------------------------
// Given a string, return the number of times the character appears in the string.
// charCount("Hello, world!") == 3
func charCount(string: String) -> Int {
    var result = 0
    for char in string {
        result += 1
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.2.3
// -----------------------------------------------------------------------------
// Given a string, return the number of times the character appears in the string.
// charCount("Hello, world!") == 3
func charCount(string: String) -> Int {
    var result = 0
    for char in string {
        result += 1
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.2.4
// -----------------------------------------------------------------------------
// Given a string, return the number of times the character appears in the string.
// charCount("Hello, world!") == 3
func charCount(string: String) -> Int {
    var result = 0
    for char in string {
        result += 1
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.2.5
// -----------------------------------------------------------------------------
// Given a string, return the number of times the character appears in the string.
// charCount("Hello, world!") == 3
func charCount(string: String) -> Int {
    var result = 0
    for char in string {
        result += 1
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.2.6
// -----------------------------------------------------------------------------
// Given a string, return the number of times the character appears in the string.
// charCount("Hello, world!") == 3
func charCount(string: String) -> Int {
    var result = 0
    for char in string {
        result += 1
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.2.7
// -----------------------------------------------------------------------------
// Given a string, return the number of times the character appears in the string.
// charCount("Hello, world!") == 3
func charCount(string: String)
if !isVowel(char) { // cannot find 'isVowel' in scope
result += char // cannot convert value of type 'Character' to expected argument type 'String'
for char in string { // immutable value 'char' was never used; consider replacing with '_' or removing it

func removeDuplicates(numbers: [Int]) -> [Int] {
    var result = [Int]()
    for number in numbers {
        if !result.contains(number) {
            result.append(number)
        }
    }
    return result
}
```swift
// From an array of integers, remove all elements that occur more than once.
// Keep order of elements left the same as in the input.
// removeDuplicates(numbers: [1, 2, 3, 2, 4]) == [1, 3, 4]
func removeDuplicates(numbers: [Int]) -> [Int] {
    var result = [Int]()
    for number in numbers {
        if !result.contains(number) {
            result.append(number)
        }
    }
    return result
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// ------------------------------------
 // XCTAssertTrue failed

func removeDuplicates(numbers: [Int]) -> [Int] {
    var result = [Int]()
    var seen = [Int]()
    for number in numbers {
        if !seen.contains(number) {
            result.append(number)
            seen.append(number)
        }
    }
    return result
}

func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}
```swift
// From an array of integers, remove all elements that occur more than once.
// Keep order of elements left the same as in the input.
// removeDuplicates(numbers: [1, 2, 3, 2, 4]) == [1, 3, 4]
func removeDuplicates(numbers: [Int]) -> [Int] {
    var result = [Int]()
    var seen = [Int]()
    for number in numbers {
        if !seen.contains(number) {
            result.append(number)
            seen.append(number)
        }
    }
    return result
}

// 2. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I love cats") == "l vcts"
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// 3. Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels("I love cats") == "l vcts"
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// 4. Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels("I love cats") == "l vcts"
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// 5. Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels("I love cats") == "l vcts"
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// 6. Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels("I love cats") == "l vcts"
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// 7. Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels("I love cats") == "l vcts"
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// 8. Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels("I love cats") == "l vcts"
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// 9. Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels("I love cats") == "l vcts"
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// 10. Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels("I love cats") == "l vcts"
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// 11. Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels
if !isVowel(char) { // cannot find 'isVowel' in scope
result += char // cannot convert value of type 'Character' to expected argument type 'String'

func removeDuplicates(numbers: [Int]) -> [Int] {
    var result = [Int]()
    for number in numbers {
        if !result.contains(number) {
            result.append(number)
        }
    }
    return result
}

func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if !isVowel(char: char) {
            result += char
        }
    }
    return result
}

func removeS(input: String) -> String {
    var result = ""
    for char in input {
        if char != "S" {
            result += char
        }
    }
    return result
}
```swift
// From an array of integers, remove all elements that occur more than once.
// Keep order of elements left the same as in the input.
// removeDuplicates(numbers: [1, 2, 3, 2, 4]) == [1, 3, 4]
func removeDuplicates(numbers: [Int]) -> [Int] {
    var result = [Int]()
    for number in numbers {
        if !result.contains(number) {
            result.append(number)
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 2. Write a function that takes a string and returns a new string with all
// vowels removed.
// removeVowels("I am a string") == " m  strng"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if !isVowel(char: char) {
            result += char
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 3. Write a function that takes a string and returns a new string with all
// the "S" characters removed.
// removeS("String") == "Trng"
func removeS(input: String) -> String {
    var result = ""
    for char in input {
        if char != "S" {
            result += char
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 4. Write a function that takes a string and returns a new string with all
// the "S" characters removed.
// removeS("String") == "Trng"
func removeS(input: String) -> String {
    var result = ""
    for char in input {
        if char != "S" {
            result += char
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 5. Write a function that takes a string and returns a new string with all
// the "S" characters removed.
// removeS("String") == "Trng"
func removeS(input: String) -> String {
    var result = ""
    for char in input {
        if char != "S" {
            result += char
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 6. Write a function that takes a string and returns a new string with all
// the "S" characters removed.
// removeS("String") == "Trng"
func removeS(input: String) -> String {
    var result = ""
    for char in input {
        if char != "S" {
            result += char
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 7. Write a function that takes a string and returns a new string with all
// the "S" characters removed.
// removeS("String") == "Trng"
func removeS(input: String) -> String {
    var result = ""
    for char in input {
        if char != "S" {
            result += char
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 8. Write a function that takes a string and returns a new string with all
// the "S" characters removed.
// removeS("String") == "Trng"
func removeS(input: String) -> String {
    var result = ""
    for char in input {
        if char != "S" {
            result += char
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 9. Write a function that takes a string and returns a new string with all
// the "S" characters removed.
// removeS("String") == "Trng"
func removeS(input: String) -> String {
if !isVowel(char: char) { // cannot find 'isVowel' in scope
result += char // cannot convert value of type 'Character' to expected argument type 'String'
result += char // cannot convert value of type 'Character' to expected argument type 'String'

func removeDuplicates(numbers: [Int]) -> [Int] {
    var result = [Int]()
    for number in numbers {
        if !result.contains(number) {
            result.append(number)
        }
    }
    return result
}
```swift
// From an array of integers, remove all elements that occur more than once.
// Keep order of elements left the same as in the input.
// removeDuplicates(numbers: [1, 2, 3, 2, 4]) == [1, 3, 4]
func removeDuplicates(numbers: [Int]) -> [Int] {
    var result = [Int]()
    for number in numbers {
        if !result.contains(number) {
            result.append(number)
        }
    }
    return result
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

 // XCTAssertTrue failed

func removeDuplicates(numbers: [Int]) -> [Int] {
    var result = [Int]()
    var last = 0
    for n in numbers {
        if n != last {
            result.append(n)
            last = n
        }
    }
    return result
}
```swift
// From an array of integers, remove all elements that occur more than once.
// Keep order of elements left the same as in the input.
// removeDuplicates(numbers: [1, 2, 3, 2, 4]) == [1, 3, 4]
func removeDuplicates(numbers: [Int]) -> [Int] {
    var result = [Int]()
    var last = 0
    for n in numbers {
        if n != last {
            result.append(n)
            last = n
        }
    }
    return result
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// ---------
 // XCTAssertTrue failed

func removeDuplicates(numbers: [Int]) -> [Int] {
    var result = [Int]()
    var seen = [Int]()
    for number in numbers {
        if !seen.contains(number) {
            result.append(number)
            seen.append(number)
        }
    }
    return result
}
```swift
// From an array of integers, remove all elements that occur more than once.
// Keep order of elements left the same as in the input.
// removeDuplicates(numbers: [1, 2, 3, 2, 4]) == [1, 3, 4]
func removeDuplicates(numbers: [Int]) -> [Int] {
    var result = [Int]()
    var seen = [Int]()
    for number in numbers {
        if !seen.contains(number) {
            result.append(number)
            seen.append(number)
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ---------------------------------------------------
 // XCTAssertTrue failed

func removeDuplicates(numbers: [Int]) -> [Int] {
    var result = [Int]()
    for number in numbers {
        if !result.contains(number) {
            result.append(number)
        }
    }
    return result
}
```swift
// From an array of integers, remove all elements that occur more than once.
// Keep order of elements left the same as in the input.
// removeDuplicates(numbers: [1, 2, 3, 2, 4]) == [1, 3, 4]
func removeDuplicates(numbers: [Int]) -> [Int] {
    var result = [Int]()
    for number in numbers {
        if !result.contains(number) {
            result.append(number)
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ------------
 // XCTAssertTrue failed

func flipCase(string: String) -> String {
    return string.map { $0.isUpperCase() ? $0.toLowerCase() : $0.toUpperCase() }.join()
}
```swift
// For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
// flipCase(string: "Hello") == "hELLO"
func flipCase(string: String) -> String {
    return string.map { $0.isUpperCase() ? $0.toLowerCase() : $0.toUpperCase() }.join()
}

// ----------------------------------------------------------------------------------------------------------------------
// 1.12.1.1.2.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.
return string.map { $0.isUpperCase() ? $0.toLowerCase() : $0.toUpperCase() }.join() // value of type 'String.Element' (aka 'Character') has no member 'isUpperCase'
return string.map { $0.isUpperCase() ? $0.toLowerCase() : $0.toUpperCase() }.join() // value of type 'Array<_>' has no member 'join'
return string.map { $0.isUpperCase() ? $0.toLowerCase() : $0.toUpperCase() }.join() // value of type 'String.Element' (aka 'Character') has no member 'toUpperCase'
return string.map { $0.isUpperCase() ? $0.toLowerCase() : $0.toUpperCase() }.join() // value of type 'String.Element' (aka 'Character') has no member 'toLowerCase'

func flipCase(string: String) -> String {
    return string.map { $0.isUpperCase() ? $0.toLowerCase() : $0.toUpperCase() }.join()
}
```swift
// For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
// flipCase(string: "Hello") == "hELLO"
func flipCase(string: String) -> String {
    return string.map { $0.isUpperCase() ? $0.toLowerCase() : $0.toUpperCase() }.join()
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ------------------------------------------------
return string.map { $0.isUpperCase() ? $0.toLowerCase() : $0.toUpperCase() }.join() // value of type 'String.Element' (aka 'Character') has no member 'isUpperCase'
return string.map { $0.isUpperCase() ? $0.toLowerCase() : $0.toUpperCase() }.join() // value of type 'Array<_>' has no member 'join'
return string.map { $0.isUpperCase() ? $0.toLowerCase() : $0.toUpperCase() }.join() // value of type 'String.Element' (aka 'Character') has no member 'toUpperCase'
return string.map { $0.isUpperCase() ? $0.toLowerCase() : $0.toUpperCase() }.join() // value of type 'String.Element' (aka 'Character') has no member 'toLowerCase'

func flipCase(string: String) -> String {
    return string.map {
        if $0.isLowercase {
            return $0.uppercaseString
        } else {
            return $0.lowercaseString
        }
    }.joined()
}
```swift
// For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
// flipCase(string: "Hello") == "hELLO"
func flipCase(string: String) -> String {
    return string.map {
        if $0.isLowercase {
            return $0.uppercaseString
        } else {
            return $0.lowercaseString
        }
    }.joined()
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

//
return $0.uppercaseString // value of type 'String.Element' (aka 'Character') has no member 'uppercaseString'

func flipCase(string: String) -> String {
    return string.map {
        if $0.isLowercase {
            return $0.uppercase
        } else {
            return $0.lowercase
        }
    }
}

func countVowels(string: String) -> Int {
    return string.count(.vowel)
}

func isPalindrome(string: String) -> Bool {
    return string.reversed == string
}

func doubleChar(string: String) -> String {
    return string.map { $0 * 2 }
}

func swapFirstLast(string: String) -> String {
    return string.last + string.substring(1, string.count - 2) + string.first
}

func removeVowels(string: String) -> String {
    return string.remove(.vowel)
}
```swift
// For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
// flipCase(string: "Hello") == "hELLO"
func flipCase(string: String) -> String {
    return string.map {
        if $0.isLowercase {
            return $0.uppercase
        } else {
            return $0.lowercase
        }
    }
}

// ----------------------------------------------------------------------------------------------------------------------

// 12. Write a function that takes a string and returns the number (count) of vowels contained within it.
// countVowels(string: "Celebration") == 5
// countVowels(string: "Palm") == 1
func countVowels(string: String) -> Int {
    return string.count(.vowel)
}

// ----------------------------------------------------------------------------------------------------------------------

// 13. Write a function that takes a string and returns true if the string is a palindrome, and false otherwise.
// isPalindrome(string: "topot") == true
// isPalindrome(string: "Alibi") == true
// isPalindrome(string: "Racecar") == true
// isPalindrome(string: "Greetings") == false
func isPalindrome(string: String) -> Bool {
    return string.reversed == string
}

// ----------------------------------------------------------------------------------------------------------------------

// 14. Write a function that takes a string and returns a string in which each character is repeated once.
// doubleChar(string: "String") == "SSttrriinngg"
// doubleChar(string: "Hello World!") == "HHeelllloo  WWoorrlldd!!"
// doubleChar(string: "1234!_ ") == "11223344!!__  "
func doubleChar(string: String) -> String {
    return string.map { $0 * 2 }
}

// ----------------------------------------------------------------------------------------------------------------------

// 15. Write a function that takes a string and returns a new string with the first and last characters swapped.
// swapFirstLast(string: "Hello") == "oellH"
// swapFirstLast(string: "a") == "a"
// swapFirstLast(string: "abcdef") == "bcfedag"
func swapFirstLast(string: String) -> String {
    return string.last + string.substring(1, string.count - 2) + string.first
}

// ----------------------------------------------------------------------------------------------------------------------

// 16. Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels(string: "I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
// removeVowels(string: "We're gonna build a wall!") == "W'r gnyb bld  wll!"
// removeVowels(string: "Happy Thanksgiving!") == "Hppy Thnksgvny!"
func removeVowels(string: String) -> String {
    return string.remove(.vowel)
}

// ----------------------------------------------------------------------------------------------------------------------

// 17. Write a function that takes a string and returns a new string with the first and last characters swapped.
// swapFirstLast(string: "Hello") == "oellH"
// swapFirstLast(string: "a") == "a"
// swapFirstLast(string: "abcdef") == "bcfedag"
func
return string.map { // cannot convert return expression of type '[T]' to return type 'String'
return $0.uppercase // value of type 'String.Element' (aka 'Character') has no member 'uppercase'
return string.count(.vowel) // cannot infer contextual base in reference to member 'vowel'
return string.count(.vowel) // cannot call value of non-function type 'Int'
return string.reversed == string // type '() -> [String.Element]' (aka '() -> Array<Character>') cannot conform to 'StringProtocol'
return string.map { $0 * 2 } // binary operator '*' cannot be applied to operands of type 'String.Element' (aka 'Character') and 'Int'
return string.map { $0 * 2 } // no 'map' candidates produce the expected contextual result type 'String'
return string.last + string.substring(1, string.count - 2) + string.first // cannot convert value of type 'String.Element?' (aka 'Optional<Character>') to expected argument type 'String'
return string.last + string.substring(1, string.count - 2) + string.first // cannot convert value of type 'String.Element?' (aka 'Optional<Character>') to expected argument type 'String'
return string.last + string.substring(1, string.count - 2) + string.first // no exact matches in call to instance method 'substring'
return string.remove(.vowel) // no exact matches in call to instance method 'remove'
return string.remove(.vowel) // type 'String.Index' has no member 'vowel'
return string.remove(.vowel) // cannot convert return expression of type 'Character' to return type 'String'

func flipCase(string: String) -> String {
    let result = ""
    for char in string {
        if char.isLowercase {
            result += char.uppercaseString
        } else {
            result += char.lowercaseString
        }
    }
    return result
}

func countVowels(string: String) -> Int {
    let vowels = "aeiou"
    var count = 0
    for char in string {
        if vowels.contains(char) {
            count += 1
        }
    }
    return count
}

func isPalindrome(string: String) -> Bool {
    let reversed = String(string.reversed())
    return string == reversed
}

func swapEnds(string: String) -> String {
    let first = string.first()
    let last = string.last()
    let middle = string.substring(1, string.count - 2)
    return last + middle + first
}
```swift
// For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
// flipCase(string: "Hello") == "hELLO"
func flipCase(string: String) -> String {
    let result = ""
    for char in string {
        if char.isLowercase {
            result += char.uppercaseString
        } else {
            result += char.lowercaseString
        }
    }
    return result
}

// 2. Write a function that takes a string and returns the number (count) of vowels contained within it.
// countVowels(string: "Celebration") == 5
func countVowels(string: String) -> Int {
    let vowels = "aeiou"
    var count = 0
    for char in string {
        if vowels.contains(char) {
            count += 1
        }
    }
    return count
}

// 3. Write a function that takes a string and returns true if the string is a palindrome, and false otherwise.
// isPalindrome(string: "racecar") == true
// isPalindrome(string: "yummy") == false
func isPalindrome(string: String) -> Bool {
    let reversed = String(string.reversed())
    return string == reversed
}

// 4. Write a function that takes a string and returns a new string with the first and last characters swapped.
// swapEnds(string: "Hello") == "oellH"
func swapEnds(string: String) -> String {
    let first = string.first()
    let last = string.last()
    let middle = string.substring(1, string.count - 2)
    return last + middle + first
}

// 5. Write a function that takes a string and returns a new string with the first and last characters swapped.
// swapEnds(string: "Hello") == "oellH"
func swapEnds(string: String) -> String {
    let first = string.first()
    let last = string.last()
    let middle = string.substring(1, string.count - 2)
    return last + middle + first
}

// 6. Write a function that takes a string and returns a new string with the first and last characters swapped.
// swapEnds(string: "Hello") == "oellH"
func swapEnds(string: String) -> String {
    let first = string.first()
    let last = string.last()
    let middle = string.substring(1, string.count - 2)
    return last + middle + first
}

// 7. Write a function that takes a string and returns a new string with the first and last characters swapped.
// swapEnds(string: "Hello") == "oellH"
func swapEnds(string: String) -> String {
    let first = string.first()
    let last = string.last()
    let middle = string.substring(1, string.count - 2)
    return last + middle + first
}

// 8. Write a function that takes a string and returns a new string with the first and last characters swapped.
// swapEnds(string: "Hello") == "oellH"
func swapEnds(string: String) -> String {
    let first = string.first()
    let last = string.last()
    let middle = string.substring(1, string.count - 2)
    return last + middle + first
}

// 9. Write a function that takes a string and returns a new string with the first and last characters swapped.
// swapEnds(string: "Hello") == "oellH"
func swapEnds(string: String) -> String {
    let first = string.first()
    let last = string.last()
    let middle = string.substring(1, string.count - 2)
    return last + middle + first
}

// 10. Write a function that takes a string and returns a new string with the first and last characters swapped.
// swapEnds(string: "Hello") == "oellH"
func swapEnds(string: String) -> String {
    let first = string.first()
    let last = string.last()
    let middle = string.substring(1, string.count - 2)
    return last + middle + first
}

// 11. Write a function that takes a string and returns a new string with the first and last characters sw
result += char.uppercaseString // value of type 'Character' has no member 'uppercaseString'
result += char.lowercaseString // value of type 'Character' has no member 'lowercaseString'
let first = string.first() // cannot call value of non-function type 'String.Element?' (aka 'Optional<Character>')
let last = string.last() // cannot call value of non-function type 'String.Element?' (aka 'Optional<Character>')
let middle = string.substring(1, string.count - 2) // no exact matches in call to instance method 'substring'

func flipCase(string: String) -> String {
    return string.map {
        if $0.isLowercase {
            return $0.uppercase
        } else {
            return $0.lowercase
        }
    }
}
```swift
// For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
// flipCase(string: "Hello") == "hELLO"
func flipCase(string: String) -> String {
    return string.map {
        if $0.isLowercase {
            return $0.uppercase
        } else {
            return $0.lowercase
        }
    }
}

// ----------------------------------------------------------------------------------------------------------------------
// 1.11.2
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// 1.12.1
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// 1.12.2
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// 1.12.3
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// 1.12.4
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// 1.12.5
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// 1.12.6
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// 1.12.7
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// 1.12.8
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// 1.12.9
// ----------------------------------------------------------------------------------------------------------------------

// ---------------------------------------
return string.map { // cannot convert return expression of type '[T]' to return type 'String'
return $0.uppercase // value of type 'String.Element' (aka 'Character') has no member 'uppercase'

func flipCase(string: String) -> String {
    var result = ""
    for char in string {
        if char.isLower {
            result += char.uppercaseString
        } else {
            result += char.lowercaseString
        }
    }
    return result
}

func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}
```swift
// For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
// flipCase(string: "Hello") == "hELLO"
func flipCase(string: String) -> String {
    var result = ""
    for char in string {
        if char.isLower {
            result += char.uppercaseString
        } else {
            result += char.lowercaseString
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// 10. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels(string: "I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// 11. Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels(string: "I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// 12. Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels(string: "I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// 13. Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels(string: "I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// 14. Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels(string: "I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
func removeVowels(string: String) -> String {
    var result = ""
    for char in string {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// 15. Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels(string: "I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck.
if char.isLower { // value of type 'Character' has no member 'isLower'
result += char.uppercaseString // value of type 'Character' has no member 'uppercaseString'
result += char.lowercaseString // value of type 'Character' has no member 'lowercaseString'
if !isVowel(char) { // cannot find 'isVowel' in scope
result += char // cannot convert value of type 'Character' to expected argument type 'String'

func flipCase(string: String) -> String {
    let result = ""
    for char in string {
        if char.isLowercase {
            result += char.uppercaseString
        } else {
            result += char.lowercaseString
        }
    }
    return result
}
```swift
// For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
// flipCase(string: "Hello") == "hELLO"
func flipCase(string: String) -> String {
    let result = ""
    for char in string {
        if char.isLowercase {
            result += char.uppercaseString
        } else {
            result += char.lowercaseString
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------------------------------------------------------------------------
result += char.uppercaseString // value of type 'Character' has no member 'uppercaseString'
result += char.lowercaseString // value of type 'Character' has no member 'lowercaseString'

func flipCase(string: String) -> String {
    return string.map {
        if $0.isLowercase {
            return $0.uppercaseString
        } else {
            return $0.lowercaseString
        }
    }.joined()
}
```swift
// For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
// flipCase(string: "Hello") == "hELLO"
func flipCase(string: String) -> String {
    return string.map {
        if $0.isLowercase {
            return $0.uppercaseString
        } else {
            return $0.lowercaseString
        }
    }.joined()
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

//
return $0.uppercaseString // value of type 'String.Element' (aka 'Character') has no member 'uppercaseString'

func flipCase(string: String) -> String {
    return string.map {
        if $0.isLowercase {
            return $0.uppercaseString
        } else {
            return $0.lowercaseString
        }
    }.joined
}

func countVowels(string: String) -> Int {
    return string.count(.Vowel)
}

func countConsonants(string: String) -> Int {
    return string.count(.Consonant)
}

func countWords(string: String) -> Int {
    return string.count(.Word)
}

func countSentences(string: String) -> Int {
    return string.count(.Sentence)
}
```swift
// For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
// flipCase(string: "Hello") == "hELLO"
func flipCase(string: String) -> String {
    return string.map {
        if $0.isLowercase {
            return $0.uppercaseString
        } else {
            return $0.lowercaseString
        }
    }.joined
}

// -----------------------------------------------------------------------------
// 1.1.2. Write a function that takes a string and returns the number of vowels in the string.
// countVowels(string: "Hello") == 2
func countVowels(string: String) -> Int {
    return string.count(.Vowel)
}

// -----------------------------------------------------------------------------
// 1.1.3. Write a function that takes a string and returns the number of consonants in the string.
// countConsonants(string: "Hello") == 3
func countConsonants(string: String) -> Int {
    return string.count(.Consonant)
}

// -----------------------------------------------------------------------------
// 1.1.4. Write a function that takes a string and returns the number of words in the string.
// countWords(string: "Hello world") == 2
func countWords(string: String) -> Int {
    return string.count(.Word)
}

// -----------------------------------------------------------------------------
// 1.1.5. Write a function that takes a string and returns the number of sentences in the string.
// countSentences(string: "Hello world. How are you?") == 2
func countSentences(string: String) -> Int {
    return string.count(.Sentence)
}

// -----------------------------------------------------------------------------
// 1.1.6. Write a function that takes a string and returns the number of emojis in the string.
// countEmojis(string: "😀 😃 😄 😁 😆 😅 😂 🤣 😊 😇 🙂 🙃 😉 😎 😍 😘 🤗 🤩 🤔 🤐 😯 😦 😧 😨 😰 😧 😢 😭 🤯 😱 😖 😣 😓 😞 😟 😤 😪 🤤 😴 🤐 🤢 🤧 🤕 🤑 🤗 🤔 🤐 🤓 😎 🤩 🤔 🤐 🤓 🤨 🤦‍♀️ 🤷‍♂️ 🤷‍♂️ 🤵 🤶 🤷 🤵‍♀️ 🤵‍♂️ 🤵‍♂️ 🤷‍♂️ 🤵‍♂️ 🤵‍♂️ 🤵‍♂️ 🤵‍♂️ 🤵‍♂️ 🤵‍♂️ 🤵‍♂️ 🤵‍♂️ 🤵‍♂️ 🤵‍♂️ 🤵‍♂️ 🤵‍♂️ 🤵‍♂️ 🤵‍♂️ 🤵‍♂️ 🤵‍
return $0.uppercaseString // value of type 'String.Element' (aka 'Character') has no member 'uppercaseString'
}.joined // function produces expected type 'String'; did you mean to call it with '()'?
return string.count(.Vowel) // cannot infer contextual base in reference to member 'Vowel'
return string.count(.Vowel) // cannot call value of non-function type 'Int'
return string.count(.Consonant) // cannot call value of non-function type 'Int'
return string.count(.Consonant) // cannot infer contextual base in reference to member 'Consonant'
return string.count(.Word) // cannot call value of non-function type 'Int'
return string.count(.Word) // cannot infer contextual base in reference to member 'Word'
return string.count(.Sentence) // cannot infer contextual base in reference to member 'Sentence'
return string.count(.Sentence) // cannot call value of non-function type 'Int'

func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}
```swift
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator
public func concatenate(strings: [String]) -> String { // invalid redeclaration of 'concatenate(strings:)'

func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}
```swift
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator
public func concatenate(strings: [String]) -> String { // invalid redeclaration of 'concatenate(strings:)'

func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}
```swift
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator
public func concatenate(strings: [String]) -> String { // invalid redeclaration of 'concatenate(strings:)'

func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}
```swift
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// -----------------------------------------------------------------------------
// MARK: - String.join
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: - String.join(separator: separator:)
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: - String.join(separator: separator:, maxLength: maxLength:,
//                     truncation: truncation:, trim: trim:,
//                     truncationLocation: truncationLocation:,
//                     truncationSubstitution: truncationSubstitution:,
//                     truncationSubstitutionLocation: truncationSubstitutionLocation:,
//                     truncationSubstitutionLength: truncationSubstitutionLength:,
//                     truncationSubstitutionLocation: truncationSubstitutionLocation:,
//                     truncationSubstitutionLength: truncationSubstitutionLength:,
//                     truncationSubstitutionLocation: truncationSubstitutionLocation:,
//                     truncationSubstitutionLength: truncationSubstitutionLength:,
//                     truncationSubstitutionLocation: truncationSubstitutionLocation:,
//                     truncationSubstitutionLength: truncationSubstitutionLength:,
//                     truncationSubstitutionLocation: truncationSubstitutionLocation:,
//                     truncationSubstitutionLength: truncationSubstitutionLength:,
//                     truncationSubstitutionLocation: truncationSubstitutionLocation:,
//                     truncationSubstitutionLength: truncationSubstitutionLength:,
//                     truncationSubstitutionLocation: truncationSubstitutionLocation:,
//                     truncationSubstitutionLength: truncationSubstitutionLength:,
//                     truncationSubstitutionLocation: truncationSubstitutionLocation:,
//                     truncationSubstitutionLength: truncationSubstitutionLength:,
//                     truncationSubstitutionLocation: truncationSubstitutionLocation:,
//                     truncationSubstitutionLength: truncationSubstitutionLength:,
//                     truncationSubstitutionLocation: truncationSubstitutionLocation:,
//                     truncationSubstitutionLength: truncationSubstitutionLength:,
//                     truncationSubstitutionLocation: truncationSubstitutionLocation:,
//                     truncationSubstitutionLength: truncationSubstitutionLength:,
//                     truncationSubstitutionLocation: truncationSubstitutionLocation:,
//                     truncationSubstitutionLength: truncationSubstitutionLength:,
//                     truncationSubstitutionLocation: truncationSubstitutionLocation:,
//                     truncationSubstitutionLength: truncationSubstitutionLength:,
//                     truncationSubstitutionLocation: truncationSubstitutionLocation:,
//                     truncationSubstitutionLength: truncationSubstitutionLength:,
//                     truncationSubstitutionLocation: truncationSubstitutionLocation:,
//                     truncationSubstitutionLength: truncationSubstitutionLength:,
//                     truncationSubstitutionLocation: truncationSubstitutionLocation:,
//                     truncationSubstitutionLength: truncationSubstitutionLength:,
//                     truncationSubstitutionLocation: truncationSubstitutionLocation:,
//                     truncationSubstitutionLength: truncationSubstitutionLength:,
//                     truncationSubstitutionLocation: truncationSubstitutionLocation:,
//                     truncationSubstitutionLength: truncationSubstitutionLength:,
//                     truncationSubstitutionLocation: truncationSubstitutionLocation:,
//                     truncationSubstitutionLength: truncationSubstitutionLength:,
//                     truncationSubstitutionLocation: truncationSubstitutionLocation:,
//                     truncationSubstitutionLength: truncationSubstitutionLength:,
//                     truncation

func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}
```swift
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(

func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}
```swift
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(

func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}
```swift
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
public func concatenate(strings: [String]) -> String {
    return strings.joined(separator
public func concatenate(strings: [String]) -> String { // invalid redeclaration of 'concatenate(strings:)'

func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}
```swift
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(

func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}
```swift
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(

func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}
```swift
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    return strings.joined(separator: "")
}

// @testable
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(

func filterByPrefix(strings: [String], prefix: String) -> [String] {
    return strings.filter { $0.startsWith(prefix) }
}

func removeVowels(input: String) -> String {
    return input.filter { !isVowel($0) }
}
```swift
// Filter an input array of strings only for ones that start with a given prefix.
// filterByPrefix(strings: [] as [String], prefix: "a") == [] as [String]
// filterByPrefix(strings: ["abc", "bcd", "cde", "array"], prefix: "a") == ["abc", "array"]
func filterByPrefix(strings: [String], prefix: String) -> [String] {
    return strings.filter { $0.startsWith(prefix) }
}

// -----------------------------------------------------------------------------
// 3. Write a function that takes a string and returns a new string with all the
// vowels removed.
// removeVowels("abcdefghijklmnopqrstuvwxyz") == "bcdfghjklmnpqrstvwxyz"
// removeVowels("hello world") == "hll wrld"
func removeVowels(input: String) -> String {
    return input.filter { !isVowel($0) }
}

// -----------------------------------------------------------------------------
// 4. Write a function that takes a string and returns a new string with all the
// vowels removed.
// removeVowels("abcdefghijklmnopqrstuvwxyz") == "bcdfghjklmnpqrstvwxyz"
// removeVowels("hello world") == "hll wrld"
func removeVowels(input: String) -> String {
    return input.filter { !isVowel($0) }
}

// -----------------------------------------------------------------------------
// 5. Write a function that takes a string and returns a new string with all the
// vowels removed.
// removeVowels("abcdefghijklmnopqrstuvwxyz") == "bcdfghjklmnpqrstvwxyz"
// removeVowels("hello world") == "hll wrld"
func removeVowels(input: String) -> String {
    return input.filter { !isVowel($0) }
}

// -----------------------------------------------------------------------------
// 6. Write a function that takes a string and returns a new string with all the
// vowels removed.
// removeVowels("abcdefghijklmnopqrstuvwxyz") == "bcdfghjklmnpqrstvwxyz"
// removeVowels("hello world") == "hll wrld"
func removeVowels(input: String) -> String {
    return input.filter { !isVowel($0) }
}

// -----------------------------------------------------------------------------
// 7. Write a function that takes a string and returns a new string with all the
// vowels removed.
// removeVowels("abcdefghijklmnopqrstuvwxyz") == "bcdfghjklmnpqrstvwxyz"
// removeVowels("hello world") == "hll wrld"
func removeVowels(input: String) -> String {
    return input.filter { !isVowel($0) }
}

// -----------------------------------------------------------------------------
// 8. Write a function that takes a string and returns a new string with all the
// vowels removed.
// removeVowels("abcdefghijklmnopqrstuvwxyz") == "bcdfghjklmnpqrstvwxyz"
// removeVowels("hello world") == "hll wrld"
func removeVowels(input: String) -> String {
    return input.filter { !isVowel($0) }
}

// -----------------------------------------------------------------------------
// 9. Write a function that takes a string and returns a new string with all the
// vowels removed.
// removeVowels("abcdefghijklmnopqrstuvwxyz") == "bcdfghjklmnpqrstvwxyz"
// removeVowels("hello world") == "hll wrld"
func removeVowels(input: String) -> String {
    return input.filter { !isVowel($0) }
return strings.filter { $0.startsWith(prefix) } // value of type 'String' has no member 'startsWith'
return input.filter { !isVowel($0) } // cannot find 'isVowel' in scope

func filterByPrefix(strings: [String], prefix: String) -> [String] {
    return strings.filter { $0.startsWith(prefix) }
}

func removeVowels(input: String) -> String {
    return input.filter { !isVowel($0) }
}
```swift
// Filter an input array of strings only for ones that start with a given prefix.
// filterByPrefix(strings: [] as [String], prefix: "a") == [] as [String]
// filterByPrefix(strings: ["abc", "bcd", "cde", "array"], prefix: "a") == ["abc", "array"]
func filterByPrefix(strings: [String], prefix: String) -> [String] {
    return strings.filter { $0.startsWith(prefix) }
}

// ----------------------------------------------------------------------------------------------------------------------

// 1. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("abcdefghijklmnopqrstuvwxyz") == "bcdfghjklmnpqrstvwxyz"
// removeVowels("hello world") == "hll wrld"
func removeVowels(input: String) -> String {
    return input.filter { !isVowel($0) }
}

// ----------------------------------------------------------------------------------------------------------------------

// 2. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("abcdefghijklmnopqrstuvwxyz") == "bcdfghjklmnpqrstvwxyz"
// removeVowels("hello world") == "hll wrld"
func removeVowels(input: String) -> String {
    return input.filter { !isVowel($0) }
}

// ----------------------------------------------------------------------------------------------------------------------

// 3. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("abcdefghijklmnopqrstuvwxyz") == "bcdfghjklmnpqrstvwxyz"
// removeVowels("hello world") == "hll wrld"
func removeVowels(input: String) -> String {
    return input.filter { !isVowel($0) }
}

// ----------------------------------------------------------------------------------------------------------------------

// 4. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("abcdefghijklmnopqrstuvwxyz") == "bcdfghjklmnpqrstvwxyz"
// removeVowels("hello world") == "hll wrld"
func removeVowels(input: String) -> String {
    return input.filter { !isVowel($0) }
}

// ----------------------------------------------------------------------------------------------------------------------

// 5. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("abcdefghijklmnopqrstuvwxyz") == "bcdfghjklmnpqrstvwxyz"
// removeVowels("hello world") == "hll wrld"
func removeVowels(input: String) -> String {
    return input.filter { !isVowel($0) }
}

// ----------------------------------------------------------------------------------------------------------------------

// 6. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("abcdefghijklmnopqrstuvwxyz") == "bcdfghjklmnpqrstvwxyz"
// removeVowels("hello world") == "hll wrld"
func removeVowels(input: String) -> String {
    return input.filter { !isVowel($0) }
}

// ----------------------------------------------------------------------------------------------------------------------

// 7. Write a function that takes a string and returns a new string with all vowels removed.
//
return strings.filter { $0.startsWith(prefix) } // value of type 'String' has no member 'startsWith'
return input.filter { !isVowel($0) } // cannot find 'isVowel' in scope

func filterByPrefix(strings: [String], prefix: String) -> [String] {
    return strings.filter { $0.startsWith(prefix) }
}
```swift
// Filter an input array of strings only for ones that start with a given prefix.
// filterByPrefix(strings: [] as [String], prefix: "a") == [] as [String]
// filterByPrefix(strings: ["abc", "bcd", "cde", "array"], prefix: "a") == ["abc", "array"]
func filterByPrefix(strings: [String], prefix: String) -> [String] {
    return strings.filter { $0.startsWith(prefix) }
}

// -----------------------------------------------------------------------------
// 1.1.1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.63.64.65.66.67.68.69.70.71.72.73.74.75.76.77.78.79.80.81.82.83.84.85.86.87.88.89.90.91.92.93.94.95.96.97.98.99.100.101.102.103.104.105.106.107.108.109.110.111.112.113.114.115.116.117.118.119.120.121.122.123.124.125.126.127.128.129.130.131.132.133.134.135.136.137.138.139.140.141.142.143.144.145.146.147.148.149.150.151.152.153.154.155.156.157.158.159.160.161.162.163.164.165.166.167.168.169.170.171.172.173.174.175.176.177.178.179.180.181.182.183.184.185.186.187.188.189.190.191.192.193.194.195.196.197.198.199.200.201.202.203.204.205.206.207.208.209.210.211.212.213.214.215.216.217.218.219.220.221.222.223.224.225.226.227.228.229.230.231.232.233.234.235.236.237.238.239.240.241.242.243.244.245.246.247.248.249.250.251.252.253.254.255.256.257.258.259.260.261.262.263.264.265.266.267.268.269.2
return strings.filter { $0.startsWith(prefix) } // value of type 'String' has no member 'startsWith'

func filterByPrefix(strings: [String], prefix: String) -> [String] {
    return strings.filter { $0.startsWith(prefix) }
}
```swift
// Filter an input array of strings only for ones that start with a given prefix.
// filterByPrefix(strings: [] as [String], prefix: "a") == [] as [String]
// filterByPrefix(strings: ["abc", "bcd", "cde", "array"], prefix: "a") == ["abc", "array"]
func filterByPrefix(strings: [String], prefix: String) -> [String] {
    return strings.filter { $0.startsWith(prefix) }
}

// -----------------------------------------------------------------------------
// 10. Write a function that takes a string and returns a new string with all
//     characters in the original string except the first and last ones.
//     Example:
//     reverseString("abcdef") == "bcd"
//     reverseString("a") == ""
//     reverseString("") == ""
//     reverseString("ab") == "a"
//     reverseString("abc") == "bc"
//     reverseString("abcd") == "bc"
//     reverseString("abcde") == "bcde"
//     reverseString("abcdefg") == "bcdef"
//     reverseString("abcdefgh") == "bcdefg"
//     reverseString("abcdefghi") == "bcdefgh"
//     reverseString("abcdefghij") == "bcdefghi"
//     reverseString("abcdefghijkl") == "bcdefghij"
//     reverseString("abcdefghijklm") == "bcdefghijkl"
//     reverseString("abcdefghijklmn") == "bcdefghijklm"
//     reverseString("abcdefghijklmno") == "bcdefghijklmno"
//     reverseString("abcdefghijklmno") == "bcdefghijklmno"
//     reverseString("abcdefghijklmno") == "bcdefghijklmno"
//     reverseString("abcdefghijklmno") == "bcdefghijklmno"
//     reverseString("abcdefghijklmno") == "bcdefghijklmno"
//     reverseString("abcdefghijklmno") == "bcdefghijklmno"
//     reverseString("abcdefghijklmno") == "bcdefghijklmno"
//     reverseString("abcdefghijklmno") == "bcdefghijklmno"
//     reverseString("abcdefghijklmno") == "bcdefghijklmno"
//     reverseString("abcdefghijklmno") == "bcdefghijklmno"
//     reverseString("abcdefghijklmno") == "bcdefghijklmno"
//     reverseString("abcdefghijklmno") == "bcdefghijklmno"
//     reverseString("abcdefghijklmno") == "bcdefghijklmno"
//     reverseString("abcdefghijklmno") == "bcdefghijklmno"
//     reverseString("abcdefghijklmno") == "bcdefghijklmno"
//     reverseString("abcdefghijklmno") == "bcdefghijklmno"
//     reverseString("abcdefghijklmno") == "bcdefghijklmno"
//     reverseString("abcdefghijklmno") == "bcdefghijklmno"
//     reverseString("abcdefghijklmno") == "bcdefghijklmno"
//     reverseString("abcdefghijklmno") == "bcdefghijklmno"
//     reverseString("abcdefghijklmno") == "bcdefghijklmno"
//     reverseString("abcdefghijklmno") == "bcdefghijklmno"
//     reverseString("abcdefghijklmno") == "bcdefghijklmno"
//     reverseString("abcdefghijklmno") == "bcdefghijklmno"
//     reverseString("abcdefghijklmno") == "bcdefghijklmno"
//     reverseString("abcdefghijklmno") == "bcdefghijklmno"
//     reverseString("abcdefghijklmno") == "
return strings.filter { $0.startsWith(prefix) } // value of type 'String' has no member 'startsWith'

func filterByPrefix(strings: [String], prefix: String) -> [String] {
    return strings.filter { $0.startsWith(prefix) }
}
```swift
// Filter an input array of strings only for ones that start with a given prefix.
// filterByPrefix(strings: [] as [String], prefix: "a") == [] as [String]
// filterByPrefix(strings: ["abc", "bcd", "cde", "array"], prefix: "a") == ["abc", "array"]
func filterByPrefix(strings: [String], prefix: String) -> [String] {
    return strings.filter { $0.startsWith(prefix) }
}

// -----------------------------------------------------------------------------
// 1.1.1.2.2.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1
return strings.filter { $0.startsWith(prefix) } // value of type 'String' has no member 'startsWith'

func filterByPrefix(strings: [String], prefix: String) -> [String] {
    return strings.filter { $0.startsWith(prefix) }
}

func countVowels(string: String) -> Int {
    return string.count(.Vowel)
}

func countWords(string: String) -> Int {
    return string.count(.Word)
}

func countUppercaseLetters(string: String) -> Int {
    return string.count(.UpperCaseLetter)
}

func countLowercaseLetters(string: String) -> Int {
    return string.count(.LowerCaseLetter)
}

func countDigits(string: String) -> Int {
    return string.count(.Digit)
}

func countLettersAndDigits(string: String) -> (Int, Int) {
    return (string.count(.Letter), string.count(.Digit))
}

func countVowelWords(string: String) -> Int {
    return string.count(.VowelWord)
}

func countVowelWords(string: String) -> Int {
    return string.count(.VowelWordEnd)
}
```swift
// Filter an input array of strings only for ones that start with a given prefix.
// filterByPrefix(strings: [] as [String], prefix: "a") == [] as [String]
// filterByPrefix(strings: ["abc", "bcd", "cde", "array"], prefix: "a") == ["abc", "array"]
func filterByPrefix(strings: [String], prefix: String) -> [String] {
    return strings.filter { $0.startsWith(prefix) }
}

// -----------------------------------------------------------------------------
// 2. Write a function that takes a string and returns the number of vowels in it.
// countVowels("apple") == 2
// countVowels("banana") == 3
func countVowels(string: String) -> Int {
    return string.count(.Vowel)
}

// -----------------------------------------------------------------------------
// 3. Write a function that takes a string and returns the number of words in it.
// countWords("Hello world") == 2
// countWords("Hello world, how are you?") == 4
func countWords(string: String) -> Int {
    return string.count(.Word)
}

// -----------------------------------------------------------------------------
// 4. Write a function that takes a string and returns the number of uppercase letters in it.
// countUppercaseLetters("Hello world") == 2
// countUppercaseLetters("Hello world, how are you?") == 3
func countUppercaseLetters(string: String) -> Int {
    return string.count(.UpperCaseLetter)
}

// -----------------------------------------------------------------------------
// 5. Write a function that takes a string and returns the number of lowercase letters in it.
// countLowercaseLetters("Hello world") == 8
// countLowercaseLetters("Hello world, how are you?") == 14
func countLowercaseLetters(string: String) -> Int {
    return string.count(.LowerCaseLetter)
}

// -----------------------------------------------------------------------------
// 6. Write a function that takes a string and returns the number of digits in it.
// countDigits("Hello world") == 0
// countDigits("Hello world, how are you?") == 2
func countDigits(string: String) -> Int {
    return string.count(.Digit)
}

// -----------------------------------------------------------------------------
// 7. Write a function that takes a string and returns the number of letters and digits in it.
// countLettersAndDigits("Hello world") == (8, 0)
// countLettersAndDigits("Hello world, how are you?") == (14, 2)
func countLettersAndDigits(string: String) -> (Int, Int) {
    return (string.count(.Letter), string.count(.Digit))
}

// -----------------------------------------------------------------------------
// 8. Write a function that takes a string and returns the number of words that start with a vowel.
// countVowelWords("Hello world") == 1
// countVowelWords("Hello world, how are you?") == 2
func countVowelWords(string: String) -> Int {
    return string.count(.VowelWord)
}

// -----------------------------------------------------------------------------
// 9. Write a function that takes a string and returns the number of words that end with a vowel.
// countVowelWords("Hello world") == 1
// countVowelWords("Hello world, how are you?") == 2
func countVowelWords(string: String) -> Int {
    return string.count(.VowelWordEnd)
}

// -----------------------------------------------------------------------------
// 10. Write a function that takes a string and returns the
return strings.filter { $0.startsWith(prefix) } // value of type 'String' has no member 'startsWith'
return string.count(.Vowel) // cannot infer contextual base in reference to member 'Vowel'
return string.count(.Vowel) // cannot call value of non-function type 'Int'
return string.count(.Word) // cannot call value of non-function type 'Int'
return string.count(.Word) // cannot infer contextual base in reference to member 'Word'
return string.count(.UpperCaseLetter) // cannot call value of non-function type 'Int'
return string.count(.UpperCaseLetter) // cannot infer contextual base in reference to member 'UpperCaseLetter'
return string.count(.LowerCaseLetter) // cannot call value of non-function type 'Int'
return string.count(.LowerCaseLetter) // cannot infer contextual base in reference to member 'LowerCaseLetter'
return string.count(.Digit) // cannot infer contextual base in reference to member 'Digit'
return string.count(.Digit) // cannot call value of non-function type 'Int'
return (string.count(.Letter), string.count(.Digit)) // cannot infer contextual base in reference to member 'Letter'
return (string.count(.Letter), string.count(.Digit)) // cannot call value of non-function type 'Int'
return (string.count(.Letter), string.count(.Digit)) // cannot infer contextual base in reference to member 'Digit'
return (string.count(.Letter), string.count(.Digit)) // cannot call value of non-function type 'Int'
return string.count(.VowelWord) // cannot infer contextual base in reference to member 'VowelWord'
return string.count(.VowelWord) // cannot call value of non-function type 'Int'
func countVowelWords(string: String) -> Int { // invalid redeclaration of 'countVowelWords(string:)'
return string.count(.VowelWordEnd) // cannot infer contextual base in reference to member 'VowelWordEnd'
return string.count(.VowelWordEnd) // cannot call value of non-function type 'Int'

func filterByPrefix(strings: [String], prefix: String) -> [String] {
    return strings.filter { $0.startsWith(prefix) }
}

func filterLongerThan(strings: [String], minLength: Int) -> [String] {
    return strings.filter { $0.length > minLength }
}

func filterShorterThan(strings: [String], maxLength: Int) -> [String] {
    return strings.filter { $0.length < maxLength }
}

func filterVowels(strings: [String], vowels: String) -> [String] {
    return strings.filter { $0.first!.isVowel }
}

func filterConsonants(strings: [String], vowels: String) -> [String] {
    return strings.filter { !$0.first!.isVowel }
}

func filterA(strings: [String], letter: String) -> [String] {
    return strings.filter { $0.contains(letter) }
}
```swift
// Filter an input array of strings only for ones that start with a given prefix.
// filterByPrefix(strings: [] as [String], prefix: "a") == [] as [String]
// filterByPrefix(strings: ["abc", "bcd", "cde", "array"], prefix: "a") == ["abc", "array"]
func filterByPrefix(strings: [String], prefix: String) -> [String] {
    return strings.filter { $0.startsWith(prefix) }
}

// -----------------------------------------------------------------------------
// 10. Write a function that takes an array of strings and returns a new array
//     containing only the strings that are longer than 5 characters.
//     filterLongerThan(strings: [] as [String], minLength: 5) == [] as [String]
//     filterLongerThan(strings: ["abc", "bcd", "cde", "array"], minLength: 5) == ["cde", "array"]
func filterLongerThan(strings: [String], minLength: Int) -> [String] {
    return strings.filter { $0.length > minLength }
}

// -----------------------------------------------------------------------------
// 11. Write a function that takes an array of strings and returns a new array
//     containing only the strings that are shorter than 5 characters.
//     filterShorterThan(strings: [] as [String], maxLength: 5) == [] as [String]
//     filterShorterThan(strings: ["abc", "bcd", "cde", "array"], maxLength: 5) == ["abc"]
func filterShorterThan(strings: [String], maxLength: Int) -> [String] {
    return strings.filter { $0.length < maxLength }
}

// -----------------------------------------------------------------------------
// 12. Write a function that takes an array of strings and returns a new array
//     containing only the strings that start with a vowel.
//     filterVowels(strings: [] as [String], vowels: "aeiou") == [] as [String]
//     filterVowels(strings: ["abc", "bcd", "cde", "array"], vowels: "aeiou") == ["abc", "bcd", "cde"]
func filterVowels(strings: [String], vowels: String) -> [String] {
    return strings.filter { $0.first!.isVowel }
}

// -----------------------------------------------------------------------------
// 13. Write a function that takes an array of strings and returns a new array
//     containing only the strings that do not start with a vowel.
//     filterConsonants(strings: [] as [String], vowels: "aeiou") == [] as [String]
//     filterConsonants(strings: ["abc", "bcd", "cde", "array"], vowels: "aeiou") == ["array"]
func filterConsonants(strings: [String], vowels: String) -> [String] {
    return strings.filter { !$0.first!.isVowel }
}

// -----------------------------------------------------------------------------
// 14. Write a function that takes an array of strings and returns a new array
//     containing only the strings that contain the letter "a".
//     filterA(strings: [] as [String], letter: "a") == [] as [String]
//     filterA(strings: ["abc", "bcd", "cde", "array"], letter: "a") == ["abc", "bcd", "cde"]
func filterA(strings: [String], letter: String) -> [String] {
    return strings.filter { $0.contains(letter) }
}

// -----------------------------------------------------------------------------
// 15. Write a function that takes an array of strings and returns a new array
//     containing only the strings that do not contain the letter "a".
//     filterNotA(strings: [] as [String], letter: "a"
return strings.filter { $0.startsWith(prefix) } // value of type 'String' has no member 'startsWith'
return strings.filter { $0.length > minLength } // trailing closure passed to parameter of type 'Predicate<String>' that does not accept a closure
return strings.filter { $0.length < maxLength } // trailing closure passed to parameter of type 'Predicate<String>' that does not accept a closure
return strings.filter { $0.first!.isVowel } // value of type 'String.Element' (aka 'Character') has no member 'isVowel'
return strings.filter { !$0.first!.isVowel } // trailing closure passed to parameter of type 'Predicate<String>' that does not accept a closure

func filterByPrefix(strings: [String], prefix: String) -> [String] {
    return strings.filter { $0.startsWith(prefix) }
}
```swift
// Filter an input array of strings only for ones that start with a given prefix.
// filterByPrefix(strings: [] as [String], prefix: "a") == [] as [String]
// filterByPrefix(strings: ["abc", "bcd", "cde", "array"], prefix: "a") == ["abc", "array"]
func filterByPrefix(strings: [String], prefix: String) -> [String] {
    return strings.filter { $0.startsWith(prefix) }
}

// -----------------------------------------------------------------------------
// 1.1.2.2.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1
return strings.filter { $0.startsWith(prefix) } // value of type 'String' has no member 'startsWith'

func filterByPrefix(strings: [String], prefix: String) -> [String] {
    return strings.filter { $0.hasPrefix(prefix) }
}
```swift
// Filter an input array of strings only for ones that start with a given prefix.
// filterByPrefix(strings: [] as [String], prefix: "a") == [] as [String]
// filterByPrefix(strings: ["abc", "bcd", "cde", "array"], prefix: "a") == ["abc", "array"]
func filterByPrefix(strings: [String], prefix: String) -> [String] {
    return strings.filter { $0.hasPrefix(prefix) }
}

// -----------------------------------------------------------------------------
// 1.1.2.2.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1

func filterByPrefix(strings: [String], prefix: String) -> [String] {
    return strings.filter { $0.startsWith(prefix) }
}

func countVowels(string: String) -> Int {
    return string.count(.vowel)
}

func countWords(string: String) -> Int {
    return string.split(.whitespace).count
}

func countConsonants(string: String) -> Int {
    return string.count(.consonant)
}

func countUppercaseLetters(string: String) -> Int {
    return string.count(.uppercaseLetter)
}

func countLowercaseLetters(string: String) -> Int {
    return string.count(.lowercaseLetter)
}

func countDigits(string: String) -> Int {
    return string.count(.digit)
}

func countWordsStartingWithVowel(string: String) -> Int {
    return string.split(.whitespace).filter { $0.first == "a" || $0.first == "e" || $0.first == "i" || $0.first == "o" || $0.first == "u" }.count
}
```swift
// Filter an input array of strings only for ones that start with a given prefix.
// filterByPrefix(strings: [] as [String], prefix: "a") == [] as [String]
// filterByPrefix(strings: ["abc", "bcd", "cde", "array"], prefix: "a") == ["abc", "array"]
func filterByPrefix(strings: [String], prefix: String) -> [String] {
    return strings.filter { $0.startsWith(prefix) }
}

// -----------------------------------------------------------------------------
// 2. Write a function that takes a string and returns the number of vowels in it.
// countVowels("apple") == 2
// countVowels("banana") == 3
func countVowels(string: String) -> Int {
    return string.count(.vowel)
}

// -----------------------------------------------------------------------------
// 3. Write a function that takes a string and returns the number of words in it.
// countWords("Hello world") == 2
// countWords("I love coding") == 3
func countWords(string: String) -> Int {
    return string.split(.whitespace).count
}

// -----------------------------------------------------------------------------
// 4. Write a function that takes a string and returns the number of consonants in it.
// countConsonants("apple") == 5
// countConsonants("banana") == 6
func countConsonants(string: String) -> Int {
    return string.count(.consonant)
}

// -----------------------------------------------------------------------------
// 5. Write a function that takes a string and returns the number of uppercase letters in it.
// countUppercaseLetters("Apple") == 1
// countUppercaseLetters("Banana") == 3
func countUppercaseLetters(string: String) -> Int {
    return string.count(.uppercaseLetter)
}

// -----------------------------------------------------------------------------
// 6. Write a function that takes a string and returns the number of lowercase letters in it.
// countLowercaseLetters("Apple") == 5
// countLowercaseLetters("Banana") == 3
func countLowercaseLetters(string: String) -> Int {
    return string.count(.lowercaseLetter)
}

// -----------------------------------------------------------------------------
// 7. Write a function that takes a string and returns the number of digits in it.
// countDigits("12345") == 5
// countDigits("abcdef") == 0
func countDigits(string: String) -> Int {
    return string.count(.digit)
}

// -----------------------------------------------------------------------------
// 8. Write a function that takes a string and returns the number of words that start with a vowel.
// countWordsStartingWithVowel("apple") == 1
// countWordsStartingWithVowel("banana") == 2
func countWordsStartingWithVowel(string: String) -> Int {
    return string.split(.whitespace).filter { $0.first == "a" || $0.first == "e" || $0.first == "i" || $0.first == "o" || $0.first == "u" }.count
}

// -----------------------------------------------------------------------------
// 9. Write a function that takes a string and returns the number of words that end with a consonant.
// countWordsEndingWithConsonant("apple") == 1
// countWordsEndingWithConsonant("banana") == 2
func countWordsEndingWithConsonant(string: String) -> Int {
    return string.split(.whitespace).filter { $0.last == "a" || $0.last == "e" || $0.last == "i" || $0.last == "o" || $0.
return strings.filter { $0.startsWith(prefix) } // value of type 'String' has no member 'startsWith'
return string.count(.vowel) // cannot call value of non-function type 'Int'
return string.count(.vowel) // cannot infer contextual base in reference to member 'vowel'
return string.split(.whitespace).count // no exact matches in call to instance method 'split'
return string.split(.whitespace).count // type 'String.Element' (aka 'Character') has no member 'whitespace'
return string.count(.consonant) // cannot infer contextual base in reference to member 'consonant'
return string.count(.consonant) // cannot call value of non-function type 'Int'
return string.count(.uppercaseLetter) // cannot infer contextual base in reference to member 'uppercaseLetter'
return string.count(.uppercaseLetter) // cannot call value of non-function type 'Int'
return string.count(.lowercaseLetter) // cannot call value of non-function type 'Int'
return string.count(.lowercaseLetter) // cannot infer contextual base in reference to member 'lowercaseLetter'
return string.count(.digit) // cannot call value of non-function type 'Int'
return string.count(.digit) // cannot infer contextual base in reference to member 'digit'
return string.split(.whitespace).filter { $0.first == "a" || $0.first == "e" || $0.first == "i" || $0.first == "o" || $0.first == "u" }.count // type 'String.Element' (aka 'Character') has no member 'whitespace'
return string.split(.whitespace).filter { $0.first == "a" || $0.first == "e" || $0.first == "i" || $0.first == "o" || $0.first == "u" }.count // no exact matches in call to instance method 'split'

func getPositive(l: [Int]) -> [Int] {
    return l.filter { $0 > 0 }
}

func countVowels(s: String) -> Int {
    return s.count(.vowel)
}

func countWords(s: String) -> Int {
    return s.split(.whitespace).count
}
```swift
// Return only positive numbers in the array.
// getPositive(l: [-1, 2, -4, 5, 6]) == [2, 5, 6]
// getPositive(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == [5, 3, 2, 3, 9, 123, 1]
func getPositive(l: [Int]) -> [Int] {
    return l.filter { $0 > 0 }
}

// -----------------------------------------------------------------------------
// 1. Write a function that takes a string and returns the number of vowels in it.
// countVowels("Hello world") == 3
// countVowels("Hi") == 2
// countVowels("aA") == 2
// countVowels("aeiou") == 5
// countVowels("") == 0
// countVowels("bcd") == 0
func countVowels(s: String) -> Int {
    return s.count(.vowel)
}

// -----------------------------------------------------------------------------
// 2. Write a function that takes a string and returns the number of words in it.
// countWords("Hello world") == 2
// countWords("Hi") == 1
// countWords("aA") == 1
// countWords("aeiou") == 1
// countWords("") == 0
// countWords("bcd") == 0
func countWords(s: String) -> Int {
    return s.split(.whitespace).count
}

// -----------------------------------------------------------------------------
// 3. Write a function that takes a string and returns the number of words in it.
// countWords("Hello world") == 2
// countWords("Hi") == 1
// countWords("aA") == 1
// countWords("aeiou") == 1
// countWords("") == 0
// countWords("bcd") == 0
func countWords(s: String) -> Int {
    return s.split(.whitespace).count
}

// -----------------------------------------------------------------------------
// 4. Write a function that takes a string and returns the number of words in it.
// countWords("Hello world") == 2
// countWords("Hi") == 1
// countWords("aA") == 1
// countWords("aeiou") == 1
// countWords("") == 0
// countWords("bcd") == 0
func countWords(s: String) -> Int {
    return s.split(.whitespace).count
}

// -----------------------------------------------------------------------------
// 5. Write a function that takes a string and returns the number of words in it.
// countWords("Hello world") == 2
// countWords("Hi") == 1
// countWords("aA") == 1
// countWords("aeiou") == 1
// countWords("") == 0
// countWords("bcd") == 0
func countWords(s: String) -> Int {
    return s.split(.whitespace).count
}

// -----------------------------------------------------------------------------
// 6. Write a function that takes a string and returns the number of words in it.
// countWords("Hello world") == 2
// countWords("Hi") == 1
// countWords("aA") == 1
// countWords("aeiou") == 1
// countWords("") == 0
// countWords("bcd") == 0
func countWords(s: String) -> Int {
    return s.split(.whitespace).count
}

// -----------------------------------------------------------------------------
// 7. Write a function that takes a string and returns the number of words in it.
// countWords("Hello world") == 2
//
return s.count(.vowel) // cannot call value of non-function type 'Int'
return s.count(.vowel) // cannot infer contextual base in reference to member 'vowel'
return s.split(.whitespace).count // no exact matches in call to instance method 'split'
return s.split(.whitespace).count // type 'String.Element' (aka 'Character') has no member 'whitespace'

func getPositive(l: [Int]) -> [Int] {
    return l.filter { $0 > 0 }
}

func reverseString(s: String) -> String {
    return String(s.reversed())
}
```swift
// Return only positive numbers in the array.
// getPositive(l: [-1, 2, -4, 5, 6]) == [2, 5, 6]
// getPositive(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == [5, 3, 2, 3, 9, 123, 1]
func getPositive(l: [Int]) -> [Int] {
    return l.filter { $0 > 0 }
}

// -----------------------------------------------------------------------------
// 2. Write a function that takes a string and returns a new string with all
//    characters in reverse order.
//    reverseString("hello") == "olleh"
//    reverseString("") == ""
//    reverseString("a") == "a"
//    reverseString("a b c") == "c b a"
//    reverseString("a!b@c#d$e%f&g*h(i)j_k+l-m[n]o{p}q|r:s<t>u|v,w^x~y{z}1234567890") == "0987654321{z}~yxv^wc,./n[o{p}q|rs<t>u(i)j_k+l-m[n]o{p}q|r:s<t>u|v,w^x~y{z}1234567890"
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// -----------------------------------------------------------------------------
// 3. Write a function that takes a string and returns a new string with all
//    characters in reverse order.
//    reverseString("hello") == "olleh"
//    reverseString("") == ""
//    reverseString("a") == "a"
//    reverseString("a b c") == "c b a"
//    reverseString("a!b@c#d$e%f&g*h(i)j_k+l-m[n]o{p}q|r:s<t>u|v,w^x~y{z}1234567890") == "0987654321{z}~yxv^wc,./n[o{p}q|rs<t>u(i)j_k+l-m[n]o{p}q|r:s<t>u|v,w^x~y{z}1234567890"
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// -----------------------------------------------------------------------------
// 4. Write a function that takes a string and returns a new string with all
//    characters in reverse order.
//    reverseString("hello") == "olleh"
//    reverseString("") == ""
//    reverseString("a") == "a"
//    reverseString("a b c") == "c b a"
//    reverseString("a!b@c#d$e%f&g*h(i)j_k+l-m[n]o{p}q|r:s<t>u|v,w^x~y{z}1234567890") == "0987654321{z}~yxv^wc,./n[o{p}q|rs<t>u(i)j_k+l-m[n]o{p}q|r:s<t>u|v,w^x~y{z}1234567890"
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// -----------------------------------------------------------------------------
// 5. Write a function that takes a string and returns a new string with all
//    characters in reverse order.
//    reverseString("hello") == "olleh"
//    reverseString("") == ""
//    reverseString("a") == "a"
//    reverseString("a b c") == "c

func getPositive(l: [Int]) -> [Int] {
    return l.filter { $0 > 0 }
}
```swift
// Return only positive numbers in the array.
// getPositive(l: [-1, 2, -4, 5, 6]) == [2, 5, 6]
// getPositive(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == [5, 3, 2, 3, 9, 123, 1]
func getPositive(l: [Int]) -> [Int] {
    return l.filter { $0 > 0 }
}

// -----------------------------------------------------------------------------
// 2. Write a function that takes a string and returns a new string with all
//    characters in reverse order.
//    reverseString("hello") == "olleh"
//    reverseString("") == ""
//    reverseString("a") == "a"
//    reverseString("a b c") == "c b a"
//    reverseString("a-b-c") == "c-b-a"
//    reverseString("a.b.c") == "c.b.a"
//    reverseString("a!b!c") == "c!b!a"
//    reverseString("a,b,c") == "c,b,a"
//    reverseString("a?b?c") == "c?b?a"
//    reverseString("a:b:c") == "c:b:a"
//    reverseString("a;b;c") == "c;b;a"
//    reverseString("a(b(c)") == "c(b(a)"
//    reverseString("a[b[c]") == "c[b[a]"
//    reverseString("a{b{c}") == "c{b{a}"
//    reverseString("a<b<c") == "c<b<a"
//    reverseString("a>b>c") == "c>b>a"
//    reverseString("a|b|c") == "c|b|a"
//    reverseString("a~b~c") == "c~b~a"
//    reverseString("a^b^c") == "c^b^a"
//    reverseString("a`b`c") == "c`b`a"
//    reverseString("a'b'c") == "c'b'a"
//    reverseString("a\"b\"c") == "c\"b\"a"
//    reverseString("a\\b\\c") == "c\\b\\a"
//    reverseString("a/b/c") == "c/b/a"
//    reverseString("a?b?c") == "c?b?a"
//    reverseString("a:b:c") == "c:b:a"
//    reverseString("a;b;c") == "c;b;a"
//    reverseString("a(b(c)") == "c(b(a)"
//    reverseString("a[b[c]") == "c[b[a]"
//    reverseString("a{b{c}") == "c{b{a}"
//    reverseString("a<b<c") == "c<b<a"
//    reverseString("a>b>c") == "c>b>a"
//    reverseString("a|b|c") == "c|b|a"
//    reverseString("a~b~c") == "c~b~a"
//    reverseString("a^b^c") == "c^b^a"
//    reverseString("a`b`c") == "c`b`a"
//    reverseString("a'b'c") == "c'b'a"
//    reverseString("a\"b\"c") == "c\"b\"a"
//    reverseString("a\\b\\c") == "c\\b\\a"
//    reverseString("a/b/c") == "c/b/a"
//    reverseString("a?b?c") == "c?b?a"
//    reverseString("a:b:c") == "c:b:a"
//    reverseString("a;b;c") == "c;b;a"
//    reverseString("a(b(c)") == "c(b(a)"
//    reverseString("a[b[

func getPositive(l: [Int]) -> [Int] {
    return l.filter { $0 > 0 }
}
```swift
// Return only positive numbers in the array.
// getPositive(l: [-1, 2, -4, 5, 6]) == [2, 5, 6]
// getPositive(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == [5, 3, 2, 3, 9, 123, 1]
func getPositive(l: [Int]) -> [Int] {
    return l.filter { $0 > 0 }
}

// ----------------------------------------------------------------------------------------------------------------------

// 1. Write a function that takes a string and returns the number (count) of vowels contained within it.
// countVowels("apple") == 2
// countVowels("hello") == 2
// countVowels("why") == 0

// ----------------------------------------------------------------------------------------------------------------------

// 2. Write a function that takes a string and returns the number (count) of vowels contained within it.
// countVowels("apple") == 2
// countVowels("hello") == 2
// countVowels("why") == 0

// ----------------------------------------------------------------------------------------------------------------------

// 3. Write a function that takes a string and returns the number (count) of vowels contained within it.
// countVowels("apple") == 2
// countVowels("hello") == 2
// countVowels("why") == 0

// ----------------------------------------------------------------------------------------------------------------------

// 4. Write a function that takes a string and returns the number (count) of vowels contained within it.
// countVowels("apple") == 2
// countVowels("hello") == 2
// countVowels("why") == 0

// ----------------------------------------------------------------------------------------------------------------------

// 5. Write a function that takes a string and returns the number (count) of vowels contained within it.
// countVowels("apple") == 2
// countVowels("hello") == 2
// countVowels("why") == 0

// ----------------------------------------------------------------------------------------------------------------------

// 6. Write a function that takes a string and returns the number (count) of vowels contained within it.
// countVowels("apple") == 2
// countVowels("hello") == 2
// countVowels("why") == 0

// ----------------------------------------------------------------------------------------------------------------------

// 7. Write a function that takes a string and returns the number (count) of vowels contained within it.
// countVowels("apple") == 2
// countVowels("hello") == 2
// countVowels("why") == 0

// ----------------------------------------------------------------------------------------------------------------------

// 8. Write a function that takes a string and returns the number (count) of vowels contained within it.
// countVowels("apple") == 2
// countVowels("hello") == 2
// countVowels("why") == 0

// ----------------------------------------------------------------------------------------------------------------------

// 9. Write a function that takes a string and returns the number (count) of vowels contained within it.
// countVowels("apple") == 2
// countVowels("hello") == 2
// countVowels

func getPositive(l: [Int]) -> [Int] {
    return l.filter { $0 > 0 }
}

func capitalize(s: String) -> String {
    return s.first!.uppercaseString + s.substring(1)
}

func capitalizeEachWord(s: String) -> String {
    var result = ""
    for (i, c) in s.enumerate() {
        if i == 0 {
            result += c.uppercaseString
        } else {
            result += c
        }
    }
    return result
}
```swift
// Return only positive numbers in the array.
// getPositive(l: [-1, 2, -4, 5, 6]) == [2, 5, 6]
// getPositive(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == [5, 3, 2, 3, 9, 123, 1]
func getPositive(l: [Int]) -> [Int] {
    return l.filter { $0 > 0 }
}

// 2. Write a function that takes a string and returns a string with the first letter capitalized.
// capitalize("hello") == "Hello"
// capitalize("") == ""
// capitalize("cat")
// capitalize("cat in the hat")
func capitalize(s: String) -> String {
    return s.first!.uppercaseString + s.substring(1)
}

// 3. Write a function that takes a string and returns a string with the first letter of each word capitalized.
// capitalizeEachWord("hello") == "Hello"
// capitalizeEachWord("")
// capitalizeEachWord("cat in the hat")
func capitalizeEachWord(s: String) -> String {
    var result = ""
    for (i, c) in s.enumerate() {
        if i == 0 {
            result += c.uppercaseString
        } else {
            result += c
        }
    }
    return result
}

// 4. Write a function that takes a string and returns a string with the first letter of each word capitalized.
// capitalizeEachWord("hello") == "Hello"
// capitalizeEachWord("")
// capitalizeEachWord("cat in the hat")
func capitalizeEachWord(s: String) -> String {
    var result = ""
    for (i, c) in s.enumerate() {
        if i == 0 {
            result += c.uppercaseString
        } else {
            result += c
        }
    }
    return result
}

// 5. Write a function that takes a string and returns a string with the first letter of each word capitalized.
// capitalizeEachWord("hello") == "Hello"
// capitalizeEachWord("")
// capitalizeEachWord("cat in the hat")
func capitalizeEachWord(s: String) -> String {
    var result = ""
    for (i, c) in s.enumerate() {
        if i == 0 {
            result += c.uppercaseString
        } else {
            result += c
        }
    }
    return result
}

// 6. Write a function that takes a string and returns a string with the first letter of each word capitalized.
// capitalizeEachWord("hello") == "Hello"
// capitalizeEachWord("")
// capitalizeEachWord("cat in the hat")
func capitalizeEachWord(s: String) -> String {
    var result = ""
    for (i, c) in s.enumerate() {
        if i == 0 {
            result += c.uppercaseString
        } else {
            result += c
        }
    }
    return result
}

// 7. Write a function that takes a string and returns a string with the first letter of each word capitalized.
// capitalizeEachWord("hello") == "Hello"
// capitalizeEachWord("")
// capitalizeEachWord("cat in the hat")
func capitalizeEachWord(s: String) -> String {
    var result = ""
    for (i, c) in s.enumerate() {
        if i == 0 {
            result += c.uppercaseString
        } else {
            result += c
        }
    }
    return result
}

// 8. Write a function that takes a string and returns a string with the first letter of each word capitalized.
// capitalizeEachWord("hello") == "Hello"
// capitalizeEachWord("")
// capitalizeEachWord("cat in the hat")
func capitalizeEachWord(s: String) -> String {
    var result = ""
    for (i, c) in s.enumerate() {
        if i == 0 {
            result += c.uppercaseString
        } else {
            result += c
        }
    }
    return result
}

// 9. Write a function that takes a string and returns a string with the first letter of each word capitalized.
// capitalizeEachWord("hello") == "Hello"
// capitalizeEachWord("")
// capitalizeEachWord("cat in the hat")
func capitalizeEachWord(s: String) -> String {
    var result = ""
    for (i, c) in s.enumerate() {
return s.first!.uppercaseString + s.substring(1) // no exact matches in call to instance method 'substring'
return s.first!.uppercaseString + s.substring(1) // value of type 'String.Element' (aka 'Character') has no member 'uppercaseString'
for (i, c) in s.enumerate() { // value of type 'String' has no member 'enumerate'

func getPositive(l: [Int]) -> [Int] {
    return l.filter { $0 > 0 }
}
```swift
// Return only positive numbers in the array.
// getPositive(l: [-1, 2, -4, 5, 6]) == [2, 5, 6]
// getPositive(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == [5, 3, 2, 3, 9, 123, 1]
func getPositive(l: [Int]) -> [Int] {
    return l.filter { $0 > 0 }
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ------------

func getPositive(l: [Int]) -> [Int] {
    return l.filter { $0 > 0 }
}
```swift
// Return only positive numbers in the array.
// getPositive(l: [-1, 2, -4, 5, 6]) == [2, 5, 6]
// getPositive(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == [5, 3, 2, 3, 9, 123, 1]
func getPositive(l: [Int]) -> [Int] {
    return l.filter { $0 > 0 }
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ------------------------

func getPositive(l: [Int]) -> [Int] {
    return l.filter { $0 > 0 }
}
```swift
// Return only positive numbers in the array.
// getPositive(l: [-1, 2, -4, 5, 6]) == [2, 5, 6]
// getPositive(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == [5, 3, 2, 3, 9, 123, 1]
func getPositive(l: [Int]) -> [Int] {
    return l.filter { $0 > 0 }
}

// -----------------------------------------------------------------------------
// 1.1.2.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.

func getPositive(l: [Int]) -> [Int] {
    return l.filter { $0 > 0 }
}
```swift
// Return only positive numbers in the array.
// getPositive(l: [-1, 2, -4, 5, 6]) == [2, 5, 6]
// getPositive(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == [5, 3, 2, 3, 9, 123, 1]
func getPositive(l: [Int]) -> [Int] {
    return l.filter { $0 > 0 }
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------------------------------------------------------------------------

func getPositive(l: [Int]) -> [Int] {
    return l.filter { $0 > 0 }
}

func removeVowels(s: String) -> String {
    return s.filter { $0 != "a" && $0 != "e" && $0 != "i" && $0 != "o" && $0 != "u" }
}
```swift
// Return only positive numbers in the array.
// getPositive(l: [-1, 2, -4, 5, 6]) == [2, 5, 6]
// getPositive(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == [5, 3, 2, 3, 9, 123, 1]
func getPositive(l: [Int]) -> [Int] {
    return l.filter { $0 > 0 }
}

// ----------------------------------------------------------------------------------------------------------------------

// 1. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I love coding") == "l vcdng"
// removeVowels("Hello world") == "Hll wrld"
func removeVowels(s: String) -> String {
    return s.filter { $0 != "a" && $0 != "e" && $0 != "i" && $0 != "o" && $0 != "u" }
}

// ----------------------------------------------------------------------------------------------------------------------

// 2. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I love coding") == "l vcdng"
// removeVowels("Hello world") == "Hll wrld"
func removeVowels(s: String) -> String {
    return s.filter { $0 != "a" && $0 != "e" && $0 != "i" && $0 != "o" && $0 != "u" }
}

// ----------------------------------------------------------------------------------------------------------------------

// 3. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I love coding") == "l vcdng"
// removeVowels("Hello world") == "Hll wrld"
func removeVowels(s: String) -> String {
    return s.filter { $0 != "a" && $0 != "e" && $0 != "i" && $0 != "o" && $0 != "u" }
}

// ----------------------------------------------------------------------------------------------------------------------

// 4. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I love coding") == "l vcdng"
// removeVowels("Hello world") == "Hll wrld"
func removeVowels(s: String) -> String {
    return s.filter { $0 != "a" && $0 != "e" && $0 != "i" && $0 != "o" && $0 != "u" }
}

// ----------------------------------------------------------------------------------------------------------------------

// 5. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I love coding") == "l vcdng"
// removeVowels("Hello world") == "Hll wrld"
func removeVowels(s: String) -> String {
    return s.filter { $0 != "a" && $0 != "e" && $0 != "i" && $0 != "o" && $0 != "u" }
}

// ----------------------------------------------------------------------------------------------------------------------

// 6. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I love coding") == "l vcdng"
// removeVowels("Hello world") == "Hll wrld"
func removeVowels(s: String) -> String {
    return s.filter { $0 != "

func isPrime(n: Int) -> Bool {
    if n == 1 {
        return false
    }
    for i in 2..<n {
        if n % i == 0 {
            return false
        }
    }
    return true
}

func vowelCount(s: String) -> Int {
    var count = 0
    for c in s {
        if c == "a" || c == "e" || c == "i" || c == "o" || c == "u" {
            count += 1
        }
    }
    return count
}

func wordCount(s: String) -> Int {
    var count = 0
    for c in s {
        if c == " " {
            count += 1
        }
    }
    return count + 1
}

func uppercaseCount(s: String) -> Int {
    var count = 0
    for c in s {
        if c == c.uppercase {
            count += 1
        }
    }
    return count
}
```swift
// Return true if a given number is prime, and false otherwise.
// isPrime(n: 6) == false
// isPrime(n: 101) == true
// isPrime(n: 11) == true
// isPrime(n: 13441) == true
// isPrime(n: 61) == true
// isPrime(n: 4) == false
// isPrime(n: 1) == false
func isPrime(n: Int) -> Bool {
    if n == 1 {
        return false
    }
    for i in 2..<n {
        if n % i == 0 {
            return false
        }
    }
    return true
}

// -----------------------------------------------------------------------------
// 1.1.2
// -----------------------------------------------------------------------------
// Write a function that takes a string and returns the number of vowels in the
// string.
// vowelCount("Hello") == 2
// vowelCount("Apple") == 2
// vowelCount("") == 0
// vowelCount("aeiou") == 5
// vowelCount("aeiouAEIOU") == 10
// vowelCount("aeiouAEIOUaeiouAEIOU") == 20
func vowelCount(s: String) -> Int {
    var count = 0
    for c in s {
        if c == "a" || c == "e" || c == "i" || c == "o" || c == "u" {
            count += 1
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// 1.1.3
// -----------------------------------------------------------------------------
// Write a function that takes a string and returns the number of words in the
// string.
// wordCount("Hello") == 1
// wordCount("Apple") == 1
// wordCount("") == 0
// wordCount("Hello, world!") == 2
// wordCount("Hello, world! Hello, world!") == 2
// wordCount("Hello, world! Hello, world! Hello, world!") == 3
func wordCount(s: String) -> Int {
    var count = 0
    for c in s {
        if c == " " {
            count += 1
        }
    }
    return count + 1
}

// -----------------------------------------------------------------------------
// 1.1.4
// -----------------------------------------------------------------------------
// Write a function that takes a string and returns the number of uppercase
// letters in the string.
// uppercaseCount("Hello") == 1
// uppercaseCount("Apple") == 0
// uppercaseCount("") == 0
// uppercaseCount("Hello, world!") == 2
// uppercaseCount("Hello, world! Hello, world!") == 2
// uppercaseCount("Hello, world! Hello, world! Hello, world!") == 3
func uppercaseCount(s: String) -> Int {
    var count = 0
    for c in s {
        if c == c.uppercase {
            count += 1
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// 1.1.5
// -----------------------------------------------------------------------------
// Write a function that takes a string and returns the number of lowercase
// letters in the string.
// lowercaseCount("Hello") == 5
// lowercaseCount("Apple") == 5
// lowercaseCount("") == 0
// lowercaseCount("Hello, world!") == 10
// lowercaseCount("Hello, world! Hello, world!") == 10
// lowercaseCount("Hello, world! Hello, world! Hello, world!") == 15
func lowercaseCount(s: String) -> Int {
    var count = 0
    for c in s {
        if c == c.lowercase {
if c == c.uppercase { // value of type 'Character' has no member 'uppercase'

func isPrime(n: Int) -> Bool {
    if n < 2 {
        return false
    }
    for i in 2..<n {
        if n % i == 0 {
            return false
        }
    }
    return true
}
```swift
// Return true if a given number is prime, and false otherwise.
// isPrime(n: 6) == false
// isPrime(n: 101) == true
// isPrime(n: 11) == true
// isPrime(n: 13441) == true
// isPrime(n: 61) == true
// isPrime(n: 4) == false
// isPrime(n: 1) == false
func isPrime(n: Int) -> Bool {
    if n < 2 {
        return false
    }
    for i in 2..<n {
        if n % i == 0 {
            return false
        }
    }
    return true
}

// -----------------------------------------------------------------------------
// 2. Write a function that takes a number as input and returns the sum of all
//    the numbers from 1 to that number.
//
//    sum(1) == 1
//    sum(2) == 3
//    sum(3) == 6
//    sum(4) == 10
//    sum(5) == 15
//    sum(6) == 21
//    sum(7) == 28
//    sum(8) == 36
//    sum(9) == 45
//    sum(10) == 55
//    sum(11) == 66
//    sum(12) == 78
//    sum(13) == 91
//    sum(14) == 105
//    sum(15) == 121
//    sum(16) == 137
//    sum(17) == 155
//    sum(18) == 173
//    sum(19) == 191
//    sum(20) == 210
//    sum(21) == 231
//    sum(22) == 253
//    sum(23) == 277
//    sum(24) == 305
//    sum(25) == 331
//    sum(26) == 361
//    sum(27) == 397
//    sum(28) == 435
//    sum(29) == 485
//    sum(30) == 543
//    sum(31) == 605
//    sum(32) == 678
//    sum(33) == 765
//    sum(34) == 865
//    sum(35) == 985
//    sum(36) == 1118
//    sum(37) == 1255
//    sum(38) == 1416
//    sum(39) == 1591
//    sum(40) == 1779
//    sum(41) == 1975
//    sum(42) == 2182
//    sum(43) == 2401
//    sum(44) == 2640
//    sum(45) == 2905
//    sum(46) == 3195
//    sum(47) == 3516
//    sum(48) == 3885
//    sum(49) == 4285
//    sum(50) == 4703
//    sum(51) == 5165
//    sum(52) == 5728
//    sum(53) == 6325
//    sum(54) == 7018
//    sum(55) == 7825
//    sum(56) == 8650
//    sum(57) == 9665
//    sum(58) == 10816
//    sum(59) == 12151
//    sum(60) == 13696
//    sum(61) == 15451
//    sum(62) == 17416
//    sum(63) == 19591
//    sum(64) == 22060
//    sum(65) == 24755
//    sum(66) == 27721
//    sum(67) == 31005
//    sum(68) == 35486
//    sum

func isPrime(n: Int) -> Bool {
    if n == 1 {
        return false
    }
    for i in 2...n {
        if n % i == 0 {
            return false
        }
    }
    return true
}
```swift
// Return true if a given number is prime, and false otherwise.
// isPrime(n: 6) == false
// isPrime(n: 101) == true
// isPrime(n: 11) == true
// isPrime(n: 13441) == true
// isPrime(n: 61) == true
// isPrime(n: 4) == false
// isPrime(n: 1) == false
func isPrime(n: Int) -> Bool {
    if n == 1 {
        return false
    }
    for i in 2...n {
        if n % i == 0 {
            return false
        }
    }
    return true
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// ---------------------
 // XCTAssertTrue failed

func isPrime(n: Int) -> Bool {
    if n < 2 {
        return false
    }
    for i in 2..<n {
        if n % i == 0 {
            return false
        }
    }
    return true
}
```swift
// Return true if a given number is prime, and false otherwise.
// isPrime(n: 6) == false
// isPrime(n: 101) == true
// isPrime(n: 11) == true
// isPrime(n: 13441) == true
// isPrime(n: 61) == true
// isPrime(n: 4) == false
// isPrime(n: 1) == false
func isPrime(n: Int) -> Bool {
    if n < 2 {
        return false
    }
    for i in 2..<n {
        if n % i == 0 {
            return false
        }
    }
    return true
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// 1. Write a function that takes a string as input and returns the string reversed.
// reverseString("hello") == "olleh"
// reverseString("") == ""
// reverseString("a") == "a"
// reverseString("ab") == "ba"
// reverseString("abc") == "cba"
// reverseString("abcd") == "dcba"
// reverseString("abcdefg") == "gfedcba"
// reverseString("abcdefghijklmnopqrstuvwxyz") == "zyxwvutsrqponmlkjihgfedcba"

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// 2. Write a function that takes an integer as input, and returns the number of
//    1 bits it has (also known as the Hamming weight).
//    numberOf1Bits(11) == 3
//    numberOf1Bits(128) == 1
//    numberOf1Bits(4) == 1
//    numberOf1Bits(0) == 0
//    numberOf1Bits(1) == 1
//    numberOf1Bits(2147483647) == 31
//    numberOf1Bits(2147483648) == 1
//    numberOf1Bits(2147483649) == 1
//    numberOf1Bits(2147483650) == 1
//    numberOf1Bits(2147483651) == 1
//    numberOf1Bits(2147483652) == 1
//    numberOf1Bits(2147483653) == 1
//    numberOf1Bits(2147483654) == 1
//    numberOf1Bits(2147483655) == 1
//    numberOf1Bits(2147483656) == 1
//    numberOf1Bits(2147483657) == 1
//    numberOf1Bits(2147483658) == 1
//    numberOf1Bits(2147483659) == 1
//    numberOf1Bits(2147483660) == 1
//    numberOf1Bits(2147483661) == 1
//    numberOf1Bits(2147483662) == 1
//    numberOf1Bits(2147483663) == 1
//    numberOf1Bits(2147483664) == 1
//    numberOf1Bits(2147483665) == 1
//    numberOf1Bits(2147483666) == 1
//    numberOf1Bits(2147483667) == 1
//    numberOf1Bits(2147483668) == 1
//    numberOf1Bits(2147483669) == 1
//    numberOf1Bits(2147483670) == 1
//    number

func isPrime(n: Int) -> Bool {
    if n < 2 {
        return false
    }
    for i in 2..<n {
        if n % i == 0 {
            return false
        }
    }
    return true
}
```swift
// Return true if a given number is prime, and false otherwise.
// isPrime(n: 6) == false
// isPrime(n: 101) == true
// isPrime(n: 11) == true
// isPrime(n: 13441) == true
// isPrime(n: 61) == true
// isPrime(n: 4) == false
// isPrime(n: 1) == false
func isPrime(n: Int) -> Bool {
    if n < 2 {
        return false
    }
    for i in 2..<n {
        if n % i == 0 {
            return false
        }
    }
    return true
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
//

func isPrime(n: Int) -> Bool {
    if n < 2 {
        return false
    }
    for i in 2..<n {
        if n % i == 0 {
            return false
        }
    }
    return true
}
```swift
// Return true if a given number is prime, and false otherwise.
// isPrime(n: 6) == false
// isPrime(n: 101) == true
// isPrime(n: 11) == true
// isPrime(n: 13441) == true
// isPrime(n: 61) == true
// isPrime(n: 4) == false
// isPrime(n: 1) == false
func isPrime(n: Int) -> Bool {
    if n < 2 {
        return false
    }
    for i in 2..<n {
        if n % i == 0 {
            return false
        }
    }
    return true
}

// -----------------------------------------------------------------------------

// 1. Write a function that takes a number and returns the sum of all numbers
// from 1 up to and including that number.
// sum(1) == 1
// sum(2) == 2 + 1
// sum(3) == 3 + 1 + 2
// sum(4) == 4 + 1 + 2 + 3
// sum(5) == 5 + 1 + 2 + 3 + 4
// sum(6) == 6 + 1 + 2 + 3 + 4 + 5
// sum(7) == 7 + 1 + 2 + 3 + 4 + 5 + 6
// sum(8) == 8 + 1 + 2 + 3 + 4 + 5 + 6 + 7
// sum(9) == 9 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8
// sum(10) == 10 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9
// sum(11) == 11 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10
// sum(12) == 12 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11
// sum(13) == 13 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12
// sum(14) == 14 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13
// sum(15) == 15 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14
// sum(16) == 16 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15
// sum(17) == 17 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16
// sum(18) == 18 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17
// sum(19) == 19 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18
// sum(20) == 20 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19
// sum(21) == 21 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20

func isPrime(n: Int) -> Bool {
    if n < 2 {
        return false
    }
    for i in 2..<n {
        if n % i == 0 {
            return false
        }
    }
    return true
}
```swift
// Return true if a given number is prime, and false otherwise.
// isPrime(n: 6) == false
// isPrime(n: 101) == true
// isPrime(n: 11) == true
// isPrime(n: 13441) == true
// isPrime(n: 61) == true
// isPrime(n: 4) == false
// isPrime(n: 1) == false
func isPrime(n: Int) -> Bool {
    if n < 2 {
        return false
    }
    for i in 2..<n {
        if n % i == 0 {
            return false
        }
    }
    return true
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// ---------------------

func isPrime(n: Int) -> Bool {
    if n == 1 {
        return false
    }
    for i in 2..<n {
        if n % i == 0 {
            return false
        }
    }
    return true
}
```swift
// Return true if a given number is prime, and false otherwise.
// isPrime(n: 6) == false
// isPrime(n: 101) == true
// isPrime(n: 11) == true
// isPrime(n: 13441) == true
// isPrime(n: 61) == true
// isPrime(n: 4) == false
// isPrime(n: 1) == false
func isPrime(n: Int) -> Bool {
    if n == 1 {
        return false
    }
    for i in 2..<n {
        if n % i == 0 {
            return false
        }
    }
    return true
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
//

func isPrime(n: Int) -> Bool {
    if n == 1 {
        return false
    }
    for i in 2..<n {
        if n % i == 0 {
            return false
        }
    }
    return true
}

func vowels(string: String) -> Int {
    var vowels = 0
    for char in string {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            vowels += 1
        }
    }
    return vowels
}

func consonants(string: String) -> Int {
    var consonants = 0
    for char in string {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" && char != " " {
            consonants += 1
        }
    }
    return consonants
}
```swift
// Return true if a given number is prime, and false otherwise.
// isPrime(n: 6) == false
// isPrime(n: 101) == true
// isPrime(n: 11) == true
// isPrime(n: 13441) == true
// isPrime(n: 61) == true
// isPrime(n: 4) == false
// isPrime(n: 1) == false
func isPrime(n: Int) -> Bool {
    if n == 1 {
        return false
    }
    for i in 2..<n {
        if n % i == 0 {
            return false
        }
    }
    return true
}

// -----------------------------------------------------------------------------
// 10. Write a function that takes a string and returns the number of vowels in
//     the string.
//     vowels: a, e, i, o, u
//     a case-insensitive.
//     vowels("Hello") == 2
//     vowels("Why do you ask?") == 4
//     vowels("Why?") == 0
//     vowels("C is cool") == 2
// -----------------------------------------------------------------------------
// 10. Write a function that takes a string and returns the number of vowels in
//     the string.
//     vowels: a, e, i, o, u
//     a case-insensitive.
//     vowels("Hello") == 2
//     vowels("Why do you ask?") == 4
//     vowels("Why?") == 0
//     vowels("C is cool") == 2
func vowels(string: String) -> Int {
    var vowels = 0
    for char in string {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            vowels += 1
        }
    }
    return vowels
}

// -----------------------------------------------------------------------------
// 11. Write a function that takes a string and returns the number of consonants
//     in the string.
//     vowels: a, e, i, o, u
//     a case-insensitive.
//     consonants("Hello") == 3
//     consonants("Why do you ask?") == 5
//     consonants("Why?") == 1
//     consonants("C is cool") == 3
// -----------------------------------------------------------------------------
// 11. Write a function that takes a string and returns the number of consonants
//     in the string.
//     vowels: a, e, i, o, u
//     a case-insensitive.
//     consonants("Hello") == 3
//     consonants("Why do you ask?") == 5
//     consonants("Why?") == 1
//     consonants("C is cool") == 3
func consonants(string: String) -> Int {
    var consonants = 0
    for char in string {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" && char != " " {
            consonants += 1
        }
    }
    return consonants
}

// -----------------------------------------------------------------------------
// 12. Write a function that takes a string and returns the number of words in
//     the string.
//     words: a sequence of characters separated by whitespace
//     words("Hello world") == 2
//     words("Hello") == 1
//     words("Hello, world") == 2
//     words("Hello, world!") == 2
//     words("Hello, world!!!") == 2
//     words("Hello, world!!!!") == 2
//     words("Hello, world!!!!!") == 2
//     words("Hello, world!!!!!!") == 2
//     words("Hello, world!!!

func isPrime(n: Int) -> Bool {
    if n == 1 {
        return false
    }
    for i in 2..<n {
        if n % i == 0 {
            return false
        }
    }
    return true
}
```swift
// Return true if a given number is prime, and false otherwise.
// isPrime(n: 6) == false
// isPrime(n: 101) == true
// isPrime(n: 11) == true
// isPrime(n: 13441) == true
// isPrime(n: 61) == true
// isPrime(n: 4) == false
// isPrime(n: 1) == false
func isPrime(n: Int) -> Bool {
    if n == 1 {
        return false
    }
    for i in 2..<n {
        if n % i == 0 {
            return false
        }
    }
    return true
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

//

func sortThird(l: [Int]) -> [Int] {
    var l' = l
    for i in 0..<l.count {
        if i % 3 == 0 {
            l'.sort()
        }
    }
    return l'
}

func removeVowels(s: String) -> String {
    var s' = s
    for c in "aeiouAEIOU" {
        s' = s'.replacingOccurrences(with: c, with: "")
    }
    return s'
}

func removeConsonants(s: String) -> String {
    var s' = s
    for c in "bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ" {
        s' = s'.replacingOccurrences(with: c, with: "")
    }
    return s'
}
```swift
// This function takes an array l and returns an array l' such that
// l' is identical to l in the indicies that are not divisible by three, while its values at the indicies that are divisible by three are equal
// to the values of the corresponding indicies of l, but sorted.
// sortThird(l: [1, 2, 3]) == [1, 2, 3]
// sortThird(l: [5, 6, 3, 4, 8, 9, 2]) == [2, 6, 3, 4, 8, 9, 5]
func sortThird(l: [Int]) -> [Int] {
    var l' = l
    for i in 0..<l.count {
        if i % 3 == 0 {
            l'.sort()
        }
    }
    return l'
}

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// 1. Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels("I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
// removeVowels("abracadabra") == "brcrdbr"
// removeVowels("pear tree") == " pr t"
// removeVowels("o a kwek") == " kwk"
func removeVowels(s: String) -> String {
    var s' = s
    for c in "aeiouAEIOU" {
        s' = s'.replacingOccurrences(with: c, with: "")
    }
    return s'
}

// 2. Write a function that takes a string and returns a new string with all the consonants removed.
// removeConsonants("I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
// removeConsonants("abracadabra") == "brcrdbr"
// removeConsonants("pear tree") == " pr t"
// removeConsonants("o a kwek") == " kwk"
func removeConsonants(s: String) -> String {
    var s' = s
    for c in "bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ" {
        s' = s'.replacingOccurrences(with: c, with: "")
    }
    return s'
}

// 3. Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels("I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
// removeVowels("abracadabra") == "brcrdbr"
// removeVowels("pear tree") == " pr t"
// removeVowels("o a kwek") == " kwk"
func removeVowels(s: String) -> String {
    var s' = s
    for c in "aeiouAEIOU" {
        s' = s'.replacingOccurrences(with: c, with: "")
    }
    return s'
}

// 4. Write a function that takes a string and returns a new string with all the consonants removed.
// removeConsonants("I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
// removeConsonants("abracadabra") == "brcrdbr"
// removeConsonants("pear tree") == " pr t"
// removeConsonants("o a kwek") == " kwk"
func removeConsonants(s: String) -> String {
    var s' = s
    for c in "bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ" {
        s' = s'.replacingOccurrences(with: c, with: "")
    }
    return s'
}

// 5. Write a function that takes a string and returns a new string with all
var l' = l // unterminated string literal
var l' = l // type annotation missing in pattern
l'.sort() // unterminated string literal
return l' // unterminated string literal
var s' = s // unterminated string literal
var s' = s // type annotation missing in pattern
s' = s'.replacingOccurrences(with: c, with: "") // extra argument 'with' in call
s' = s'.replacingOccurrences(with: c, with: "") // single-quoted string literal found, use '"'
s' = s'.replacingOccurrences(with: c, with: "") // consecutive statements on a line must be separated by ';'
s' = s'.replacingOccurrences(with: c, with: "") // instance method 'replacingOccurrences(of:with:options:range:)' requires that 'Character' conform to 'StringProtocol'
s' = s'.replacingOccurrences(with: c, with: "") // missing argument for parameter 'of' in call
return s' // unterminated string literal
var s' = s // type annotation missing in pattern
var s' = s // unterminated string literal
s' = s'.replacingOccurrences(with: c, with: "") // single-quoted string literal found, use '"'
s' = s'.replacingOccurrences(with: c, with: "") // extra argument 'with' in call
s' = s'.replacingOccurrences(with: c, with: "") // missing argument for parameter 'of' in call
s' = s'.replacingOccurrences(with: c, with: "") // consecutive statements on a line must be separated by ';'
s' = s'.replacingOccurrences(with: c, with: "") // instance method 'replacingOccurrences(of:with:options:range:)' requires that 'Character' conform to 'StringProtocol'
return s' // unterminated string literal

func sortThird(l: [Int]) -> [Int] {
    var l' = l
    for i in 0..<l.count {
        if i % 3 == 0 {
            continue
        }
        for j in 0..<l.count {
            if l[i] < l[j] {
                l[i], l[j] = l[j], l[i]
            }
        }
    }
    return l'
}
```swift
// This function takes an array l and returns an array l' such that
// l' is identical to l in the indicies that are not divisible by three, while its values at the indicies that are divisible by three are equal
// to the values of the corresponding indicies of l, but sorted.
// sortThird(l: [1, 2, 3]) == [1, 2, 3]
// sortThird(l: [5, 6, 3, 4, 8, 9, 2]) == [2, 6, 3, 4, 8, 9, 5]
func sortThird(l: [Int]) -> [Int] {
    var l' = l
    for i in 0..<l.count {
        if i % 3 == 0 {
            continue
        }
        for j in 0..<l.count {
            if l[i] < l[j] {
                l[i], l[j] = l[j], l[i]
            }
        }
    }
    return l'
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ---------------------------
var l' = l // type annotation missing in pattern
var l' = l // unterminated string literal
l[i], l[j] = l[j], l[i] // expected expression
l[i], l[j] = l[j], l[i] // consecutive statements on a line must be separated by ';'
return l' // unterminated string literal

func sortThird(l: [Int]) -> [Int] {
    var l' = l
    for i in 0..<l.count {
        if i % 3 == 0 {
            l'.sort()
        }
    }
    return l'
}
```swift
// This function takes an array l and returns an array l' such that
// l' is identical to l in the indicies that are not divisible by three, while its values at the indicies that are divisible by three are equal
// to the values of the corresponding indicies of l, but sorted.
// sortThird(l: [1, 2, 3]) == [1, 2, 3]
// sortThird(l: [5, 6, 3, 4, 8, 9, 2]) == [2, 6, 3, 4, 8, 9, 5]
func sortThird(l: [Int]) -> [Int] {
    var l' = l
    for i in 0..<l.count {
        if i % 3 == 0 {
            l'.sort()
        }
    }
    return l'
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 
var l' = l // unterminated string literal
var l' = l // type annotation missing in pattern
l'.sort() // unterminated string literal
return l' // unterminated string literal

func sortThird(l: [Int]) -> [Int] {
    var l' = l
    for i in 0..<l.count {
        if i % 3 == 0 {
            l'.sort()
        }
    }
    return l'
}
```swift
// This function takes an array l and returns an array l' such that
// l' is identical to l in the indicies that are not divisible by three, while its values at the indicies that are divisible by three are equal
// to the values of the corresponding indicies of l, but sorted.
// sortThird(l: [1, 2, 3]) == [1, 2, 3]
// sortThird(l: [5, 6, 3, 4, 8, 9, 2]) == [2, 6, 3, 4, 8, 9, 5]
func sortThird(l: [Int]) -> [Int] {
    var l' = l
    for i in 0..<l.count {
        if i % 3 == 0 {
            l'.sort()
        }
    }
    return l'
}

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------
var l' = l // unterminated string literal
var l' = l // type annotation missing in pattern
l'.sort() // unterminated string literal
return l' // unterminated string literal

func sortThird(l: [Int]) -> [Int] {
    var l' = l
    for i in 0..<l.count {
        if i % 3 != 0 {
            l'[i] = l[i]
        }
    }
    l'.sort()
    for i in 0..<l.count {
        if i % 3 == 0 {
            l'[i] = l[i]
        }
    }
    return l'
}
```swift
// This function takes an array l and returns an array l' such that
// l' is identical to l in the indicies that are not divisible by three, while its values at the indicies that are divisible by three are equal
// to the values of the corresponding indicies of l, but sorted.
// sortThird(l: [1, 2, 3]) == [1, 2, 3]
// sortThird(l: [5, 6, 3, 4, 8, 9, 2]) == [2, 6, 3, 4, 8, 9, 5]
func sortThird(l: [Int]) -> [Int] {
    var l' = l
    for i in 0..<l.count {
        if i % 3 != 0 {
            l'[i] = l[i]
        }
    }
    l'.sort()
    for i in 0..<l.count {
        if i % 3 == 0 {
            l'[i] = l[i]
        }
    }
    return l'
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ------
var l' = l // type annotation missing in pattern
var l' = l // unterminated string literal
l'[i] = l[i] // unterminated string literal
l'.sort() // unterminated string literal
l'[i] = l[i] // unterminated string literal
return l' // unterminated string literal

func sortThird(l: [Int]) -> [Int] {
    var l' = l
    for i in 0..<l.count {
        if i % 3 == 0 {
            l'.sort()
        }
    }
    return l'
}
```swift
// This function takes an array l and returns an array l' such that
// l' is identical to l in the indicies that are not divisible by three, while its values at the indicies that are divisible by three are equal
// to the values of the corresponding indicies of l, but sorted.
// sortThird(l: [1, 2, 3]) == [1, 2, 3]
// sortThird(l: [5, 6, 3, 4, 8, 9, 2]) == [2, 6, 3, 4, 8, 9, 5]
func sortThird(l: [Int]) -> [Int] {
    var l' = l
    for i in 0..<l.count {
        if i % 3 == 0 {
            l'.sort()
        }
    }
    return l'
}

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------
var l' = l // unterminated string literal
var l' = l // type annotation missing in pattern
l'.sort() // unterminated string literal
return l' // unterminated string literal

func sortThird(l: [Int]) -> [Int] {
    var l' = l
    for i in 0..<l.count {
        if i % 3 == 0 {
            l'.sort()
        }
    }
    return l'
}
```swift
// This function takes an array l and returns an array l' such that
// l' is identical to l in the indicies that are not divisible by three, while its values at the indicies that are divisible by three are equal
// to the values of the corresponding indicies of l, but sorted.
// sortThird(l: [1, 2, 3]) == [1, 2, 3]
// sortThird(l: [5, 6, 3, 4, 8, 9, 2]) == [2, 6, 3, 4, 8, 9, 5]
func sortThird(l: [Int]) -> [Int] {
    var l' = l
    for i in 0..<l.count {
        if i % 3 == 0 {
            l'.sort()
        }
    }
    return l'
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 10. Write a function that takes an array l and returns an array l' such that
// l' is identical to l in the indicies that are not divisible by three, while its values at the indicies that are divisible by three are equal
// to the values of the corresponding indicies of l, but sorted.
// sortThird(l: [1, 2, 3]) == [1, 2, 3]
// sortThird(l: [5, 6, 3, 4, 8, 9, 2]) == [2, 6, 3, 4, 8, 9, 5]
func sortThird(l: [Int]) -> [Int] {
    var l' = l
    for i in 0..<l.count {
        if i % 3 == 0 {
            l'.sort()
        }
    }
    return l'
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 11. Write a function that takes an array l and returns an array l' such that
// l' is identical to l in the indicies that are not divisible by three, while its values at the indicies that are divisible by three are equal
// to the values of the corresponding indicies of l, but sorted.
// sortThird(l: [1, 2, 3]) == [1, 2, 3]
// sortThird(l: [5, 6, 3, 4, 8, 9, 2]) == [2, 6, 3, 4, 8, 9, 5]
func sortThird(l: [Int]) -> [Int] {
    var l' = l
    for i in 0..<l.count {
        if i % 3 == 0 {
            l'.sort()
        }
    }
    return l'
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 12. Write a function that takes an array l and returns an array l' such that
// l' is identical to l in the indicies that are not divisible by three, while its values at the indicies that are divisible by three are equal
// to the values of the corresponding indicies of l, but sorted.
// sortThird(l: [1, 2, 3]) == [1, 2, 3]
// sortThird(l: [5, 6, 3, 4, 8, 9, 2]) == [2, 6, 3, 4, 8, 9, 5]
func sortThird(l: [Int]) -> [Int] {
    var l' = l
    for i in 0..<l.count {
        if i % 3 == 0 {
            l'.sort()
        }
    }
    return l'
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 13. Write a function that takes an array l and returns an array l' such that
// l' is identical to l in the indicies that are not divisible by three, while its values at the indicies that are divisible by three are equal
// to the values of the corresponding indicies of l, but sorted.
// sortThird(l: [1, 2, 3]) == [1, 2, 3]
// sortThird(l: [5, 6, 3, 4, 8,
var l' = l // unterminated string literal
var l' = l // type annotation missing in pattern
l'.sort() // unterminated string literal
return l' // unterminated string literal

func sortThird(l: [Int]) -> [Int] {
    var l' = l
    for i in 0..<l.count {
        if i % 3 != 0 {
            l'[i] = l[i]
        }
    }
    for i in 0..<l.count {
        if i % 3 == 0 {
            for j in 0..<l.count {
                if l[j] < l[i] {
                    l[i] = l[j]
                    l[j] = l[i - 1]
                }
            }
        }
    }
    return l'
}
```swift
// This function takes an array l and returns an array l' such that
// l' is identical to l in the indicies that are not divisible by three, while its values at the indicies that are divisible by three are equal
// to the values of the corresponding indicies of l, but sorted.
// sortThird(l: [1, 2, 3]) == [1, 2, 3]
// sortThird(l: [5, 6, 3, 4, 8, 9, 2]) == [2, 6, 3, 4, 8, 9, 5]
func sortThird(l: [Int]) -> [Int] {
    var l' = l
    for i in 0..<l.count {
        if i % 3 != 0 {
            l'[i] = l[i]
        }
    }
    for i in 0..<l.count {
        if i % 3 == 0 {
            for j in 0..<l.count {
                if l[j] < l[i] {
                    l[i] = l[j]
                    l[j] = l[i - 1]
                }
            }
        }
    }
    return l'
}

// -----------------------------------------------------------------------------

// 1. Write a function that takes a string and returns a string with all the
//    letters in alphabetical order.
//    sortLetters("hello") == "ehllo"
//    sortLetters("apple") == "aellpp"
//    sortLetters("zoo") == "oozz"
//    sortLetters("") == ""
//    sortLetters("a") == "a"
//    sortLetters("zz") == "zz"
//    sortLetters("zzz") == "zzzz"
//    sortLetters("zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
var l' = l // unterminated string literal
var l' = l // type annotation missing in pattern
l'[i] = l[i] // unterminated string literal
return l' // unterminated string literal

func sortThird(l: [Int]) -> [Int] {
    var result = [Int]()
    for i in 0..<l.count {
        if i % 3 == 0 {
            result.append(l[i])
        }
    }
    result.sort()
    for i in 0..<l.count {
        if i % 3 != 0 {
            result.append(l[i])
        }
    }
    return result
}
```swift
// This function takes an array l and returns an array l' such that
// l' is identical to l in the indicies that are not divisible by three, while its values at the indicies that are divisible by three are equal
// to the values of the corresponding indicies of l, but sorted.
// sortThird(l: [1, 2, 3]) == [1, 2, 3]
// sortThird(l: [5, 6, 3, 4, 8, 9, 2]) == [2, 6, 3, 4, 8, 9, 5]
func sortThird(l: [Int]) -> [Int] {
    var result = [Int]()
    for i in 0..<l.count {
        if i % 3 == 0 {
            result.append(l[i])
        }
    }
    result.sort()
    for i in 0..<l.count {
        if i % 3 != 0 {
            result.append(l[i])
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ------------------
 // XCTAssertTrue failed

func sortThird(l: [Int]) -> [Int] {
    var sorted = [Int]()
    var sortedIndex = 0
    for index in l.enumerated() {
        if index.1 % 3 == 0 {
            sorted.append(index.1)
        } else {
            sorted[sortedIndex] = index.1
            sortedIndex += 1
        }
    }
    return sorted
}
```swift
// This function takes an array l and returns an array l' such that
// l' is identical to l in the indicies that are not divisible by three, while its values at the indicies that are divisible by three are equal
// to the values of the corresponding indicies of l, but sorted.
// sortThird(l: [1, 2, 3]) == [1, 2, 3]
// sortThird(l: [5, 6, 3, 4, 8, 9, 2]) == [2, 6, 3, 4, 8, 9, 5]
func sortThird(l: [Int]) -> [Int] {
    var sorted = [Int]()
    var sortedIndex = 0
    for index in l.enumerated() {
        if index.1 % 3 == 0 {
            sorted.append(index.1)
        } else {
            sorted[sortedIndex] = index.1
            sortedIndex += 1
        }
    }
    return sorted
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ---
 // Fatal error: Index out of range

func unique(l: [Int]) -> [Int] {
    var result = [Int]()
    for i in l {
        if !result.contains(i) {
            result.append(i)
        }
    }
    return result
}
```swift
// Return sorted unique elements in an array
// unique(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [0, 2, 3, 5, 9, 123]
func unique(l: [Int]) -> [Int] {
    var result = [Int]()
    for i in l {
        if !result.contains(i) {
            result.append(i)
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ------------
 // XCTAssertTrue failed

func unique(l: [Int]) -> [Int] {
    return l.sorted().distinct()
}
```swift
// Return sorted unique elements in an array
// unique(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [0, 2, 3, 5, 9, 123]
func unique(l: [Int]) -> [Int] {
    return l.sorted().distinct()
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ---------------------------
return l.sorted().distinct() // value of type '[Int]' has no member 'distinct'

func unique(l: [Int]) -> [Int] {
    return l.sorted().distinct()
}
```swift
// Return sorted unique elements in an array
// unique(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [0, 2, 3, 5, 9, 123]
func unique(l: [Int]) -> [Int] {
    return l.sorted().distinct()
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ---------------------------
return l.sorted().distinct() // value of type '[Int]' has no member 'distinct'

func unique(l: [Int]) -> [Int] {
    return l.sorted(by: { $0 < $1 }).distinct()
}
```swift
// Return sorted unique elements in an array
// unique(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [0, 2, 3, 5, 9, 123]
func unique(l: [Int]) -> [Int] {
    return l.sorted(by: { $0 < $1 }).distinct()
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ---------
return l.sorted(by: { $0 < $1 }).distinct() // value of type '[Int]' has no member 'distinct'

func unique(l: [Int]) -> [Int] {
    var result = [Int]()
    for i in l {
        if !result.contains(i) {
            result.append(i)
        }
    }
    return result
}
```swift
// Return sorted unique elements in an array
// unique(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [0, 2, 3, 5, 9, 123]
func unique(l: [Int]) -> [Int] {
    var result = [Int]()
    for i in l {
        if !result.contains(i) {
            result.append(i)
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ------------
 // XCTAssertTrue failed

func unique(l: [Int]) -> [Int] {
    var result = l
    result.sort()
    var unique = [Int]()
    for i in result {
        if !unique.contains(i) {
            unique.append(i)
        }
    }
    return unique
}
```swift
// Return sorted unique elements in an array
// unique(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [0, 2, 3, 5, 9, 123]
func unique(l: [Int]) -> [Int] {
    var result = l
    result.sort()
    var unique = [Int]()
    for i in result {
        if !unique.contains(i) {
            unique.append(i)
        }
    }
    return unique
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ------------------------------------------------------------------

func unique(l: [Int]) -> [Int] {
    var result = l
    result.sort()
    var i = 0
    while i < result.count - 1 {
        if result[i] == result[i + 1] {
            result.remove(at: i)
        } else {
            i += 1
        }
    }
    return result
}
```swift
// Return sorted unique elements in an array
// unique(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [0, 2, 3, 5, 9, 123]
func unique(l: [Int]) -> [Int] {
    var result = l
    result.sort()
    var i = 0
    while i < result.count - 1 {
        if result[i] == result[i + 1] {
            result.remove(at: i)
        } else {
            i += 1
        }
    }
    return result
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// ---------------------------------------------------------------------------

func unique(l: [Int]) -> [Int] {
    var result = [Int]()
    for i in l {
        if !result.contains(i) {
            result.append(i)
        }
    }
    return result
}
```swift
// Return sorted unique elements in an array
// unique(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [0, 2, 3, 5, 9, 123]
func unique(l: [Int]) -> [Int] {
    var result = [Int]()
    for i in l {
        if !result.contains(i) {
            result.append(i)
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// ------------
 // XCTAssertTrue failed

func unique(l: [Int]) -> [Int] {
    var sorted = l.sorted()
    var result = [sorted.first!]
    for i in 1..<sorted.count {
        if sorted[i] != sorted[i - 1] {
            result.append(sorted[i])
        }
    }
    return result
}
```swift
// Return sorted unique elements in an array
// unique(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [0, 2, 3, 5, 9, 123]
func unique(l: [Int]) -> [Int] {
    var sorted = l.sorted()
    var result = [sorted.first!]
    for i in 1..<sorted.count {
        if sorted[i] != sorted[i - 1] {
            result.append(sorted[i])
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ------------
var sorted = l.sorted() // variable 'sorted' was never mutated; consider changing to 'let' constant

func unique(l: [Int]) -> [Int] {
    var result = l.sorted()
    var i = 0
    while i < result.count - 1 {
        if result[i] == result[i + 1] {
            result.remove(at: i)
        } else {
            i += 1
        }
    }
    return result
}
```swift
// Return sorted unique elements in an array
// unique(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [0, 2, 3, 5, 9, 123]
func unique(l: [Int]) -> [Int] {
    var result = l.sorted()
    var i = 0
    while i < result.count - 1 {
        if result[i] == result[i + 1] {
            result.remove(at: i)
        } else {
            i += 1
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ------------

func maxElement(l: [Int]) -> Int {
    var max = l[0]
    for i in l {
        if i > max {
            max = i
        }
    }
    return max
}
```swift
// Return maximum element in the array.
// maxElement(l: [1, 2, 3]) == 3
// maxElement(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 123
func maxElement(l: [Int]) -> Int {
    var max = l[0]
    for i in l {
        if i > max {
            max = i
        }
    }
    return max
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// ------------------------------------

func maxElement(l: [Int]) -> Int {
    var max = l[0]
    for i in l {
        if i > max {
            max = i
        }
    }
    return max
}
```swift
// Return maximum element in the array.
// maxElement(l: [1, 2, 3]) == 3
// maxElement(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 123
func maxElement(l: [Int]) -> Int {
    var max = l[0]
    for i in l {
        if i > max {
            max = i
        }
    }
    return max
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// ------------------------------------

func maxElement(l: [Int]) -> Int {
    var max = l[0]
    for i in l {
        if i > max {
            max = i
        }
    }
    return max
}
```swift
// Return maximum element in the array.
// maxElement(l: [1, 2, 3]) == 3
// maxElement(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 123
func maxElement(l: [Int]) -> Int {
    var max = l[0]
    for i in l {
        if i > max {
            max = i
        }
    }
    return max
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ------------------------------------

func maxElement(l: [Int]) -> Int {
    var max = l[0]
    for i in l {
        if i > max {
            max = i
        }
    }
    return max
}
```swift
// Return maximum element in the array.
// maxElement(l: [1, 2, 3]) == 3
// maxElement(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 123
func maxElement(l: [Int]) -> Int {
    var max = l[0]
    for i in l {
        if i > max {
            max = i
        }
    }
    return max
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// ------------------------------------------------------------

func maxElement(l: [Int]) -> Int {
    var max = l[0]
    for i in l {
        if i > max {
            max = i
        }
    }
    return max
}
```swift
// Return maximum element in the array.
// maxElement(l: [1, 2, 3]) == 3
// maxElement(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 123
func maxElement(l: [Int]) -> Int {
    var max = l[0]
    for i in l {
        if i > max {
            max = i
        }
    }
    return max
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// ------------------------------------------------------------

func maxElement(l: [Int]) -> Int {
    var max = l[0]
    for i in l {
        if i > max {
            max = i
        }
    }
    return max
}
```swift
// Return maximum element in the array.
// maxElement(l: [1, 2, 3]) == 3
// maxElement(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 123
func maxElement(l: [Int]) -> Int {
    var max = l[0]
    for i in l {
        if i > max {
            max = i
        }
    }
    return max
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1

func maxElement(l: [Int]) -> Int {
    var max = l[0]
    for i in l {
        if i > max {
            max = i
        }
    }
    return max
}
```swift
// Return maximum element in the array.
// maxElement(l: [1, 2, 3]) == 3
// maxElement(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 123
func maxElement(l: [Int]) -> Int {
    var max = l[0]
    for i in l {
        if i > max {
            max = i
        }
    }
    return max
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ------------------------------------

func maxElement(l: [Int]) -> Int {
    return l.max()!
}
```swift
// Return maximum element in the array.
// maxElement(l: [1, 2, 3]) == 3
// maxElement(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 123
func maxElement(l: [Int]) -> Int {
    return l.max()!
}

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//
//  maxElement
//

//

func maxElement(l: [Int]) -> Int {
    var max = l[0]
    for i in l {
        if i > max {
            max = i
        }
    }
    return max
}
```swift
// Return maximum element in the array.
// maxElement(l: [1, 2, 3]) == 3
// maxElement(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 123
func maxElement(l: [Int]) -> Int {
    var max = l[0]
    for i in l {
        if i > max {
            max = i
        }
    }
    return max
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// ------------------------------------------------------------

func maxElement(l: [Int]) -> Int {
    var max = l[0]
    for i in l {
        if i > max {
            max = i
        }
    }
    return max
}

struct maxElementTests {
    static let allTests: [UITestCase] = [
        UITestCase(
            name: "maxElement",
            description: """
            maxElement(l: [1, 2, 3]) == 3
            maxElement(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 123
            """,
            expected: "3\n123",
            actual: """
            maxElement(l: [1, 2, 3]) == 3
            maxElement(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 123
            """
        )
    ]
}

struct maxElementTestsRunner: XCTestCase {
    static func suite() -> XCTest {
        return XCTest(
            name: "maxElement",
            description: """
            maxElement(l: [1, 2, 3]) == 3
            maxElement(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 123
            """,
            tests: maxElementTests.allTests
        )
    }
}

import Foundation
```swift
// Return maximum element in the array.
// maxElement(l: [1, 2, 3]) == 3
// maxElement(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 123
func maxElement(l: [Int]) -> Int {
    var max = l[0]
    for i in l {
        if i > max {
            max = i
        }
    }
    return max
}

// -----------------------------------------------------------------------------

struct maxElementTests {
    static let allTests: [UITestCase] = [
        UITestCase(
            name: "maxElement",
            description: """
            maxElement(l: [1, 2, 3]) == 3
            maxElement(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 123
            """,
            expected: "3\n123",
            actual: """
            maxElement(l: [1, 2, 3]) == 3
            maxElement(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 123
            """
        )
    ]
}

// -----------------------------------------------------------------------------

struct maxElementTestsRunner: XCTestCase {
    static func suite() -> XCTest {
        return XCTest(
            name: "maxElement",
            description: """
            maxElement(l: [1, 2, 3]) == 3
            maxElement(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 123
            """,
            tests: maxElementTests.allTests
        )
    }
}<|endoftext|>//
//  main.swift
//  10.1.1
//
//  Created by Даниил on 10.04.2020.
//  Copyright © 2020 Danil. All rights reserved.
//

import Foundation

// -----------------------------------------------------------------------------

// 1. Написать функцию, которая принимает на вход строку и возвращает
// новую строку, в которой каждый символ заменен на символ, который стоит
// на позиции символа в исходной строке.
//
// Пример:
//
// string("hello") == "olleh"
// string("bye") == "yb"
// string("") == ""
// string("a") == "a"

// -----------------------------------------------------------------------------

// 2. Написать функцию, которая принимает на вход строку и возвращает
// новую строку, в которой каждый символ заменен на символ, который стоит
// на позиции символа в исходной строке.
//
// Пример:
//
// string("hello") == "olleh"
// string("bye") == "yb"
// string("") == ""
// string("a") == "a"

// -----------------------------------------------------------------------------

// 3. Написать функцию, которая принимает на вход строку и возвращает
// новую строку, в которой каждый символ заменен на символ, который стоит
// на позиции символа в исходной строке.
//
// Пример:
//
//
static let allTests: [UITestCase] = [ // cannot find type 'UITestCase' in scope
struct maxElementTestsRunner: XCTestCase { // inheritance from non-protocol type 'XCTestCase'
static func suite() -> XCTest { // cannot find type 'XCTest' in scope

func fizzBuzz(n: Int) -> Int {
    var count = 0
    for i in 1...n {
        if i % 11 == 0 || i % 13 == 0 {
            count += 1
        }
    }
    return count
}

func reverseString(s: String) -> String {
    return String(s.reversed())
}

func countBits(n: Int) -> Int {
    var count = 0
    while n > 0 {
        if n & 1 == 1 {
            count += 1
        }
        n >>= 1
    }
    return count
}

func addDigits(num: Int) -> Int {
    if num < 10 {
        return num
    }
    return num % 9 == 0 ? 9 : num % 9
}
```swift
// Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.
// fizzBuzz(n: 50) == 0
// fizzBuzz(n: 78) == 2
// fizzBuzz(n: 79) == 3
func fizzBuzz(n: Int) -> Int {
    var count = 0
    for i in 1...n {
        if i % 11 == 0 || i % 13 == 0 {
            count += 1
        }
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 11. Write a function that takes a string as input and returns the string reversed.
// Example:
// Given s = "hello", return "olleh".
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 12. Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number.
// Example:
// Input: 11
// Output: 3
// Explanation: 11 (1011) has binary representation 00011110 and contains three ones.
func countBits(n: Int) -> Int {
    var count = 0
    while n > 0 {
        if n & 1 == 1 {
            count += 1
        }
        n >>= 1
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 13. Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.
// Example:
// Input: 38
// Output: 2
// Explanation: The process is like: 3 + 8 = 11, 1 + 1 = 2.
//              Since 2 has only one digit, return it.
func addDigits(num: Int) -> Int {
    if num < 10 {
        return num
    }
    return num % 9 == 0 ? 9 : num % 9
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 14. Given a non-negative integer, repeatedly add all its digits until the result has only one digit.
// Example:
// Input: 38
// Output: 2
// Explanation: The process is like: 3 + 8 = 11, 1 + 1 = 2.
//              Since 2 has only one digit, return it.
func addDigits(num: Int) -> Int {
    if num < 10 {
        return num
    }
    return num % 9 == 0 ? 9 : num % 9
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 15. Given a non-negative integer, repeatedly add all its digits until the result has only one digit.
// Example:
// Input: 38
// Output: 2
// Explanation: The process is like: 3 + 8 = 11, 1 + 1 = 2.
//              Since 2 has only one digit, return it.
func addDigits(num: Int) -> Int {
    if num < 10 {
        return num
    }
    return num % 9 == 0 ? 9 : num % 9
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 16. Given a non-negative integer, repeatedly add all its digits until the result has only one digit.
// Example:
// Input: 38
// Output: 2
// Explanation: The process is like: 3 + 8
n >>= 1 // left side of mutating operator isn't mutable: 'n' is a 'let' constant

func fizzBuzz(n: Int) -> Int {
    var count = 0
    for i in 1...n {
        if i % 11 == 0 || i % 13 == 0 {
            count += 1
        }
    }
    return count
}

func reverseString(s: String) -> String {
    return String(s.reversed())
}

func singleNumber(nums: [Int]) -> Int {
    return nums.reduce(0, ^(let acc, let num) { acc ^= num })
}

func singleNumber2(nums: [Int]) -> Int {
    var ones = 0
    var twos = 0
    for num in nums {
        ones = (ones ^ num) & ~twos
        twos = (twos ^ num) & ~ones
    }
    return ones
}

func singleNumber3(nums: [Int]) -> Int {
    var ones = 0
    var twos = 0
    for num in nums {
        ones = (ones ^ num) & ~twos
        twos = (twos ^ num) & ~ones
    }
    return ones
}

func singleNumber4(nums: [Int]) -> Int {
    var ones = 0
    var twos = 0
    for num in nums {
        ones = (ones ^ num) & ~twos
        twos = (twos ^ num) & ~ones
    }
    return ones
}
```swift
// Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.
// fizzBuzz(n: 50) == 0
// fizzBuzz(n: 78) == 2
// fizzBuzz(n: 79) == 3
func fizzBuzz(n: Int) -> Int {
    var count = 0
    for i in 1...n {
        if i % 11 == 0 || i % 13 == 0 {
            count += 1
        }
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 10. Write a function that takes a string as input and returns the string reversed.
// Example:
// Given s = "hello", return "olleh".
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 11. Given an array of integers, every element appears twice except for one. Find that single one.
// Note:
// Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?
// Example:
// Input: [2,2,1]
// Output: 1
func singleNumber(nums: [Int]) -> Int {
    return nums.reduce(0, ^(let acc, let num) { acc ^= num })
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 12. Given an array of integers, every element appears three times except for one. Find that single one.
// Note:
// Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?
// Example:
// Input: [2,2,3,2]
// Output: 3
func singleNumber2(nums: [Int]) -> Int {
    var ones = 0
    var twos = 0
    for num in nums {
        ones = (ones ^ num) & ~twos
        twos = (twos ^ num) & ~ones
    }
    return ones
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 13. Given an array of integers, every element appears three times except for one. Find that single one.
// Note:
// Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?
// Example:
// Input: [2,2,3,2]
// Output: 3
func singleNumber3(nums: [Int]) -> Int {
    var ones = 0
    var twos = 0
    for num in nums {
        ones = (ones ^ num) & ~twos
        twos = (twos ^ num) & ~ones
    }
    return ones
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 14. Given an array of integers, every element appears three times except for one. Find that single one.
// Note:
// Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?
// Example:
// Input: [2,2,3,2]
// Output: 3
func singleNumber4(nums: [Int]) -> Int {
    var ones = 0
    var twos = 0
    for num in nums {
        ones = (ones ^ num) & ~twos
        twos = (twos ^ num) & ~ones
    }
    return ones
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 15. Given an array of integers, every element appears three times except for one. Find that single one.
// Note:
// Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?
// Example:
// Input: [2,2
return nums.reduce(0, ^(let acc, let num) { acc ^= num }) // 'let' cannot appear nested inside another 'var' or 'let' pattern
return nums.reduce(0, ^(let acc, let num) { acc ^= num }) // type annotation missing in pattern
return nums.reduce(0, ^(let acc, let num) { acc ^= num }) // expected expression
return nums.reduce(0, ^(let acc, let num) { acc ^= num }) // consecutive statements on a line must be separated by ';'
return nums.reduce(0, ^(let acc, let num) { acc ^= num }) // expected expression in list of expressions
return nums.reduce(0, ^(let acc, let num) { acc ^= num }) // type annotation missing in pattern
return nums.reduce(0, ^(let acc, let num) { acc ^= num }) // '^' is not a prefix unary operator

func fizzBuzz(n: Int) -> Int {
    var count = 0
    for i in 1...n {
        if i % 11 == 0 || i % 13 == 0 {
            count += 1
        }
    }
    return count
}

func reverseString(s: String) -> String {
    return String(s.reversed())
}

func numberOf1Bits(n: Int) -> Int {
    var count = 0
    while n != 0 {
        count += 1
        n = n & (n - 1)
    }
    return count
}

func numberOf1Bits(n: UInt) -> Int {
    var count = 0
    while n != 0 {
        count += 1
        n = n & (n - 1)
    }
    return count
}

func numberOf7(n: Int) -> Int {
    var count = 0
    var num = n
    while num != 0 {
        if num % 10 == 7 {
            count += 1
        }
        num /= 10
    }
    return count
}

func numberOfDigits(n: Int) -> Int {
    var count = 0
    var num = n
    while num != 0 {
        count += 1
        num /= 10
    }
    return count
}
```swift
// Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.
// fizzBuzz(n: 50) == 0
// fizzBuzz(n: 78) == 2
// fizzBuzz(n: 79) == 3
func fizzBuzz(n: Int) -> Int {
    var count = 0
    for i in 1...n {
        if i % 11 == 0 || i % 13 == 0 {
            count += 1
        }
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 10. Write a function that takes a string as input and returns the string reversed.
// Example:
// Given s = "hello", return "olleh".
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 11. Write a function that takes an integer and returns the number of 1 bits it has.
// Example:
// Given input n = 00000000000000000000000000001011, return 3.
// Given input n = 00000000000000000000000010000000, return 1.
// Given input n = 11111111111111111111111111111101, return 31.
func numberOf1Bits(n: Int) -> Int {
    var count = 0
    while n != 0 {
        count += 1
        n = n & (n - 1)
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 12. Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).
// Example:
// The 32-bit integer ’11' has binary representation 00000000000000000000000000001011, so the function should return 3.
func numberOf1Bits(n: UInt) -> Int {
    var count = 0
    while n != 0 {
        count += 1
        n = n & (n - 1)
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 13. Write a function that takes an integer and returns the number of times the digit 7 appears in it.
// Example:
// For n = 717, the output should be 2;
// For n = 1234, the output should be 1.
// For n = 777777, the output should be 7.
func numberOf7(n: Int) -> Int {
    var count = 0
    var num = n
    while num != 0 {
        if num % 10 == 7 {
            count += 1
        }
        num /= 10
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 14. Write a function that takes an integer and returns the number of digits in it.
// Example:
// For n = 123, the output should be 3;
// For n = 52, the output should be 2.
func numberOfDigits(n: Int) -> Int {
    var count = 0
    var num = n
    while num != 0 {
        count += 1
        num /= 10
    }
    return count
}

// ---------
n = n & (n - 1) // cannot assign to value: 'n' is a 'let' constant
n = n & (n - 1) // cannot assign to value: 'n' is a 'let' constant

func fizzBuzz(n: Int) -> Int {
    var count = 0
    for i in 1...n {
        if i % 11 == 0 || i % 13 == 0 {
            count += 1
        }
    }
    return count
}

func fizzBuzz(s: String) -> String {
    return String(characters: s.reversed())
}
```swift
// Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.
// fizzBuzz(n: 50) == 0
// fizzBuzz(n: 78) == 2
// fizzBuzz(n: 79) == 3
func fizzBuzz(n: Int) -> Int {
    var count = 0
    for i in 1...n {
        if i % 11 == 0 || i % 13 == 0 {
            count += 1
        }
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 12. Write a function that takes a string and returns a new string with the first and last characters swapped.
// fizzBuzz("Hello") == "oHell"
// fizzBuzz("Goodbye") == "Goodbye"
func fizzBuzz(s: String) -> String {
    return String(characters: s.reversed())
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 13. Write a function that takes a string and returns a new string with the first and last characters swapped.
// fizzBuzz("Hello") == "oHell"
// fizzBuzz("Goodbye") == "Goodbye"
func fizzBuzz(s: String) -> String {
    return String(characters: s.reversed())
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 14. Write a function that takes a string and returns a new string with the first and last characters swapped.
// fizzBuzz("Hello") == "oHell"
// fizzBuzz("Goodbye") == "Goodbye"
func fizzBuzz(s: String) -> String {
    return String(characters: s.reversed())
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 15. Write a function that takes a string and returns a new string with the first and last characters swapped.
// fizzBuzz("Hello") == "oHell"
// fizzBuzz("Goodbye") == "Goodbye"
func fizzBuzz(s: String) -> String {
    return String(characters: s.reversed())
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 16. Write a function that takes a string and returns a new string with the first and last characters swapped.
// fizzBuzz("Hello") == "oHell"
// fizzBuzz("Goodbye") == "Goodbye"
func fizzBuzz(s: String) -> String {
    return String(characters: s.reversed())
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 17. Write a function that takes a string and returns a new string with the first and last characters swapped.
// fizzBuzz("Hello") == "oHell"
// fizzBuzz("Goodbye") == "Goodbye"
func fizzBuzz(s: String) -> String {
    return String(characters: s.reversed())
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 18. Write a function that takes a string and returns a new string with the first and last characters swapped.
// fizzBuzz("Hello") == "oHell"
// fizzBuzz("Goodbye") == "Goodbye"
func fizzBuzz(s: String) -> String {
    return String(characters: s.reversed())
}
return String(characters: s.reversed()) // no exact matches in call to initializer

func fizzBuzz(n: Int) -> Int {
    var count = 0
    for i in 1...n {
        if i % 11 == 0 || i % 13 == 0 {
            count += 1
        }
    }
    return count
}

func reverseOdd(str: String) -> String {
    var newStr = ""
    for i in 0..<str.count {
        if i % 2 == 1 {
            newStr += str[str.index(i)]
        }
    }
    return newStr.reversed().join()
}

func reverse(str: String) -> String {
    return str.reversed().join()
}

func capitalize(str: String) -> String {
    var newStr = ""
    for i in 0..<str.count {
        newStr += str[str.index(i)].uppercase
    }
    return newStr
}

func lowercase(str: String) -> String {
    var newStr = ""
    for i in 0..<str.count {
        newStr += str[str.index(i)].lowercase
    }
    return newStr
}

func swapCase(str: String) -> String {
    var newStr = ""
    for i in 0..<str.count {
        newStr += str[str.index(i)].lowercase
    }
    return newStr
}

func swapCase(str: String) -> String {
    var newStr = ""
    for i in 0..<str.count {
        newStr += str[str.index(i)].uppercase
    }
    return newStr
}
```swift
// Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.
// fizzBuzz(n: 50) == 0
// fizzBuzz(n: 78) == 2
// fizzBuzz(n: 79) == 3
func fizzBuzz(n: Int) -> Int {
    var count = 0
    for i in 1...n {
        if i % 11 == 0 || i % 13 == 0 {
            count += 1
        }
    }
    return count
}

// 2. Write a function that takes a string as an argument and returns a new string that contains the same characters as the original string but with the characters at odd indices reversed.
// reverseOdd("abcdef") == "aecdbf"
// reverseOdd("123456789") == "187532946"
func reverseOdd(str: String) -> String {
    var newStr = ""
    for i in 0..<str.count {
        if i % 2 == 1 {
            newStr += str[str.index(i)]
        }
    }
    return newStr.reversed().join()
}

// 3. Write a function that takes a string as an argument and returns a new string that contains the same characters as the original string but with the characters in reverse order.
// reverse("abcdef") == "fedcba"
// reverse("123456789") == "987654321"
func reverse(str: String) -> String {
    return str.reversed().join()
}

// 4. Write a function that takes a string as an argument and returns a new string that contains the same characters as the original string but with the characters in reverse order and with the first character replaced by its uppercase equivalent.
// capitalize("abcdef") == "ABCDEF"
// capitalize("123456789") == "987654321"
func capitalize(str: String) -> String {
    var newStr = ""
    for i in 0..<str.count {
        newStr += str[str.index(i)].uppercase
    }
    return newStr
}

// 5. Write a function that takes a string as an argument and returns a new string that contains the same characters as the original string but with the characters in reverse order and with the first character replaced by its lowercase equivalent.
// lowercase("ABCDEF") == "abcdef"
// lowercase("123456789") == "987654321"
func lowercase(str: String) -> String {
    var newStr = ""
    for i in 0..<str.count {
        newStr += str[str.index(i)].lowercase
    }
    return newStr
}

// 6. Write a function that takes a string as an argument and returns a new string that contains the same characters as the original string but with the characters in reverse order and with the first character replaced by its uppercase equivalent and the rest replaced by its lowercase equivalent.
// swapCase("abcdef") == "AbCdEf"
// swapCase("123456789") == "987654321"
func swapCase(str: String) -> String {
    var newStr = ""
    for i in 0..<str.count {
        newStr += str[str.index(i)].lowercase
    }
    return newStr
}

// 7. Write a function that takes a string as an argument and returns a new string that contains the same characters as the original string but with the characters in reverse order and with the first character replaced by its lowercase equivalent and the rest replaced by its uppercase equivalent.
// swapCase("abcdef") == "AbCdEf"
// swapCase("123456789") == "987654321"
func swapCase(str: String) -> String {
    var newStr = ""
    for i in 0..<str.count {
        newStr += str[str.index(i)].uppercase
    }
    return newStr
}

// 8. Write a function that takes a string as an argument and returns a new string that contains the same characters as the original string but with the characters in reverse order and with the first character replaced by its lowercase equivalent and the rest replaced by its uppercase equivalent and the first character replaced
newStr += str[str.index(i)] // subscript 'subscript(_:)' requires that 'String.Index' conform to 'RangeExpression'
newStr += str[str.index(i)] // no exact matches in call to instance method 'index'
return newStr.reversed().join() // reference to member 'join' cannot be resolved without a contextual type
return str.reversed().join() // reference to member 'join' cannot be resolved without a contextual type
newStr += str[str.index(i)].uppercase // no exact matches in call to instance method 'index'
newStr += str[str.index(i)].uppercase // value of type 'Character' has no member 'uppercase'
newStr += str[str.index(i)].lowercase // no exact matches in call to instance method 'index'
newStr += str[str.index(i)].lowercase // value of type 'Character' has no member 'lowercase'
newStr += str[str.index(i)].lowercase // no exact matches in call to instance method 'index'
newStr += str[str.index(i)].lowercase // value of type 'Character' has no member 'lowercase'
func swapCase(str: String) -> String { // invalid redeclaration of 'swapCase(str:)'
newStr += str[str.index(i)].uppercase // no exact matches in call to instance method 'index'
newStr += str[str.index(i)].uppercase // value of type 'Character' has no member 'uppercase'

func fizzBuzz(n: Int) -> Int {
    var count = 0
    for i in 1...n {
        if i % 11 == 0 || i % 13 == 0 {
            count += 1
        }
    }
    return count
}

func countOnes(n: Int) -> Int {
    var count = 0
    while n > 0 {
        if n & 1 == 1 {
            count += 1
        }
        n >>= 1
    }
    return count
}

func hammingWeight(n: Int) -> Int {
    var count = 0
    while n > 0 {
        if n & 1 == 1 {
            count += 1
        }
        n >>= 1
    }
    return count
}
```swift
// Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.
// fizzBuzz(n: 50) == 0
// fizzBuzz(n: 78) == 2
// fizzBuzz(n: 79) == 3
func fizzBuzz(n: Int) -> Int {
    var count = 0
    for i in 1...n {
        if i % 11 == 0 || i % 13 == 0 {
            count += 1
        }
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 10. Write a function that takes a string as input and returns the string reversed.
// Example:
// Given s = "hello", return "olleh".

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 11. Write a function that takes an integer and returns the number of 5's that appear in its binary representation.
// Example:
// countOnes(10) == 1
// countOnes(12) == 2
// countOnes(25) == 2
func countOnes(n: Int) -> Int {
    var count = 0
    while n > 0 {
        if n & 1 == 1 {
            count += 1
        }
        n >>= 1
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 12. Write a function that takes an integer and returns the number of 1 bits it has.
// Example:
// hammingWeight(11) == 3
// hammingWeight(128) == 1
// hammingWeight(4294967293) == 31
func hammingWeight(n: Int) -> Int {
    var count = 0
    while n > 0 {
        if n & 1 == 1 {
            count += 1
        }
        n >>= 1
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 13. Write a function that takes an integer and returns the number of 1 bits it has.
// Example:
// hammingWeight(11) == 3
// hammingWeight(128) == 1
// hammingWeight(4294967293) == 31
func hammingWeight(n: Int) -> Int {
    var count = 0
    while n > 0 {
        if n & 1 == 1 {
            count += 1
        }
        n >>= 1
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 14. Write a function that takes an integer and returns the number of 1 bits it has.
// Example:
// hammingWeight(11) == 3
// hammingWeight(128) == 1
// hammingWeight(4294967293) == 31
func hammingWeight(n: Int) -> Int {
    var count = 0
    while n > 0 {
        if n & 1 == 1 {
            count += 1
        }
        n >>= 1
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------
// MARK: - 15. Write a function that takes an integer and returns the number of 1 bits it has.
// Example:
// hammingWeight(11) == 3
// hammingWeight(128) == 1
// hammingWeight(4294967293) == 31
func hammingWeight(n: Int) -> Int {
    var
n >>= 1 // left side of mutating operator isn't mutable: 'n' is a 'let' constant
n >>= 1 // left side of mutating operator isn't mutable: 'n' is a 'let' constant

func fizzBuzz(n: Int) -> Int {
    var count = 0
    for i in 1..<n {
        if i % 11 == 0 || i % 13 == 0 {
            count += 1
        }
    }
    return count
}

func findOdd(A: [Int]) -> Int {
    var dict = [Int: Int]()
    for i in A {
        if dict[i] == nil {
            dict[i] = 1
        } else {
            dict[i] += 1
        }
    }
    for (key, value) in dict {
        if value % 2 != 0 {
            return key
        }
    }
    return 0
}

func doubleChar(text: String) -> String {
    var result = ""
    for i in text {
        result += String(i) + String(i)
    }
    return result
}
```swift
// Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.
// fizzBuzz(n: 50) == 0
// fizzBuzz(n: 78) == 2
// fizzBuzz(n: 79) == 3
func fizzBuzz(n: Int) -> Int {
    var count = 0
    for i in 1..<n {
        if i % 11 == 0 || i % 13 == 0 {
            count += 1
        }
    }
    return count
}

// 2.
// Given an array of integers, find the one that appears an odd number of times.
//
// There will always be only one integer that appears an odd number of times.
//
// Examples
// [7] should return 7, because it occurs 1 time (which is odd).
// [0] should return 0, because it occurs 1 time (which is odd).
// [1,1,2] should return 2, because it occurs 1 time (which is odd).
// [0,1,0,1,0] should return 0, because it occurs 3 times (which is odd).
// [1,2,2,3,3,3,4,3,3,3,2,2,1] should return 4, because it appears 1 time (which is odd).
func findOdd(A: [Int]) -> Int {
    var dict = [Int: Int]()
    for i in A {
        if dict[i] == nil {
            dict[i] = 1
        } else {
            dict[i] += 1
        }
    }
    for (key, value) in dict {
        if value % 2 != 0 {
            return key
        }
    }
    return 0
}

// 3.
// Given a string, you have to return a string in which each character (case-sensitive) is repeated once.
//
// Examples (Input -> Output):
// * "String"      -> "SSttrriinngg"
// * "Hello World" -> "HHeelllloo  WWoorrlldd"
// * "1234!_ "     -> "11223344!!__  "
// Good Luck!
func doubleChar(text: String) -> String {
    var result = ""
    for i in text {
        result += String(i) + String(i)
    }
    return result
}

// 4.
// Given a string, you have to return a string in which each character (case-sensitive) is repeated once.
//
// Examples (Input -> Output):
// * "String"      -> "SSttrriinngg"
// * "Hello World" -> "HHeelllloo  WWoorrlldd"
// * "1234!_ "     -> "11223344!!__  "
// Good Luck!
func doubleChar(text: String) -> String {
    var result = ""
    for i in text {
        result += String(i) + String(i)
    }
    return result
}

// 5.
// Given a string, you have to return a string in which each character (case-sensitive) is repeated once.
//
// Examples (Input -> Output):
// * "String"      -> "SSttrriinngg"
// * "Hello World" -> "HHeelllloo  WWoorrlldd"
// * "1234!_ "     -> "11223344!!__  "
// Good Luck!
func doubleChar(text: String) -> String {
    var result = ""
    for i in text {
        result += String(i) + String(i)
    }
    return result
}

// 6.
// Given a string, you have to return a string in which each character (case-sensitive) is repeated once.
//
// Examples (Input -> Output):
// * "String"      -> "SSttrriinngg"
// * "Hello World" -> "HHeelllloo  WWoorrlldd"
// * "1234!_ "     -> "11223344!!__  "
// Good Luck!
func doubleChar(text: String) -> String {
    var result = ""
    for i in text {
        result += String(i) + String(i)
    }
    return result
}

// 7.
// Given a string, you have to return a string in which each character (
dict[i] += 1 // value of optional type 'Int?' must be unwrapped to a value of type 'Int'

func fizzBuzz(n: Int) -> Int {
    var count = 0
    for i in 1...n {
        if i % 11 == 0 || i % 13 == 0 {
            count += 1
        }
    }
    return count
}

func doubleArrayValues(inputArray: [Int]) -> [Int] {
    return inputArray.map { $0 * 2 }
}

func mapArray(inputArray: [Int]) -> [Int] {
    return inputArray.map { $0 + 1 }
}
```swift
// Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.
// fizzBuzz(n: 50) == 0
// fizzBuzz(n: 78) == 2
// fizzBuzz(n: 79) == 3
func fizzBuzz(n: Int) -> Int {
    var count = 0
    for i in 1...n {
        if i % 11 == 0 || i % 13 == 0 {
            count += 1
        }
    }
    return count
}

// 2. Given an array of integers, return a new array with each value doubled.
// For example:
// [1, 2, 3] --> [2, 4, 6]
func doubleArrayValues(inputArray: [Int]) -> [Int] {
    return inputArray.map { $0 * 2 }
}

// 3. Given an array of integers, return a new array with each value doubled.
// For example:
// [1, 2, 3] --> [2, 4, 6]
func mapArray(inputArray: [Int]) -> [Int] {
    return inputArray.map { $0 + 1 }
}

// 4. Given an array of integers, return a new array with each value doubled.
// For example:
// [1, 2, 3] --> [2, 4, 6]
func mapArray(inputArray: [Int]) -> [Int] {
    return inputArray.map { $0 + 1 }
}

// 5. Given an array of integers, return a new array with each value doubled.
// For example:
// [1, 2, 3] --> [2, 4, 6]
func mapArray(inputArray: [Int]) -> [Int] {
    return inputArray.map { $0 + 1 }
}

// 6. Given an array of integers, return a new array with each value doubled.
// For example:
// [1, 2, 3] --> [2, 4, 6]
func mapArray(inputArray: [Int]) -> [Int] {
    return inputArray.map { $0 + 1 }
}

// 7. Given an array of integers, return a new array with each value doubled.
// For example:
// [1, 2, 3] --> [2, 4, 6]
func mapArray(inputArray: [Int]) -> [Int] {
    return inputArray.map { $0 + 1 }
}

// 8. Given an array of integers, return a new array with each value doubled.
// For example:
// [1, 2, 3] --> [2, 4, 6]
func mapArray(inputArray: [Int]) -> [Int] {
    return inputArray.map { $0 + 1 }
}

// 9. Given an array of integers, return a new array with each value doubled.
// For example:
// [1, 2, 3] --> [2, 4, 6]
func mapArray(inputArray: [Int]) -> [Int] {
    return inputArray.map { $0 + 1 }
}

// 10. Given an array of integers, return a new array with each value doubled.
// For example:
// [1, 2, 3] --> [2, 4, 6]
func mapArray(inputArray: [Int]) -> [Int] {
    return inputArray.map { $0 + 1 }
}

// 11. Given an array of integers, return a new array with each value doubled.
// For example:
// [1, 2, 3] --> [2, 4, 6]
func mapArray(inputArray: [Int]) -> [Int] {
    return inputArray.map { $0 + 1 }
}

// 12. Given an array of integers, return a new array with each value doubled.
// For example:
// [1, 2, 3] --> [2, 4, 6]
func mapArray(inputArray: [Int]) -> [Int] {
    return inputArray.map { $0 + 1 }
}

// 13. Given an array of integers, return a new array with each value doubled.
// For example:
// [1, 2, 3] --> [2, 4, 6]
func mapArray(inputArray: [Int]) -> [Int] {
    return inputArray.map { $0 + 1 }
}
 // XCTAssertTrue failed

func fizzBuzz(n: Int) -> Int {
    var count = 0
    for i in 1..<n {
        if i % 11 == 0 || i % 13 == 0 {
            count += 1
        }
    }
    return count
}
```swift
// Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.
// fizzBuzz(n: 50) == 0
// fizzBuzz(n: 78) == 2
// fizzBuzz(n: 79) == 3
func fizzBuzz(n: Int) -> Int {
    var count = 0
    for i in 1..<n {
        if i % 11 == 0 || i % 13 == 0 {
            count += 1
        }
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------

// 10. Write a function that takes a string as input and returns the number of vowels in the string.
// vowels("apple") == 2
// vowels("banana") == 3
// vowels("grapefruit") == 5
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") == 3
// vowels("kiwi") ==
 // XCTAssertTrue failed

func fizzBuzz(n: Int) -> Int {
    var count = 0
    for i in 1...n {
        if i % 11 == 0 || i % 13 == 0 {
            count += 1
        }
    }
    return count
}
```swift
// Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.
// fizzBuzz(n: 50) == 0
// fizzBuzz(n: 78) == 2
// fizzBuzz(n: 79) == 3
func fizzBuzz(n: Int) -> Int {
    var count = 0
    for i in 1...n {
        if i % 11 == 0 || i % 13 == 0 {
            count += 1
        }
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------------------------
 // XCTAssertTrue failed

func sortEven(l: [Int]) -> [Int] {
    var l' = l
    for i in 1..<l.count {
        if i % 2 == 0 {
            l'[i] = l[i]
        } else {
            l'[i] = l[i-1]
        }
    }
    return l'
}
```swift
// This function takes an array l and returns an array l' such that
// l' is identical to l in the odd indicies, while its values at the even indicies are equal
// to the values of the even indicies of l, but sorted.
// sortEven(l: [1, 2, 3]) == [1, 2, 3]
// sortEven(l: [5, 6, 3, 4]) == [3, 6, 5, 4]
func sortEven(l: [Int]) -> [Int] {
    var l' = l
    for i in 1..<l.count {
        if i % 2 == 0 {
            l'[i] = l[i]
        } else {
            l'[i] = l[i-1]
        }
    }
    return l'
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ------------------------------------------------------------
var l' = l // type annotation missing in pattern
var l' = l // unterminated string literal
l'[i] = l[i] // unterminated string literal
l'[i] = l[i-1] // unterminated string literal
return l' // unterminated string literal

func sortEven(l: [Int]) -> [Int] {
    var l' = l
    for i in 0..<l.count {
        if i % 2 == 0 {
            l'.sort()
        }
    }
    return l'
}
```swift
// This function takes an array l and returns an array l' such that
// l' is identical to l in the odd indicies, while its values at the even indicies are equal
// to the values of the even indicies of l, but sorted.
// sortEven(l: [1, 2, 3]) == [1, 2, 3]
// sortEven(l: [5, 6, 3, 4]) == [3, 6, 5, 4]
func sortEven(l: [Int]) -> [Int] {
    var l' = l
    for i in 0..<l.count {
        if i % 2 == 0 {
            l'.sort()
        }
    }
    return l'
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 
var l' = l // unterminated string literal
var l' = l // type annotation missing in pattern
l'.sort() // unterminated string literal
return l' // unterminated string literal

func sortEven(l: [Int]) -> [Int] {
    var l' = l
    for i in 0..<l.count {
        if i % 2 == 0 {
            l'[i] = l[i]
        } else {
            l'[i] = l[i / 2]
        }
    }
    return l'
}
```swift
// This function takes an array l and returns an array l' such that
// l' is identical to l in the odd indicies, while its values at the even indicies are equal
// to the values of the even indicies of l, but sorted.
// sortEven(l: [1, 2, 3]) == [1, 2, 3]
// sortEven(l: [5, 6, 3, 4]) == [3, 6, 5, 4]
func sortEven(l: [Int]) -> [Int] {
    var l' = l
    for i in 0..<l.count {
        if i % 2 == 0 {
            l'[i] = l[i]
        } else {
            l'[i] = l[i / 2]
        }
    }
    return l'
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------------------
var l' = l // type annotation missing in pattern
var l' = l // unterminated string literal
l'[i] = l[i] // unterminated string literal
l'[i] = l[i / 2] // unterminated string literal
return l' // unterminated string literal

func sortEven(l: [Int]) -> [Int] {
    var result = [Int]()
    for i in 0..<l.count {
        if i % 2 == 0 {
            result.append(l[i])
        } else {
            result.append(l[i - 1])
        }
    }
    return result
}
```swift
// This function takes an array l and returns an array l' such that
// l' is identical to l in the odd indicies, while its values at the even indicies are equal
// to the values of the even indicies of l, but sorted.
// sortEven(l: [1, 2, 3]) == [1, 2, 3]
// sortEven(l: [5, 6, 3, 4]) == [3, 6, 5, 4]
func sortEven(l: [Int]) -> [Int] {
    var result = [Int]()
    for i in 0..<l.count {
        if i % 2 == 0 {
            result.append(l[i])
        } else {
            result.append(l[i - 1])
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// 1. Write a function that takes a string and returns the number of vowels in the string.
//    You may assume the string will always be in all lower case.
//    You can assume the string will always be a valid string.
//    vowelCount("apple") == 2
//    vowelCount("cheese") == 4
//    vowelCount("sillystring") == 4
//    vowelCount("12345") == 0
//    vowelCount("") == 0
//    vowelCount("aeiou") == 5
//    vowelCount("aeiouaeiou") == 10
//    vowelCount("aeiouaeiouaeiouaeiou") == 20
//    vowelCount("aeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouae
 // XCTAssertTrue failed

func sortEven(l: [Int]) -> [Int] {
    var l' = l
    for i in 1..<l.count {
        if i % 2 == 0 {
            l'[i] = l[i/2]
        }
    }
    for i in 1..<l.count {
        if i % 2 == 1 {
            for j in 1..<i {
                if l[j] > l[i] {
                    l[j], l[i] = l[i], l[j]
                }
            }
        }
    }
    return l'
}
```swift
// This function takes an array l and returns an array l' such that
// l' is identical to l in the odd indicies, while its values at the even indicies are equal
// to the values of the even indicies of l, but sorted.
// sortEven(l: [1, 2, 3]) == [1, 2, 3]
// sortEven(l: [5, 6, 3, 4]) == [3, 6, 5, 4]
func sortEven(l: [Int]) -> [Int] {
    var l' = l
    for i in 1..<l.count {
        if i % 2 == 0 {
            l'[i] = l[i/2]
        }
    }
    for i in 1..<l.count {
        if i % 2 == 1 {
            for j in 1..<i {
                if l[j] > l[i] {
                    l[j], l[i] = l[i], l[j]
                }
            }
        }
    }
    return l'
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
var l' = l // type annotation missing in pattern
var l' = l // unterminated string literal
l'[i] = l[i/2] // unterminated string literal
l[j], l[i] = l[i], l[j] // expected expression
l[j], l[i] = l[i], l[j] // consecutive statements on a line must be separated by ';'
return l' // unterminated string literal

func sortEven(l: [Int]) -> [Int] {
    var l' = l
    for i in 1..<l.count {
        if i % 2 == 0 {
            l'.insert(l[i], at: i)
        }
    }
    return l'
}
```swift
// This function takes an array l and returns an array l' such that
// l' is identical to l in the odd indicies, while its values at the even indicies are equal
// to the values of the even indicies of l, but sorted.
// sortEven(l: [1, 2, 3]) == [1, 2, 3]
// sortEven(l: [5, 6, 3, 4]) == [3, 6, 5, 4]
func sortEven(l: [Int]) -> [Int] {
    var l' = l
    for i in 1..<l.count {
        if i % 2 == 0 {
            l'.insert(l[i], at: i)
        }
    }
    return l'
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------------------------------------------------------------------
var l' = l // unterminated string literal
var l' = l // type annotation missing in pattern
l'.insert(l[i], at: i) // unterminated string literal
return l' // unterminated string literal

func sortEven(l: [Int]) -> [Int] {
    var l' = l
    for i in 1..<l.count {
        if i % 2 == 0 {
            l'[i] = l[i]
        }
    }
    for i in 0..<l.count {
        if i % 2 == 1 {
            l'.sort()
        }
    }
    return l'
}

func sumEven(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        if i % 2 == 0 {
            sum += l[i]
        }
    }
    return sum
}

func sumOdd(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        if i % 2 == 1 {
            sum += l[i]
        }
    }
    return sum
}
```swift
// This function takes an array l and returns an array l' such that
// l' is identical to l in the odd indicies, while its values at the even indicies are equal
// to the values of the even indicies of l, but sorted.
// sortEven(l: [1, 2, 3]) == [1, 2, 3]
// sortEven(l: [5, 6, 3, 4]) == [3, 6, 5, 4]
func sortEven(l: [Int]) -> [Int] {
    var l' = l
    for i in 1..<l.count {
        if i % 2 == 0 {
            l'[i] = l[i]
        }
    }
    for i in 0..<l.count {
        if i % 2 == 1 {
            l'.sort()
        }
    }
    return l'
}

// ----------------------------------------------------------------------------------------------------------------------

// Given an array l, return the sum of the elements at the even indicies.
// sumEven([1, 2, 3]) == 2
// sumEven([5, 6, 3, 4]) == 10
func sumEven(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        if i % 2 == 0 {
            sum += l[i]
        }
    }
    return sum
}

// ----------------------------------------------------------------------------------------------------------------------

// Given an array l, return the sum of the elements at the odd indicies.
// sumOdd([1, 2, 3]) == 3
// sumOdd([5, 6, 3, 4]) == 12
func sumOdd(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        if i % 2 == 1 {
            sum += l[i]
        }
    }
    return sum
}

// ----------------------------------------------------------------------------------------------------------------------

// Given an array l, return the sum of the elements at the even indicies.
// sumEven([1, 2, 3]) == 2
// sumEven([5, 6, 3, 4]) == 10
func sumEven(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        if i % 2 == 0 {
            sum += l[i]
        }
    }
    return sum
}

// ----------------------------------------------------------------------------------------------------------------------

// Given an array l, return the sum of the elements at the odd indicies.
// sumOdd([1, 2, 3]) == 3
// sumOdd([5, 6, 3, 4]) == 12
func sumOdd(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        if i % 2 == 1 {
            sum += l[i]
        }
    }
    return sum
}

// ----------------------------------------------------------------------------------------------------------------------

// Given an array l, return the sum of the elements at the even indicies.
// sumEven([1, 2, 3]) == 2
// sumEven([5, 6, 3, 4]) == 10
func sumEven(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        if i % 2 == 0 {
            sum += l[i]
        }
    }
    return sum
}

// ----------------------------------------------------------------------------------------------------------------------

// Given an array l, return the sum of the elements at the odd indicies.
// sumOdd([1, 2, 3]) == 3
// sumOdd([5, 6, 3, 4])
var l' = l // type annotation missing in pattern
var l' = l // unterminated string literal
l'[i] = l[i] // unterminated string literal
l'.sort() // unterminated string literal
return l' // unterminated string literal

func sortEven(l: [Int]) -> [Int] {
    var l' = l
    for i in 0..<l.count {
        if i % 2 == 0 {
            l'[i] = l[i]
        } else {
            l'[i] = l[i / 2]
        }
    }
    return l'
}

func vowels(s: String) -> Int {
    var count = 0
    for c in s {
        if c == "a" || c == "e" || c == "i" || c == "o" || c == "u" {
            count += 1
        }
    }
    return count
}

func removeVowels(s: String) -> String {
    var s' = ""
    for c in s {
        if c != "a" && c != "e" && c != "i" && c != "o" && c != "u" {
            s' += c
        }
    }
    return s'
}

func isPalindrome(s: String) -> Bool {
    var s' = ""
    for c in s {
        s' = c + s'
    }
    return s == s'
}
```swift
// This function takes an array l and returns an array l' such that
// l' is identical to l in the odd indicies, while its values at the even indicies are equal
// to the values of the even indicies of l, but sorted.
// sortEven(l: [1, 2, 3]) == [1, 2, 3]
// sortEven(l: [5, 6, 3, 4]) == [3, 6, 5, 4]
func sortEven(l: [Int]) -> [Int] {
    var l' = l
    for i in 0..<l.count {
        if i % 2 == 0 {
            l'[i] = l[i]
        } else {
            l'[i] = l[i / 2]
        }
    }
    return l'
}

// ----------------------------------------------------------------------------------------------------------------------

// 1. Write a function that takes a string and returns the number of vowels in the string.
//    You may assume the string will contain only lowercase letters.
//    vowels("apple") == 2
//    vowels("cheese") == 4
//    vowels("sillystring") == 5
func vowels(s: String) -> Int {
    var count = 0
    for c in s {
        if c == "a" || c == "e" || c == "i" || c == "o" || c == "u" {
            count += 1
        }
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------

// 2. Write a function that takes a string and returns a new string with all the vowels removed.
//    You may assume the string will contain only lowercase letters.
//    removeVowels("apple") == "ppl"
//    removeVowels("cheese") == "chs"
//    removeVowels("sillystring") == "slystrng"
func removeVowels(s: String) -> String {
    var s' = ""
    for c in s {
        if c != "a" && c != "e" && c != "i" && c != "o" && c != "u" {
            s' += c
        }
    }
    return s'
}

// ----------------------------------------------------------------------------------------------------------------------

// 3. Write a function that takes a string and returns true if the string is a palindrome, false otherwise.
//    You may assume the string will contain only lowercase letters.
//    isPalindrome("abba") == true
//    isPalindrome("racecar") == true
//    isPalindrome("hello") == false
func isPalindrome(s: String) -> Bool {
    var s' = ""
    for c in s {
        s' = c + s'
    }
    return s == s'
}

// ----------------------------------------------------------------------------------------------------------------------

// 4. Write a function that takes a string and returns a new string with all the vowels removed.
//    You may assume the string will contain only lowercase letters.
//    removeVowels("apple") == "ppl"
//    removeVowels("cheese") == "chs"
//    removeVowels("sillystring") == "slystrng"
func removeVowels(s: String) -> String {
    var s' = ""
    for c in s {
        if c != "a" && c != "e" && c != "i" && c != "o" && c != "u" {
            s' += c
        }
    }
    return s'
}

// ----------------------------------------------------------------------------------------------------------------------

// 5. Write a function that takes a string and returns true if the string is a palindrome, false otherwise.
//    You may assume the string will contain only lowercase letters.
//    isPalindrome("abba")
var l' = l // type annotation missing in pattern
var l' = l // unterminated string literal
l'[i] = l[i] // unterminated string literal
l'[i] = l[i / 2] // unterminated string literal
return l' // unterminated string literal
var s' = "" // type annotation missing in pattern
var s' = "" // unterminated string literal
s' += c // unterminated string literal
return s' // unterminated string literal
var s' = "" // unterminated string literal
var s' = "" // type annotation missing in pattern
s' = c + s' // single-quoted string literal found, use '"'
s' = c + s' // consecutive statements on a line must be separated by ';'
return s == s' // unterminated string literal

func sortEven(l: [Int]) -> [Int] {
    var l2 = l
    for i in 0..<l.count {
        if i % 2 == 0 {
            l2[i] = l[i]
        } else {
            l2[i] = l[i/2]
        }
    }
    l2.sort()
    return l2
}
```swift
// This function takes an array l and returns an array l' such that
// l' is identical to l in the odd indicies, while its values at the even indicies are equal
// to the values of the even indicies of l, but sorted.
// sortEven(l: [1, 2, 3]) == [1, 2, 3]
// sortEven(l: [5, 6, 3, 4]) == [3, 6, 5, 4]
func sortEven(l: [Int]) -> [Int] {
    var l2 = l
    for i in 0..<l.count {
        if i % 2 == 0 {
            l2[i] = l[i]
        } else {
            l2[i] = l[i/2]
        }
    }
    l2.sort()
    return l2
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // XCTAssertTrue failed

func sortEven(l: [Int]) -> [Int] {
    var result = l
    for i in 1..<l.count {
        if i % 2 == 0 {
            result[i] = l[i/2]
        }
    }
    for i in 1..<l.count {
        if i % 2 == 1 {
            result[i] = l[i/2]
        }
    }
    return result
}
```swift
// This function takes an array l and returns an array l' such that
// l' is identical to l in the odd indicies, while its values at the even indicies are equal
// to the values of the even indicies of l, but sorted.
// sortEven(l: [1, 2, 3]) == [1, 2, 3]
// sortEven(l: [5, 6, 3, 4]) == [3, 6, 5, 4]
func sortEven(l: [Int]) -> [Int] {
    var result = l
    for i in 1..<l.count {
        if i % 2 == 0 {
            result[i] = l[i/2]
        }
    }
    for i in 1..<l.count {
        if i % 2 == 1 {
            result[i] = l[i/2]
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ---------------------------------
 // XCTAssertTrue failed

func primeFib(n: Int) -> Int {
    var fib = [Int]()
    var prime = [Int]()
    var i = 0
    var j = 0
    var k = 0
    var l = 0
    var m = 0
    var n = 0
    var o = 0
    var p = 0
    var q = 0
    var r = 0
    var s = 0
    var t = 0
    var u = 0
    var v = 0
    var w = 0
    var x = 0
    var y = 0
    var z = 0
    while fib.count < n {
        fib.append(i)
        i = j + k
        j = k
        k = i
    }
    while prime.count < n {
        if fib[l] % 2 == 0 {
            prime.append(fib[l])
        }
        l++
    }
    return prime[n - 1]
}
```swift
// prime_fib returns n-th number that is a Fibonacci number and it's also prime.
// primeFib(n: 1) == 2
// primeFib(n: 2) == 3
// primeFib(n: 3) == 5
// primeFib(n: 4) == 13
// primeFib(n: 5) == 89
func primeFib(n: Int) -> Int {
    var fib = [Int]()
    var prime = [Int]()
    var i = 0
    var j = 0
    var k = 0
    var l = 0
    var m = 0
    var n = 0
    var o = 0
    var p = 0
    var q = 0
    var r = 0
    var s = 0
    var t = 0
    var u = 0
    var v = 0
    var w = 0
    var x = 0
    var y = 0
    var z = 0
    while fib.count < n {
        fib.append(i)
        i = j + k
        j = k
        k = i
    }
    while prime.count < n {
        if fib[l] % 2 == 0 {
            prime.append(fib[l])
        }
        l++
    }
    return prime[n - 1]
}

print(primeFib(1))
print(primeFib(2))
print(primeFib(3))
print(primeFib(4))
print(primeFib(5))
print(primeFib(6))
print(primeFib(7))
print(primeFib(8))
print(primeFib(9))
print(primeFib(10))
print(primeFib(11))
print(primeFib(12))
print(primeFib(13))
print(primeFib(14))
print(primeFib(15))
print(primeFib(16))
print(primeFib(17))
print(primeFib(18))
print(primeFib(19))
print(primeFib(20))
print(primeFib(21))
print(primeFib(22))
print(primeFib(23))
print(primeFib(24))
print(primeFib(25))
print(primeFib(26))
print(primeFib(27))
print(primeFib(28))
print(primeFib(29))
print(primeFib(30))
print(primeFib(31))
print(primeFib(32))
print(primeFib(33))
print(primeFib(34))
print(primeFib(35))
print(primeFib(36))
print(primeFib(37))
print(primeFib(38))
print(primeFib(39))
print(primeFib(40))
print(primeFib(41))
print(primeFib(42))
print(primeFib(43))
print(primeFib(44))
print(primeFib(45))
print(primeFib(46))
print(primeFib(47))
print(primeFib(48))
print(primeFib(49))
print(primeFib(50))
print(primeFib(51))
print(primeFib(52))
print(primeFib(53))
print(primeFib(54))
print(primeFib(55))
print(primeFib(56))
print(primeFib(57))
print(primeFib(58))
print(primeFib(59))
print(primeFib(60))
print(primeFib(61))
print(primeFib(62))
print(primeFib(63))
print(primeFib(64))
print(primeFib(65))
print(primeFib(66))
print(primeFib(67))
print(primeFib(68))
print(primeFib(69))
print(primeFib(70))
print(primeFib(71))
print(primeFib(72))
print(primeFib(73))
print(primeFib(74))
print(primeFib(75))
print(primeFib(76))
print(primeFib(77))
print(primeFib(78))
print(primeFib(79))
print(primeFib
l++ // cannot find operator '++' in scope; did you mean '+= 1'?

func primeFib(n: Int) -> Int {
    var fib = [1, 1]
    var i = 2
    while fib[i - 1] + fib[i - 2] < n {
        fib.append(fib[i - 1] + fib[i - 2])
        i += 1
    }
    var j = 0
    while fib[j] < n {
        if isPrime(fib[j]) {
            return fib[j]
        }
        j += 1
    }
    return fib[j - 1]
}
```swift
// prime_fib returns n-th number that is a Fibonacci number and it's also prime.
// primeFib(n: 1) == 2
// primeFib(n: 2) == 3
// primeFib(n: 3) == 5
// primeFib(n: 4) == 13
// primeFib(n: 5) == 89
func primeFib(n: Int) -> Int {
    var fib = [1, 1]
    var i = 2
    while fib[i - 1] + fib[i - 2] < n {
        fib.append(fib[i - 1] + fib[i - 2])
        i += 1
    }
    var j = 0
    while fib[j] < n {
        if isPrime(fib[j]) {
            return fib[j]
        }
        j += 1
    }
    return fib[j - 1]
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// ---------------------------------------------------------------
if isPrime(fib[j]) { // cannot find 'isPrime' in scope

func primeFib(n: Int) -> Int {
    var a = 1
    var b = 1
    var c = 1
    while n > 0 {
        c = a + b
        if isPrime(c) {
            a = b
            b = c
        } else {
            a = b
            b = c
        }
        n -= 1
    }
    return c
}
```swift
// prime_fib returns n-th number that is a Fibonacci number and it's also prime.
// primeFib(n: 1) == 2
// primeFib(n: 2) == 3
// primeFib(n: 3) == 5
// primeFib(n: 4) == 13
// primeFib(n: 5) == 89
func primeFib(n: Int) -> Int {
    var a = 1
    var b = 1
    var c = 1
    while n > 0 {
        c = a + b
        if isPrime(c) {
            a = b
            b = c
        } else {
            a = b
            b = c
        }
        n -= 1
    }
    return c
}

// -----------------------------------------------------------------------------
// MARK: - Tests

// -----------------------------------------------------------------------------
// MARK: - Helpers

// -----------------------------------------------------------------------------
// MARK: - Tests

// -----------------------------------------------------------------------------
// MARK: - Helpers

// -----------------------------------------------------------------------------
// MARK: - Tests

// -----------------------------------------------------------------------------
// MARK: - Helpers

// -----------------------------------------------------------------------------
// MARK: - Tests

// -----------------------------------------------------------------------------
// MARK: - Helpers

// -----------------------------------------------------------------------------
// MARK: - Tests

// -----------------------------------------------------------------------------
// MARK: - Helpers

// -----------------------------------------------------------------------------
// MARK: - Tests

// -----------------------------------------------------------------------------
// MARK: - Helpers

// -----------------------------------------------------------------------------
// MARK: - Tests

// -----------------------------------------------------------------------------
// MARK: - Helpers

// -----------------------------------------------------------------------------
// MARK: - Tests

// -----------------------------------------------------------------------------
// MARK: - Helpers

// -----------------------------------------------------------------------------
// MARK: - Tests

// -----------------------------------------------------------------------------
// MARK: - Helpers

// -----------------------------------------------------------------------------
// MARK: - Tests

// -----------------------------------------------------------------------------
// MARK: - Helpers

// -----------------------------------------------------------------------------
// MARK: - Tests

// -----------------------------------------------------------------------------
// MARK: - Helpers

// -----------------------------------------------------------------------------
// MARK: - Tests

// -----------------------------------------------------------------------------
// MARK: - Helpers

// -----------------------------------------------------------------------------
// MARK:
if isPrime(c) { // cannot find 'isPrime' in scope
n -= 1 // left side of mutating operator isn't mutable: 'n' is a 'let' constant

func primeFib(n: Int) -> Int {
    var fib = [0, 1]
    var i = 2
    while fib[i - 1] + fib[i - 2] < n {
        fib.append(fib[i - 1] + fib[i - 2])
        i += 1
    }
    return fib[i]
}

import Foundation
```swift
// prime_fib returns n-th number that is a Fibonacci number and it's also prime.
// primeFib(n: 1) == 2
// primeFib(n: 2) == 3
// primeFib(n: 3) == 5
// primeFib(n: 4) == 13
// primeFib(n: 5) == 89
func primeFib(n: Int) -> Int {
    var fib = [0, 1]
    var i = 2
    while fib[i - 1] + fib[i - 2] < n {
        fib.append(fib[i - 1] + fib[i - 2])
        i += 1
    }
    return fib[i]
}

print(primeFib(1000))<|endoftext|>//
//  main.swift
//  1480
//
//  Created by 윤승현 on 2021/09/22.
//

import Foundation

// 1480. Running Sum of 1d Array
// https://leetcode.com/problems/running-sum-of-1d-array/

// 배열의 각 요소는 앞에서부터 1씩 증가하는 숫자로 이루어져 있다.
// 배열의 요소를 순회하면서 앞에서부터 증가하는 숫자의 합을 구하는 프로그램을 작성하라.

// 예제 1
// Input: nums = [1,2,3,4]
// Output: [1,3,6,10]
// Explanation: Running sum is obtained as follows: [1, 1+2, 1+2+3, 1+2+3+4].

// 예제 2
// Input: nums = [1,1,1,1,1]
// Output: [1,2,3,4,5]
// Explanation: Running sum is obtained as follows: [1, 1+1, 1+1+1, 1+1+1+1, 1+1+1+1+1].

// 예제 3
// Input: nums = [3,1,2,10,1]
// Output: [3,4,6,16,17]

// 제한사항
// 1 <= nums.length <= 1000
// -10^6 <= nums[i] <= 10^6

// 풀이
// 배열의 각 요소를 순회하면서 앞에서부터 증가하는 숫자의 합을 구하는 프로그램을 작성하라.

// 제한사항
// 배열의 길이는 1 이상 1000 이하이다.
// 배열의 요소는 -10^6 이상 10^6 이하이다.

// 제한사항
// 배열의 각 요소는 앞에서부터 1씩 증가하는 숫자로 이루어져 있다.
// 배열의 요소를 순회하면서 앞에서부터 증가하는 숫자의 합을 구하는 프로그램을 작성하라.

// 예제 1
// Input: nums = [1,2,3,4]
// Output: [1,3,6,10]
// Explanation: Running sum is obtained as follows: [1, 1+2, 1+
 // Fatal error: Index out of range

func primeFib(n: Int) -> Int {
    var fib = [1, 1]
    var i = 2
    while fib[i - 1] + fib[i - 2] < n {
        fib.append(fib[i - 1] + fib[i - 2])
        i += 1
    }
    var j = 0
    while fib[i - 1] + fib[i - 2] < n {
        j += 1
        i += 1
    }
    return fib[j]
}
```swift
// prime_fib returns n-th number that is a Fibonacci number and it's also prime.
// primeFib(n: 1) == 2
// primeFib(n: 2) == 3
// primeFib(n: 3) == 5
// primeFib(n: 4) == 13
// primeFib(n: 5) == 89
func primeFib(n: Int) -> Int {
    var fib = [1, 1]
    var i = 2
    while fib[i - 1] + fib[i - 2] < n {
        fib.append(fib[i - 1] + fib[i - 2])
        i += 1
    }
    var j = 0
    while fib[i - 1] + fib[i - 2] < n {
        j += 1
        i += 1
    }
    return fib[j]
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// ------------------------------------------
 // XCTAssertTrue failed

func primeFib(n: Int) -> Int {
    var fib = [1, 1]
    var i = 2
    while fib[i] < n {
        fib.append(fib[i - 1] + fib[i - 2])
        i += 1
    }
    return fib[i - 1]
}
```swift
// prime_fib returns n-th number that is a Fibonacci number and it's also prime.
// primeFib(n: 1) == 2
// primeFib(n: 2) == 3
// primeFib(n: 3) == 5
// primeFib(n: 4) == 13
// primeFib(n: 5) == 89
func primeFib(n: Int) -> Int {
    var fib = [1, 1]
    var i = 2
    while fib[i] < n {
        fib.append(fib[i - 1] + fib[i - 2])
        i += 1
    }
    return fib[i - 1]
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// ------------------------------------------------------------
 // Fatal error: Index out of range

func primeFib(n: Int) -> Int {
    var fib = [0, 1]
    var i = 2
    while fib[i - 1] + fib[i - 2] < n {
        fib.append(fib[i - 1] + fib[i - 2])
        i += 1
    }
    return fib[i]
}
```swift
// prime_fib returns n-th number that is a Fibonacci number and it's also prime.
// primeFib(n: 1) == 2
// primeFib(n: 2) == 3
// primeFib(n: 3) == 5
// primeFib(n: 4) == 13
// primeFib(n: 5) == 89
func primeFib(n: Int) -> Int {
    var fib = [0, 1]
    var i = 2
    while fib[i - 1] + fib[i - 2] < n {
        fib.append(fib[i - 1] + fib[i - 2])
        i += 1
    }
    return fib[i]
}

print(primeFib(1))
print(primeFib(2))
print(primeFib(3))
print(primeFib(4))
print(primeFib(5))
print(primeFib(6))
print(primeFib(7))
print(primeFib(8))
print(primeFib(9))
print(primeFib(10))
print(primeFib(11))
print(primeFib(12))
print(primeFib(13))
print(primeFib(14))
print(primeFib(15))
print(primeFib(16))
print(primeFib(17))
print(primeFib(18))
print(primeFib(19))
print(primeFib(20))
print(primeFib(21))
print(primeFib(22))
print(primeFib(23))
print(primeFib(24))
print(primeFib(25))
print(primeFib(26))
print(primeFib(27))
print(primeFib(28))
print(primeFib(29))
print(primeFib(30))
print(primeFib(31))
print(primeFib(32))
print(primeFib(33))
print(primeFib(34))
print(primeFib(35))
print(primeFib(36))
print(primeFib(37))
print(primeFib(38))
print(primeFib(39))
print(primeFib(40))
print(primeFib(41))
print(primeFib(42))
print(primeFib(43))
print(primeFib(44))
print(primeFib(45))
print(primeFib(46))
print(primeFib(47))
print(primeFib(48))
print(primeFib(49))
print(primeFib(50))
print(primeFib(51))
print(primeFib(52))
print(primeFib(53))
print(primeFib(54))
print(primeFib(55))
print(primeFib(56))
print(primeFib(57))
print(primeFib(58))
print(primeFib(59))
print(primeFib(60))
print(primeFib(61))
print(primeFib(62))
print(primeFib(63))
print(primeFib(64))
print(primeFib(65))
print(primeFib(66))
print(primeFib(67))
print(primeFib(68))
print(primeFib(69))
print(primeFib(70))
print(primeFib(71))
print(primeFib(72))
print(primeFib(73))
print(primeFib(74))
print(primeFib(75))
print(primeFib(76))
print(primeFib(77))
print(primeFib(78))
print(primeFib(79))
print(primeFib(80))
print(primeFib(81))
print(primeFib(82))
print(primeFib(83))
print(primeFib(84))
print(primeFib(85))
print(primeFib(86))
print(primeFib(87))
print(primeFib(88))
print(primeFib(89))
print(primeFib(90))
print(primeFib(91))
print(primeFib(92))
print(primeFib(93))
print(primeFib(94))
print(primeFib(95))
print(prime
 // Fatal error: Index out of range

func primeFib(n: Int) -> Int {
    var fib = [0, 1]
    var i = 2
    while fib[i - 1] + fib[i - 2] < n {
        fib.append(fib[i - 1] + fib[i - 2])
        i += 1
    }
    var j = 0
    while fib[j] < n {
        if isPrime(fib[j]) {
            return fib[j]
        }
        j += 1
    }
    return fib[j - 1]
}
```swift
// prime_fib returns n-th number that is a Fibonacci number and it's also prime.
// primeFib(n: 1) == 2
// primeFib(n: 2) == 3
// primeFib(n: 3) == 5
// primeFib(n: 4) == 13
// primeFib(n: 5) == 89
func primeFib(n: Int) -> Int {
    var fib = [0, 1]
    var i = 2
    while fib[i - 1] + fib[i - 2] < n {
        fib.append(fib[i - 1] + fib[i - 2])
        i += 1
    }
    var j = 0
    while fib[j] < n {
        if isPrime(fib[j]) {
            return fib[j]
        }
        j += 1
    }
    return fib[j - 1]
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// ---------------------------------
if isPrime(fib[j]) { // cannot find 'isPrime' in scope

func primeFib(n: Int) -> Int {
    var fib = [1, 1]
    var i = 2
    while fib[i] < n {
        fib[i] = fib[i - 1] + fib[i - 2]
        i += 1
    }
    return fib[i - 1]
}
```swift
// prime_fib returns n-th number that is a Fibonacci number and it's also prime.
// primeFib(n: 1) == 2
// primeFib(n: 2) == 3
// primeFib(n: 3) == 5
// primeFib(n: 4) == 13
// primeFib(n: 5) == 89
func primeFib(n: Int) -> Int {
    var fib = [1, 1]
    var i = 2
    while fib[i] < n {
        fib[i] = fib[i - 1] + fib[i - 2]
        i += 1
    }
    return fib[i - 1]
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// ---------------------------------------------------------
 // Fatal error: Index out of range

func primeFib(n: Int) -> Int {
    var fib = [0, 1]
    var i = 2
    while fib[i - 1] < n {
        fib[i] = fib[i - 1] + fib[i - 2]
        i += 1
    }
    return fib[i - 1]
}
```swift
// prime_fib returns n-th number that is a Fibonacci number and it's also prime.
// primeFib(n: 1) == 2
// primeFib(n: 2) == 3
// primeFib(n: 3) == 5
// primeFib(n: 4) == 13
// primeFib(n: 5) == 89
func primeFib(n: Int) -> Int {
    var fib = [0, 1]
    var i = 2
    while fib[i - 1] < n {
        fib[i] = fib[i - 1] + fib[i - 2]
        i += 1
    }
    return fib[i - 1]
}

print(primeFib(1)) // 2
print(primeFib(2)) // 3
print(primeFib(3)) // 5
print(primeFib(4)) // 13
print(primeFib(5)) // 89

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // XCTAssertTrue failed

func triplesSumToZero(l: [Int]) -> Bool {
    if l.count < 3 {
        return false
    }
    var result = false
    for i in 0..<l.count-2 {
        for j in i+1..<l.count-1 {
            for k in j+1..<l.count {
                if l[i] + l[j] + l[k] == 0 {
                    result = true
                    break
                }
            }
            if result {
                break
            }
        }
        if result {
            break
        }
    }
    return result
}
```swift
// triples_sum_to_zero takes an array of integers as an input.
// it returns true if there are three distinct elements in the array that
// sum to zero, and false otherwise.
// triplesSumToZero(l: [1, 3, 5, 0]) == false
// triplesSumToZero(l: [1, 3, -2, 1]) == true
// triplesSumToZero(l: [1, 2, 3, 7]) == false
// triplesSumToZero(l: [2, 4, -5, 3, 9, 7]) == true
// triplesSumToZero(l: [1]) == false
func triplesSumToZero(l: [Int]) -> Bool {
    if l.count < 3 {
        return false
    }
    var result = false
    for i in 0..<l.count-2 {
        for j in i+1..<l.count-1 {
            for k in j+1..<l.count {
                if l[i] + l[j] + l[k] == 0 {
                    result = true
                    break
                }
            }
            if result {
                break
            }
        }
        if result {
            break
        }
    }
    return result
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// ------------------------

func triplesSumToZero(l: [Int]) -> Bool {
    if l.count < 3 {
        return false
    }
    for i in 0..<l.count {
        for j in i+1..<l.count {
            for k in j+1..<l.count {
                if l[i] + l[j] + l[k] == 0 {
                    return true
                }
            }
        }
    }
    return false
}
```swift
// triples_sum_to_zero takes an array of integers as an input.
// it returns true if there are three distinct elements in the array that
// sum to zero, and false otherwise.
// triplesSumToZero(l: [1, 3, 5, 0]) == false
// triplesSumToZero(l: [1, 3, -2, 1]) == true
// triplesSumToZero(l: [1, 2, 3, 7]) == false
// triplesSumToZero(l: [2, 4, -5, 3, 9, 7]) == true
// triplesSumToZero(l: [1]) == false
func triplesSumToZero(l: [Int]) -> Bool {
    if l.count < 3 {
        return false
    }
    for i in 0..<l.count {
        for j in i+1..<l.count {
            for k in j+1..<l.count {
                if l[i] + l[j] + l[k] == 0 {
                    return true
                }
            }
        }
    }
    return false
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ------------------

func triplesSumToZero(l: [Int]) -> Bool {
    if l.count < 3 {
        return false
    }
    for i in 0..<l.count {
        for j in i+1..<l.count {
            for k in j+1..<l.count {
                if l[i] + l[j] + l[k] == 0 {
                    return true
                }
            }
        }
    }
    return false
}
```swift
// triples_sum_to_zero takes an array of integers as an input.
// it returns true if there are three distinct elements in the array that
// sum to zero, and false otherwise.
// triplesSumToZero(l: [1, 3, 5, 0]) == false
// triplesSumToZero(l: [1, 3, -2, 1]) == true
// triplesSumToZero(l: [1, 2, 3, 7]) == false
// triplesSumToZero(l: [2, 4, -5, 3, 9, 7]) == true
// triplesSumToZero(l: [1]) == false
func triplesSumToZero(l: [Int]) -> Bool {
    if l.count < 3 {
        return false
    }
    for i in 0..<l.count {
        for j in i+1..<l.count {
            for k in j+1..<l.count {
                if l[i] + l[j] + l[k] == 0 {
                    return true
                }
            }
        }
    }
    return false
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ------------------

func triplesSumToZero(l: [Int]) -> Bool {
    if l.count < 3 {
        return false
    }
    var sum = 0
    for i in l {
        sum += i
    }
    if sum % 3 != 0 {
        return false
    }
    var sum2 = sum / 3
    var count = 0
    for i in l {
        if i == sum2 {
            count += 1
        }
    }
    if count >= 3 {
        return true
    }
    return false
}
```swift
// triples_sum_to_zero takes an array of integers as an input.
// it returns true if there are three distinct elements in the array that
// sum to zero, and false otherwise.
// triplesSumToZero(l: [1, 3, 5, 0]) == false
// triplesSumToZero(l: [1, 3, -2, 1]) == true
// triplesSumToZero(l: [1, 2, 3, 7]) == false
// triplesSumToZero(l: [2, 4, -5, 3, 9, 7]) == true
// triplesSumToZero(l: [1]) == false
func triplesSumToZero(l: [Int]) -> Bool {
    if l.count < 3 {
        return false
    }
    var sum = 0
    for i in l {
        sum += i
    }
    if sum % 3 != 0 {
        return false
    }
    var sum2 = sum / 3
    var count = 0
    for i in l {
        if i == sum2 {
            count += 1
        }
    }
    if count >= 3 {
        return true
    }
    return false
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ------------------------------------------------
var sum2 = sum / 3 // variable 'sum2' was never mutated; consider changing to 'let' constant
 // XCTAssertTrue failed

func triplesSumToZero(l: [Int]) -> Bool {
    if l.count < 3 {
        return false
    }
    var sum = 0
    for i in l {
        sum += i
    }
    if sum % 3 != 0 {
        return false
    }
    var sumToFind = sum / 3
    var left = 0
    var right = l.count - 1
    while left < right {
        var leftSum = l[left] + l[right]
        if leftSum == sumToFind {
            return true
        } else if leftSum < sumToFind {
            left += 1
        } else {
            right -= 1
        }
    }
    return false
}
```swift
// triples_sum_to_zero takes an array of integers as an input.
// it returns true if there are three distinct elements in the array that
// sum to zero, and false otherwise.
// triplesSumToZero(l: [1, 3, 5, 0]) == false
// triplesSumToZero(l: [1, 3, -2, 1]) == true
// triplesSumToZero(l: [1, 2, 3, 7]) == false
// triplesSumToZero(l: [2, 4, -5, 3, 9, 7]) == true
// triplesSumToZero(l: [1]) == false
func triplesSumToZero(l: [Int]) -> Bool {
    if l.count < 3 {
        return false
    }
    var sum = 0
    for i in l {
        sum += i
    }
    if sum % 3 != 0 {
        return false
    }
    var sumToFind = sum / 3
    var left = 0
    var right = l.count - 1
    while left < right {
        var leftSum = l[left] + l[right]
        if leftSum == sumToFind {
            return true
        } else if leftSum < sumToFind {
            left += 1
        } else {
            right -= 1
        }
    }
    return false
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// ---------------------------------------------
var sumToFind = sum / 3 // variable 'sumToFind' was never mutated; consider changing to 'let' constant
var leftSum = l[left] + l[right] // variable 'leftSum' was never mutated; consider changing to 'let' constant
 // XCTAssertTrue failed

func triplesSumToZero(l: [Int]) -> Bool {
    var result = false
    if l.count > 2 {
        for i in 0..<l.count-2 {
            for j in i+1..<l.count-1 {
                for k in j+1..<l.count {
                    if l[i] + l[j] + l[k] == 0 {
                        result = true
                        break
                    }
                }
            }
        }
    }
    return result
}
```swift
// triples_sum_to_zero takes an array of integers as an input.
// it returns true if there are three distinct elements in the array that
// sum to zero, and false otherwise.
// triplesSumToZero(l: [1, 3, 5, 0]) == false
// triplesSumToZero(l: [1, 3, -2, 1]) == true
// triplesSumToZero(l: [1, 2, 3, 7]) == false
// triplesSumToZero(l: [2, 4, -5, 3, 9, 7]) == true
// triplesSumToZero(l: [1]) == false
func triplesSumToZero(l: [Int]) -> Bool {
    var result = false
    if l.count > 2 {
        for i in 0..<l.count-2 {
            for j in i+1..<l.count-1 {
                for k in j+1..<l.count {
                    if l[i] + l[j] + l[k] == 0 {
                        result = true
                        break
                    }
                }
            }
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 12. Write a function that takes an array of integers and returns the sum of
// the integers.
// sum(l: [1, 2, 3]) == 6
// sum(l: [1, 2, 3, 4]) == 10
// sum(l: [1, 2, 3, 4, 5]) == 15
// sum(l: [1, 2, 3, 4, 5, 6]) == 21
// sum(l: [1, 2, 3, 4, 5, 6, 7]) == 28
// sum(l: [1, 2, 3, 4, 5, 6, 7, 8]) == 36
// sum(l: [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 45
// sum(l: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55
// sum(l: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 66
// sum(l: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 78
// sum(l: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == 91
// sum(l: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 105
// sum(l: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 121
// sum(l: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 137
// sum(l: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]) == 155
// sum(l: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == 173
// sum(l: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 191
// sum(l: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16

func triplesSumToZero(l: [Int]) -> Bool {
    if l.count < 3 {
        return false
    }
    var sum = 0
    for i in l {
        sum += i
    }
    if sum % 3 != 0 {
        return false
    }
    var sum_to_find = sum / 3
    var count = 0
    var i = 0
    var j = 0
    var k = 0
    while i < l.count {
        j = i + 1
        while j < l.count {
            k = j + 1
            while k < l.count {
                if l[i] + l[j] + l[k] == sum_to_find {
                    count += 1
                }
                k += 1
            }
            j += 1
        }
        i += 1
    }
    if count > 0 {
        return true
    } else {
        return false
    }
}
```swift
// triples_sum_to_zero takes an array of integers as an input.
// it returns true if there are three distinct elements in the array that
// sum to zero, and false otherwise.
// triplesSumToZero(l: [1, 3, 5, 0]) == false
// triplesSumToZero(l: [1, 3, -2, 1]) == true
// triplesSumToZero(l: [1, 2, 3, 7]) == false
// triplesSumToZero(l: [2, 4, -5, 3, 9, 7]) == true
// triplesSumToZero(l: [1]) == false
func triplesSumToZero(l: [Int]) -> Bool {
    if l.count < 3 {
        return false
    }
    var sum = 0
    for i in l {
        sum += i
    }
    if sum % 3 != 0 {
        return false
    }
    var sum_to_find = sum / 3
    var count = 0
    var i = 0
    var j = 0
    var k = 0
    while i < l.count {
        j = i + 1
        while j < l.count {
            k = j + 1
            while k < l.count {
                if l[i] + l[j] + l[k] == sum_to_find {
                    count += 1
                }
                k += 1
            }
            j += 1
        }
        i += 1
    }
    if count > 0 {
        return true
    } else {
        return false
    }
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

var input = [1, 3, 5, 0]
print(triplesSumToZero(input))

input = [1, 3, -2, 1]
print(triplesSumToZero(input))

input = [1, 2, 3, 7]
print(triplesSumToZero(input))

input = [2, 4, -5, 3, 9, 7]
print(triplesSumToZero(input))

input = [1]
print(triplesSumToZero(input))<|endoftext|>// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// Given an array of integers, return a new array such that each element at
// index i of the new array is the product of all the numbers in the original
// array except the one at i.
//
// For example, if our input was [1, 2, 3, 4, 5], the expected output would be
// [120, 60, 40, 30, 24]. If our input was [3, 2, 1], the expected output would
// be [2, 3, 6].
//
// Follow-up: what if you can't use division?

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ---------
var sum_to_find = sum / 3 // variable 'sum_to_find' was never mutated; consider changing to 'let' constant
 // XCTAssertTrue failed

func triplesSumToZero(l: [Int]) -> Bool {
    // your code here
    return false
}
```swift
// triples_sum_to_zero takes an array of integers as an input.
// it returns true if there are three distinct elements in the array that
// sum to zero, and false otherwise.
// triplesSumToZero(l: [1, 3, 5, 0]) == false
// triplesSumToZero(l: [1, 3, -2, 1]) == true
// triplesSumToZero(l: [1, 2, 3, 7]) == false
// triplesSumToZero(l: [2, 4, -5, 3, 9, 7]) == true
// triplesSumToZero(l: [1]) == false
func triplesSumToZero(l: [Int]) -> Bool {
    // your code here
    return false
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ---------------------------------
 // XCTAssertTrue failed

func triplesSumToZero(l: [Int]) -> Bool {
    if l.count < 3 {
        return false
    }
    for i in 0..<l.count-2 {
        for j in i+1..<l.count-1 {
            for k in j+1..<l.count {
                if l[i] + l[j] + l[k] == 0 {
                    return true
                }
            }
        }
    }
    return false
}
```swift
// triples_sum_to_zero takes an array of integers as an input.
// it returns true if there are three distinct elements in the array that
// sum to zero, and false otherwise.
// triplesSumToZero(l: [1, 3, 5, 0]) == false
// triplesSumToZero(l: [1, 3, -2, 1]) == true
// triplesSumToZero(l: [1, 2, 3, 7]) == false
// triplesSumToZero(l: [2, 4, -5, 3, 9, 7]) == true
// triplesSumToZero(l: [1]) == false
func triplesSumToZero(l: [Int]) -> Bool {
    if l.count < 3 {
        return false
    }
    for i in 0..<l.count-2 {
        for j in i+1..<l.count-1 {
            for k in j+1..<l.count {
                if l[i] + l[j] + l[k] == 0 {
                    return true
                }
            }
        }
    }
    return false
}

// -----------------------------------------------------------------------------

// 1.1
// Given two strings, write a method to decide if one is a permutation of the
// other.
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dcab") == false
// isPermutation("abcd", "dcba") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcabd") == false
// isPermutation("abcd", "dcab

func triplesSumToZero(l: [Int]) -> Bool {
    if l.count < 3 {
        return false
    }
    for i in 0..<l.count - 2 {
        for j in i+1..<l.count - 1 {
            for k in j+1..<l.count {
                if l[i] + l[j] + l[k] == 0 {
                    return true
                }
            }
        }
    }
    return false
}
```swift
// triples_sum_to_zero takes an array of integers as an input.
// it returns true if there are three distinct elements in the array that
// sum to zero, and false otherwise.
// triplesSumToZero(l: [1, 3, 5, 0]) == false
// triplesSumToZero(l: [1, 3, -2, 1]) == true
// triplesSumToZero(l: [1, 2, 3, 7]) == false
// triplesSumToZero(l: [2, 4, -5, 3, 9, 7]) == true
// triplesSumToZero(l: [1]) == false
func triplesSumToZero(l: [Int]) -> Bool {
    if l.count < 3 {
        return false
    }
    for i in 0..<l.count - 2 {
        for j in i+1..<l.count - 1 {
            for k in j+1..<l.count {
                if l[i] + l[j] + l[k] == 0 {
                    return true
                }
            }
        }
    }
    return false
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// ---------------------------

func carRaceCollision(n: Int) -> Int {
    var result = 0
    for i in 1..<n {
        result += i
    }
    return result
}

func countLetters(s: String) -> Int {
    var result = 0
    for c in s {
        if c.isUpper {
            result += 1
        }
        if c.isLower {
            result += 1
        }
    }
    return result
}

func sumArray(arr: [Int]) -> Int {
    var result = 0
    for i in arr {
        result += i
    }
    return result
}

func maxArray(arr: [Int]) -> Int {
    var result = arr[0]
    for i in arr {
        if i > result {
            result = i
        }
    }
    return result
}

func minArray(arr: [Int]) -> Int {
    var result = arr[0]
    for i in arr {
        if i < result {
            result = i
        }
    }
    return result
}

func avgArray(arr: [Int]) -> Int {
    var result = 0
    for i in arr {
        result += i
    }
    return result / arr.count
}

func prodArray(arr: [Int]) -> Int {
    var result = 1
    for i in arr {
        result *= i
    }
    return result
}

func countEven(arr: [Int]) -> Int {
    var result = 0
    for i in arr {
        if i % 2 == 0 {
            result += 1
        }
    }
    return result
}

func countOdd(arr: [Int]) -> Int {
    var result = 0
    for i in arr {
        if i % 2 != 0 {
            result += 1
        }
    }
    return result
}
```swift
// Imagine a road that's a perfectly straight infinitely long line.
// n cars are driving left to right;  simultaneously, a different set of n cars
// are driving right to left.   The two sets of cars start out being very far from
// each other.  All cars move in the same speed.  Two cars are said to collide
// when a car that's moving left to right hits a car that's moving right to left.
// However, the cars are infinitely sturdy and strong; as a result, they continue moving
// in their trajectory as if they did not collide.
// This function outputs the number of such collisions.
func carRaceCollision(n: Int) -> Int {
    var result = 0
    for i in 1..<n {
        result += i
    }
    return result
}

// 10. Write a function that takes a string as input and returns the number of
// uppercase letters and lowercase letters.
// Example:
// Input: "Hello, World!"
// Output: 3
func countLetters(s: String) -> Int {
    var result = 0
    for c in s {
        if c.isUpper {
            result += 1
        }
        if c.isLower {
            result += 1
        }
    }
    return result
}

// 11. Write a function that takes an array of integers as input and returns the
// sum of all the integers in the array.
// Example:
// Input: [1, 2, 3, 4, 5]
// Output: 15
func sumArray(arr: [Int]) -> Int {
    var result = 0
    for i in arr {
        result += i
    }
    return result
}

// 12. Write a function that takes an array of integers as input and returns the
// maximum integer in the array.
// Example:
// Input: [1, 2, 3, 4, 5]
// Output: 5
func maxArray(arr: [Int]) -> Int {
    var result = arr[0]
    for i in arr {
        if i > result {
            result = i
        }
    }
    return result
}

// 13. Write a function that takes an array of integers as input and returns the
// minimum integer in the array.
// Example:
// Input: [1, 2, 3, 4, 5]
// Output: 1
func minArray(arr: [Int]) -> Int {
    var result = arr[0]
    for i in arr {
        if i < result {
            result = i
        }
    }
    return result
}

// 14. Write a function that takes an array of integers as input and returns the
// average of all the integers in the array.
// Example:
// Input: [1, 2, 3, 4, 5]
// Output: 3
func avgArray(arr: [Int]) -> Int {
    var result = 0
    for i in arr {
        result += i
    }
    return result / arr.count
}

// 15. Write a function that takes an array of integers as input and returns the
// product of all the integers in the array.
// Example:
// Input: [1, 2, 3, 4, 5]
// Output: 120
func prodArray(arr: [Int]) -> Int {
    var result = 1
    for i in arr {
        result *= i
    }
    return result
}

// 16. Write a function that takes an array of integers as input and returns the
// number of even integers in the array.
// Example:
// Input: [1, 2, 3, 4, 5]
// Output: 2
func countEven(arr: [Int]) -> Int {
    var result = 0
    for i in arr {
        if i % 2 == 0 {
            result += 1
        }
    }
    return result
}

// 17. Write a function that takes an array of integers as input and returns the
// number of odd integers in the array.
// Example:
// Input: [1, 2, 3, 4, 5]
// Output: 3
func countOdd(arr: [Int]) -> Int {
    var result = 0
    for i in arr {
        if i % 2 != 0 {
            result += 1
        }
    }
    return result
}

// 18. Write a function that takes an array of integers as input and returns the
// number of integers in the array that are greater than 0.
// Example:
// Input: [1, 2, 3, 4, 5]
// Output: 3
func countPositive(arr: [Int]) -> Int {
    var result = 0
    for i in arr {
        if i >
if c.isUpper { // value of type 'Character' has no member 'isUpper'
if c.isLower { // value of type 'Character' has no member 'isLower'

func carRaceCollision(n: Int) -> Int {
    var result = 0
    for i in 1...n {
        for j in 1...n {
            if i != j {
                result += 1
            }
        }
    }
    return result
}

func countLetters(s: String) -> (uppercase: Int, lowercase: Int) {
    var uppercase = 0
    var lowercase = 0
    for c in s {
        if c.isUpper {
            uppercase += 1
        } else {
            lowercase += 1
        }
    }
    return (uppercase, lowercase)
}

func reverseString(s: String) -> String {
    return String(s.reversed())
}

func countBits(n: Int) -> Int {
    var result = 0
    while n > 0 {
        if n & 1 == 1 {
            result += 1
        }
        n >>= 1
    }
    return result
}

func countSetBits(n: Int) -> Int {
    var result = 0
    while n > 0 {
        result += n & 1
        n >>= 1
    }
    return result
}

func countBits(n: Int) -> [Int] {
    var result = [0, 0]
    while n > 0 {
        result[n & 1] += 1
        n >>= 1
    }
    return result
}
```swift
// Imagine a road that's a perfectly straight infinitely long line.
// n cars are driving left to right;  simultaneously, a different set of n cars
// are driving right to left.   The two sets of cars start out being very far from
// each other.  All cars move in the same speed.  Two cars are said to collide
// when a car that's moving left to right hits a car that's moving right to left.
// However, the cars are infinitely sturdy and strong; as a result, they continue moving
// in their trajectory as if they did not collide.
// This function outputs the number of such collisions.
func carRaceCollision(n: Int) -> Int {
    var result = 0
    for i in 1...n {
        for j in 1...n {
            if i != j {
                result += 1
            }
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 10. Write a function that takes a string as input and returns the number of
// uppercase letters and lowercase letters.
// Example:
// Input: "Hello, World!"
// Output: 3
func countLetters(s: String) -> (uppercase: Int, lowercase: Int) {
    var uppercase = 0
    var lowercase = 0
    for c in s {
        if c.isUpper {
            uppercase += 1
        } else {
            lowercase += 1
        }
    }
    return (uppercase, lowercase)
}

// -----------------------------------------------------------------------------
// 11. Write a function that takes a string as input and returns the string
// reversed.
// Example:
// Input: "hello"
// Output: "olleh"
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// -----------------------------------------------------------------------------
// 12. Write a function that takes an integer as input and returns the number of
// bits that are equal to one in the binary representation of that number.
// Example:
// Input: 7
// Output: 3
// Explanation: 7 is 111 and has binary representation 111.
func countBits(n: Int) -> Int {
    var result = 0
    while n > 0 {
        if n & 1 == 1 {
            result += 1
        }
        n >>= 1
    }
    return result
}

// -----------------------------------------------------------------------------
// 13. Write a function that takes an integer as input and returns the number of
// bits that are equal to one in the binary representation of that number,
// excluding any leading zero bits.
// Example:
// Input: 11
// Output: 3
// Explanation: 11 is 1011 and has binary representation 1011.
//              There are three ones, so return 3.
func countSetBits(n: Int) -> Int {
    var result = 0
    while n > 0 {
        result += n & 1
        n >>= 1
    }
    return result
}

// -----------------------------------------------------------------------------
// 14. Write a function that takes an integer as input and returns the number of
// bits that are equal to one in the binary representation of that number,
// then returns the number of bits that are equal to zero in the binary
// representation of that number.
// Example:
// Input: 7
// Output: [3, 0]
// Explanation: 7 is 111 and has binary representation 111.
//              So the returned array should be [3, 0]
func countBits(n: Int) -> [Int] {
    var result = [0, 0]
    while n > 0 {
        result[n & 1] += 1
        n >>= 1
    }
    return result
}

// -----------------------------------------------------------------------------
// 15. Write a function that takes an integer as input and returns the number of
// bits that are equal to one in the binary representation of that number,
// then returns the number of bits that are equal to zero in the binary
// representation of that number.
// Example:
// Input: 7
// Output: [3, 0]
// Explanation: 7 is 111 and has binary representation 111.
//              So the returned array should be [3,
if c.isUpper { // value of type 'Character' has no member 'isUpper'
n >>= 1 // left side of mutating operator isn't mutable: 'n' is a 'let' constant
n >>= 1 // left side of mutating operator isn't mutable: 'n' is a 'let' constant
n >>= 1 // left side of mutating operator isn't mutable: 'n' is a 'let' constant

func carRaceCollision(n: Int) -> Int {
    var result = 0
    for i in 1..<n {
        result += i * (n - i)
    }
    return result
}

func sumNumbers(s: String) -> Int {
    var result = 0
    var currentNumber = ""
    for char in s {
        if char.isDigit(char) {
            currentNumber += char
        } else if currentNumber != "" {
            result += Int(currentNumber)
            currentNumber = ""
        }
    }
    if currentNumber != "" {
        result += Int(currentNumber)
    }
    return result
}

func maxPalindrome(s: String) -> Int {
    var result = 0
    var currentPalindrome = ""
    for char in s {
        currentPalindrome += char
        if currentPalindrome == currentPalindrome.reversed() {
            result = max(result, currentPalindrome.length)
        }
    }
    return result
}

func longestPalindromeDelete(s: String) -> Int {
    var result = 0
    var currentPalindrome = ""
    for char in s {
        currentPalindrome += char
        if currentPalindrome == currentPalindrome.reversed() {
            result = max(result, currentPalindrome.length)
        }
        if currentPalindrome.length > 1 && currentPalindrome[0] == currentPalindrome[1] {
            currentPalindrome = currentPalindrome[1..]
        }
    }
    return result
}
```swift
// Imagine a road that's a perfectly straight infinitely long line.
// n cars are driving left to right;  simultaneously, a different set of n cars
// are driving right to left.   The two sets of cars start out being very far from
// each other.  All cars move in the same speed.  Two cars are said to collide
// when a car that's moving left to right hits a car that's moving right to left.
// However, the cars are infinitely sturdy and strong; as a result, they continue moving
// in their trajectory as if they did not collide.
// This function outputs the number of such collisions.
func carRaceCollision(n: Int) -> Int {
    var result = 0
    for i in 1..<n {
        result += i * (n - i)
    }
    return result
}

// 2.
// Given a string, return the sum of the numbers appearing in the string, ignoring all other characters.
// A number is a series of 1 or more digit chars in a row.
// (Note: Character.isDigit(char) tests if a char is one of the chars '0', '1', .. '9').
//
// Examples:
// "abc123xyz" → 123
// "aa11b33" → 44
// "7 11" → 22

func sumNumbers(s: String) -> Int {
    var result = 0
    var currentNumber = ""
    for char in s {
        if char.isDigit(char) {
            currentNumber += char
        } else if currentNumber != "" {
            result += Int(currentNumber)
            currentNumber = ""
        }
    }
    if currentNumber != "" {
        result += Int(currentNumber)
    }
    return result
}

// 3.
// Given a string, return the length of the longest palindrome that can be made using
// letters from the string.
//
// For example, maxPalindrome("aaabaaa") → 9
// maxPalindrome("abccbaitf") → 3
// maxPalindrome("abccba") → 7

func maxPalindrome(s: String) -> Int {
    var result = 0
    var currentPalindrome = ""
    for char in s {
        currentPalindrome += char
        if currentPalindrome == currentPalindrome.reversed() {
            result = max(result, currentPalindrome.length)
        }
    }
    return result
}

// 4.
// Given a string, return the length of the longest palindrome that can be made
// by deleting exactly one character from the string.
//
// For example, longestPalindromeDelete("aaabaaa") → 7
// longestPalindromeDelete("abccbaitf") → 5
// longestPalindromeDelete("abccba") → 7

func longestPalindromeDelete(s: String) -> Int {
    var result = 0
    var currentPalindrome = ""
    for char in s {
        currentPalindrome += char
        if currentPalindrome == currentPalindrome.reversed() {
            result = max(result, currentPalindrome.length)
        }
        if currentPalindrome.length > 1 && currentPalindrome[0] == currentPalindrome[1] {
            currentPalindrome = currentPalindrome[1..]
        }
    }
    return result
}

// 5.
// Given a string, return the length of the longest palindrome that can be made
// by deleting exactly one character from the string.
//
// For example, longestPalindromeDelete("aaabaaa") → 7
// longestPalindromeDelete("abccbaitf") → 5
// longestPalindromeDelete("abccba") → 7

func longestPalindromeDelete(s: String) -> Int {
    var result = 0
    var currentPalindrome = ""
    for char in s {
        currentPalindrome += char
        if currentPalindrome == currentPalindrome.reversed() {
            result = max(result, currentPalindrome.length)
        }
        if currentPalindrome.length > 1 && currentPalindrome[0] == currentPalindrome[1] {
            currentPalindrome = currentPalindrome[1..]
        }
    }
    return result
}

// 6.
// Given a string, return the length of the longest palindrome that can be made
// by deleting exactly one character from the string.
//
// For example, longestPalindromeDelete("aaabaaa") → 7
// longestPalindromeDelete("abccbaitf") → 5
// longestPalindromeDelete("abccba
if char.isDigit(char) { // value of type 'Character' has no member 'isDigit'
currentNumber += char // cannot convert value of type 'Character' to expected argument type 'String'
result += Int(currentNumber) // value of optional type 'Int?' must be unwrapped to a value of type 'Int'
result += Int(currentNumber) // value of optional type 'Int?' must be unwrapped to a value of type 'Int'
currentPalindrome += char // cannot convert value of type 'Character' to expected argument type 'String'
if currentPalindrome == currentPalindrome.reversed() { // binary operator '==' cannot be applied to operands of type 'String' and '[String.Element]' (aka 'Array<Character>')
result = max(result, currentPalindrome.length) // value of type 'String' has no member 'length'
currentPalindrome += char // cannot convert value of type 'Character' to expected argument type 'String'
if currentPalindrome == currentPalindrome.reversed() { // binary operator '==' cannot be applied to operands of type 'String' and '[String.Element]' (aka 'Array<Character>')
result = max(result, currentPalindrome.length) // value of type 'String' has no member 'length'
if currentPalindrome.length > 1 && currentPalindrome[0] == currentPalindrome[1] { // value of type 'String' has no member 'length'
currentPalindrome = currentPalindrome[1..] // cannot find operator '..' in scope; did you mean '...'?

func carRaceCollision(n: Int) -> Int {
    let cars = [Int(0), Int(0)]
    let collisions = 0
    for i in 0..<n {
        cars[i % 2] += 1
        if cars[i % 2] == cars[(i + 1) % 2] {
            collisions += 1
        }
    }
    return collisions
}
```swift
// Imagine a road that's a perfectly straight infinitely long line.
// n cars are driving left to right;  simultaneously, a different set of n cars
// are driving right to left.   The two sets of cars start out being very far from
// each other.  All cars move in the same speed.  Two cars are said to collide
// when a car that's moving left to right hits a car that's moving right to left.
// However, the cars are infinitely sturdy and strong; as a result, they continue moving
// in their trajectory as if they did not collide.
// This function outputs the number of such collisions.
func carRaceCollision(n: Int) -> Int {
    let cars = [Int(0), Int(0)]
    let collisions = 0
    for i in 0..<n {
        cars[i % 2] += 1
        if cars[i % 2] == cars[(i + 1) % 2] {
            collisions += 1
        }
    }
    return collisions
}

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------
cars[i % 2] += 1 // left side of mutating operator isn't mutable: 'cars' is a 'let' constant
collisions += 1 // left side of mutating operator isn't mutable: 'collisions' is a 'let' constant

func carRaceCollision(n: Int) -> Int {
    var result = 0
    for i in 1...n {
        result += i * (n - i)
    }
    return result
}
```swift
// Imagine a road that's a perfectly straight infinitely long line.
// n cars are driving left to right;  simultaneously, a different set of n cars
// are driving right to left.   The two sets of cars start out being very far from
// each other.  All cars move in the same speed.  Two cars are said to collide
// when a car that's moving left to right hits a car that's moving right to left.
// However, the cars are infinitely sturdy and strong; as a result, they continue moving
// in their trajectory as if they did not collide.
// This function outputs the number of such collisions.
func carRaceCollision(n: Int) -> Int {
    var result = 0
    for i in 1...n {
        result += i * (n - i)
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.1.2.  A palindrome is a word that's spelled the same forward and backward.
// For example, radar is a palindrome.  Some palindromic words are spelled like
// madam, madam I'm Adam.  Others, like alex, are spelled like madam I'M Adam.
// The challenge is to write the shortest function that determines whether a
// given string of characters is a palindrome.
// -----------------------------------------------------------------------------
// A palindrome is a word that's spelled the same forward and backward.
// For example, radar is a palindrome.  Some palindromic words are spelled like
// madam, madam I'm Adam.  Others, like alex, are spelled like madam I'M Adam.
// The challenge is to write the shortest function that determines whether a
// given string of characters is a palindrome.
// -----------------------------------------------------------------------------
// A palindrome is a word that's spelled the same forward and backward.
// For example, radar is a palindrome.  Some palindromic words are spelled like
// madam, madam I'm Adam.  Others, like alex, are spelled like madam I'M Adam.
// The challenge is to write the shortest function that determines whether a
// given string of characters is a palindrome.
// -----------------------------------------------------------------------------
// A palindrome is a word that's spelled the same forward and backward.
// For example, radar is a palindrome.  Some palindromic words are spelled like
// madam, madam I'm Adam.  Others, like alex, are spelled like madam I'M Adam.
// The challenge is to write the shortest function that determines whether a
// given string of characters is a palindrome.
// -----------------------------------------------------------------------------
// A palindrome is a word that's spelled the same forward and backward.
// For example, radar is a palindrome.  Some palindromic words are spelled like
// madam, madam I'm Adam.  Others, like alex, are spelled like madam I'M Adam.
// The challenge is to write the shortest function that determines whether a
// given string of characters is a palindrome.
// -----------------------------------------------------------------------------
// A palindrome is a word that's spelled the same forward and backward.
// For example, radar is a palindrome.  Some palindromic words are spelled like
// madam, madam I'm Adam.  Others, like alex, are spelled like madam I'M Adam.
// The challenge is to write the shortest function that determines whether a
// given string of characters is a palindrome.
// -----------------------------------------------------------------------------
// A palindrome is a word that's spelled the same forward and backward.
// For example, radar is a palindrome.  Some palindromic words are spelled like
// madam, madam I'm Adam.  Others, like alex, are spelled like madam I'M Adam.
// The challenge is to write the shortest function that determines whether a
// given string of characters is a palindrome.
// -----------------------------------------------------------------------------
// A palindrome is a word that's spelled the same forward and backward.
// For example, radar is a palindrome.  Some palindromic words are spelled like
// madam, madam I'm Adam.  Others, like alex, are spelled like mad
 // XCTAssertTrue failed

func carRaceCollision(n: Int) -> Int {
    var collisions = 0
    for i in 1...n {
        collisions += n - i
    }
    return collisions
}
```swift
// Imagine a road that's a perfectly straight infinitely long line.
// n cars are driving left to right;  simultaneously, a different set of n cars
// are driving right to left.   The two sets of cars start out being very far from
// each other.  All cars move in the same speed.  Two cars are said to collide
// when a car that's moving left to right hits a car that's moving right to left.
// However, the cars are infinitely sturdy and strong; as a result, they continue moving
// in their trajectory as if they did not collide.
// This function outputs the number of such collisions.
func carRaceCollision(n: Int) -> Int {
    var collisions = 0
    for i in 1...n {
        collisions += n - i
    }
    return collisions
}

// -----------------------------------------------------------------------------
// 1.1.2
// -----------------------------------------------------------------------------
// Given a string, return the length of the longest substring without repeating
// characters.
// For example, the longest substring without repeating letters for "abcabcbb"
// is "abc", which the length is 3.
// For "bbbbb" the longest substring is "b", with the length of 1.
//
// Example 1:
// Input: "abcabcbb"
// Output: 3
// Explanation: The answer is "abc", with the length of 3.
//
// Example 2:
// Input: "pwwkew"
// Output: 3
// Explanation: The answer is "wke", with the length of 3.
//              Note that the answer must be a substring, "pwke" is a subsequence and not a substring.

// -----------------------------------------------------------------------------
// 1.1.3
// -----------------------------------------------------------------------------
// Given a string s, find the length of the longest substring without repeating characters.
//
// Example 1:
// Input: "abcabcbb"
// Output: 3
// Explanation: The answer is "abc", with the length of 3.
//
// Example 2:
// Input: "bbbbb"
// Output: 1
// Explanation: The answer is "b", with the length of 1.
//
// Example 3:
// Input: "pwwkew"
// Output: 3
// Explanation: The answer is "wke", with the length of 3.
//              Note that the answer must be a substring, "pwke" is a subsequence and not a substring.

// -----------------------------------------------------------------------------
// 1.1.4
// -----------------------------------------------------------------------------
// Given an array of integers, return indices of the two numbers such that they add up to a specific target.
//
// You may assume that each input would have exactly one solution, and you may not use the same element twice.
//
// Example:
// Given nums = [2, 7, 11, 15], target = 9,
//
// Because nums[0] + nums[1] = 2 + 7 = 9,
// return [0, 1].

// -----------------------------------------------------------------------------
// 1.1.5
// -----------------------------------------------------------------------------
// Given an array of integers, return indices of the two numbers such that they add up to a specific target.
//
// You may assume that each input would have exactly one solution, and you may not use the same element twice.
//
// Example:
// Given nums = [2, 7, 11, 15], target = 9,
//
// Because nums[0] + nums[1] = 2 + 7 = 9,
// return [0, 1].

// -----------------------------------------------------------------------------
// 1.1.6
// -----------------------------------------------------------------------------
// Given an array of integers, return indices of the two numbers such that they add up to a specific target.
//
// You may assume that each input would have exactly one solution, and you may not use the same element twice.
//
//
 // XCTAssertTrue failed

func carRaceCollision(n: Int) -> Int {
    var result = 0
    for i in 1..<n {
        result += i
    }
    return result
}

func countChar(str: String, char: Character) -> Int {
    return str.count(of: char)
}
```swift
// Imagine a road that's a perfectly straight infinitely long line.
// n cars are driving left to right;  simultaneously, a different set of n cars
// are driving right to left.   The two sets of cars start out being very far from
// each other.  All cars move in the same speed.  Two cars are said to collide
// when a car that's moving left to right hits a car that's moving right to left.
// However, the cars are infinitely sturdy and strong; as a result, they continue moving
// in their trajectory as if they did not collide.
// This function outputs the number of such collisions.
func carRaceCollision(n: Int) -> Int {
    var result = 0
    for i in 1..<n {
        result += i
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.1.2
// -----------------------------------------------------------------------------
// Write a function that takes a string as input and returns the number of
// times that a particular character appears in the string.
// For example, given the input "apple", your function should return 2.
// Hint: you may find the built-in string method count(of:_) helpful.

func countChar(str: String, char: Character) -> Int {
    return str.count(of: char)
}

// -----------------------------------------------------------------------------
// 1.1.3
// -----------------------------------------------------------------------------
// Write a function that takes a string as input and returns the number of
// times that a particular character appears in the string.
// For example, given the input "apple", your function should return 2.
// Hint: you may find the built-in string method count(of:_) helpful.

func countChar(str: String, char: Character) -> Int {
    return str.count(of: char)
}

// -----------------------------------------------------------------------------
// 1.1.4
// -----------------------------------------------------------------------------
// Write a function that takes a string as input and returns the number of
// times that a particular character appears in the string.
// For example, given the input "apple", your function should return 2.
// Hint: you may find the built-in string method count(of:_) helpful.

func countChar(str: String, char: Character) -> Int {
    return str.count(of: char)
}

// -----------------------------------------------------------------------------
// 1.1.5
// -----------------------------------------------------------------------------
// Write a function that takes a string as input and returns the number of
// times that a particular character appears in the string.
// For example, given the input "apple", your function should return 2.
// Hint: you may find the built-in string method count(of:_) helpful.

func countChar(str: String, char: Character) -> Int {
    return str.count(of: char)
}

// -----------------------------------------------------------------------------
// 1.1.6
// -----------------------------------------------------------------------------
// Write a function that takes a string as input and returns the number of
// times that a particular character appears in the string.
// For example, given the input "apple", your function should return 2.
// Hint: you may find the built-in string method count(of:_) helpful.

func countChar(str: String, char: Character) -> Int {
    return str.count(of: char)
}

// -----------------------------------------------------------------------------
// 1.1.7
// -----------------------------------------------------------------------------
// Write a function that takes a string as input and returns the number of
// times that a particular character appears in the string.
// For example, given the input "apple", your function should return 2.
// Hint: you may find the built-in string method count(of:_) helpful.

func countChar(str: String, char: Character) -> Int {
    return str.count(of: char)
}
return str.count(of: char) // cannot call value of non-function type 'Int'

func carRaceCollision(n: Int) -> Int {
    var leftToRight = 0
    var rightToLeft = 0
    for i in 1...n {
        leftToRight += i
        rightToLeft += n - i + 1
    }
    return leftToRight * rightToLeft
}

import Foundation
```swift
// Imagine a road that's a perfectly straight infinitely long line.
// n cars are driving left to right;  simultaneously, a different set of n cars
// are driving right to left.   The two sets of cars start out being very far from
// each other.  All cars move in the same speed.  Two cars are said to collide
// when a car that's moving left to right hits a car that's moving right to left.
// However, the cars are infinitely sturdy and strong; as a result, they continue moving
// in their trajectory as if they did not collide.
// This function outputs the number of such collisions.
func carRaceCollision(n: Int) -> Int {
    var leftToRight = 0
    var rightToLeft = 0
    for i in 1...n {
        leftToRight += i
        rightToLeft += n - i + 1
    }
    return leftToRight * rightToLeft
}

print(carRaceCollision(3))<|endoftext|>//
//  main.swift
//  100DaysOfSwift
//
//  Created by 윤선우 on 2022/04/02.
//

import Foundation

var nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

var sum = 0

for num in nums {
    sum += num
}

print(sum)<|endoftext|>//
//  main.swift
//  100DaysOfSwift
//
//  Created by 윤선우 on 2022/04/02.
//

import Foundation

var nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

var sum = 0

for num in nums {
    if num % 2 == 0 {
        sum += num
    }
}

print(sum)<|endoftext|>//
//  main.swift
//  100DaysOfSwift
//
//  Created by 윤선우 on 2022/04/02.
//

import Foundation

var nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

var sum = 0

for num in nums {
    if num % 2 == 0 {
        sum += num
    } else {
        sum -= num
    }
}

print(sum)<|endoftext|>//
//  main.swift
//  100DaysOfSwift
//
//  Created by 윤선우 on 2022/04/02.
//

import Foundation

var nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

var sum = 0

for num in nums {
    if num % 2 == 0 {
        sum += num
    } else {
        sum -= num
    }
}

print(sum)<|endoftext|>//
//  main.swift
//  100DaysOfSwift
//
//  Created by 윤선우 on 2022/04/02.
//

import Foundation

var nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

var sum = 0

for num in nums {
    if num % 2 == 0 {
        sum += num
    } else {
        sum -= num
    }
}

print(sum)<|endoftext|>//
//  main.swift
//  100DaysOfSwift
//
//  Created by 윤선우 on 2022/04/02.
//

import Foundation

var nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

var sum = 0

for num in nums {
    if num % 2 == 0 {
        sum += num
    } else {
        sum -= num
    }
}

print(sum)<|endoftext|>//
//  main.swift
//  100DaysOfSwift
//
//  Created by 윤선우 on 2022/04/02.
//

import Foundation

var nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 
 // XCTAssertTrue failed

func carRaceCollision(n: Int) -> Int {
    var result = 0
    for i in 1...n {
        for j in 1...n {
            if i < j {
                result += 1
            }
        }
    }
    return result
}

func reverseString(s: String) -> String {
    return String(s.reversed())
}

func twoSum(nums: [Int], target: Int) -> [Int] {
    var result = [Int]()
    for i in 0..<nums.count {
        for j in 0..<nums.count {
            if i != j {
                if nums[i] + nums[j] == target {
                    result.append(i)
                    result.append(j)
                    return result
                }
            }
        }
    }
    return result
}

func containsDuplicate(nums: [Int]) -> Bool {
    var result = false
    for i in 0..<nums.count {
        for j in 0..<nums.count {
            if i != j {
                if nums[i] == nums[j] {
                    result = true
                }
            }
        }
    }
    return result
}
```swift
// Imagine a road that's a perfectly straight infinitely long line.
// n cars are driving left to right;  simultaneously, a different set of n cars
// are driving right to left.   The two sets of cars start out being very far from
// each other.  All cars move in the same speed.  Two cars are said to collide
// when a car that's moving left to right hits a car that's moving right to left.
// However, the cars are infinitely sturdy and strong; as a result, they continue moving
// in their trajectory as if they did not collide.
// This function outputs the number of such collisions.
func carRaceCollision(n: Int) -> Int {
    var result = 0
    for i in 1...n {
        for j in 1...n {
            if i < j {
                result += 1
            }
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.1.2
// -----------------------------------------------------------------------------
// Write a function that takes a string as input and returns the string reversed.
// Example:
// Given s = "hello", return "olleh".
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// -----------------------------------------------------------------------------
// 1.1.3
// -----------------------------------------------------------------------------
// Given an array of integers, return indices of the two numbers such that they add up to a specific target.
// You may assume that each input would have exactly one solution, and you may not use the same element twice.
// Example:
// Given nums = [2, 7, 11, 15], target = 9,
// Because nums[0] + nums[1] = 2 + 7 = 9,
// return [0, 1].
func twoSum(nums: [Int], target: Int) -> [Int] {
    var result = [Int]()
    for i in 0..<nums.count {
        for j in 0..<nums.count {
            if i != j {
                if nums[i] + nums[j] == target {
                    result.append(i)
                    result.append(j)
                    return result
                }
            }
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.1.4
// -----------------------------------------------------------------------------
// Given an array of integers, find if the array contains any duplicates.
// Your function should return true if any value appears at least twice in the array,
// and it should return false if every element is distinct.
func containsDuplicate(nums: [Int]) -> Bool {
    var result = false
    for i in 0..<nums.count {
        for j in 0..<nums.count {
            if i != j {
                if nums[i] == nums[j] {
                    result = true
                }
            }
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.1.5
// -----------------------------------------------------------------------------
// Given an array of integers, return indices of the two numbers such that they add up to a specific target.
// You may assume that each input would have exactly one solution, and you may not use the same element twice.
// Example:
// Given nums = [2, 7, 11, 15], target = 9,
// Because nums[0] + nums[1] = 2 + 7 = 9,
// return [0, 1].
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ------------------------------------------------------
 // XCTAssertTrue failed

func carRaceCollision(n: Int) -> Int {
    var result = 0
    for i in 1..<n {
        for j in 1..<n {
            if i != j {
                result += 1
            }
        }
    }
    return result
}

func sumNumbers(s: String) -> Int {
    var result = 0
    var i = 0
    var j = 0
    while i < s.length {
        while j < s.length && s[j] != " " {
            j += 1
        }
        var num = 0
        while i < s.length && s[i] != " " {
            num = num * 10 + Int(s[i]) - 48
            i += 1
        }
        result += num
        i += 1
        j += 1
    }
    return result
}
```swift
// Imagine a road that's a perfectly straight infinitely long line.
// n cars are driving left to right;  simultaneously, a different set of n cars
// are driving right to left.   The two sets of cars start out being very far from
// each other.  All cars move in the same speed.  Two cars are said to collide
// when a car that's moving left to right hits a car that's moving right to left.
// However, the cars are infinitely sturdy and strong; as a result, they continue moving
// in their trajectory as if they did not collide.
// This function outputs the number of such collisions.
func carRaceCollision(n: Int) -> Int {
    var result = 0
    for i in 1..<n {
        for j in 1..<n {
            if i != j {
                result += 1
            }
        }
    }
    return result
}

// 2. Given a string, return the sum of the numbers appearing in the string, ignoring all other characters.
// A number is a series of 1 or more digit chars in a row.
// (Note: Character.isDigit(char) tests if a char is one of the chars '0', '1', .. '9'.  Integer.parseInt(string) converts a string to an int.)
//
// Example:
// Input: "abc123xyz"
// Output: 123
//
// Hint:
// Use two pointers: one to find the start of the next number, and one to find the end of the next number.
//
// Example:
// Input: "aa11b33"
// Output: 4
//
// Hint:
// Use two pointers: one to find the start of the next number, and one to find the end of the next number.
//
// Example:
// Input: "7 11"
// Output: 18
//
// Hint:
// Use two pointers: one to find the start of the next number, and one to find the end of the next number.
//
// Example:
// Input: "a"
// Output: 0
//
// Hint:
// Use two pointers: one to find the start of the next number, and one to find the end of the next number.

func sumNumbers(s: String) -> Int {
    var result = 0
    var i = 0
    var j = 0
    while i < s.length {
        while j < s.length && s[j] != " " {
            j += 1
        }
        var num = 0
        while i < s.length && s[i] != " " {
            num = num * 10 + Int(s[i]) - 48
            i += 1
        }
        result += num
        i += 1
        j += 1
    }
    return result
}

// 3. Given a string, return the sum of the numbers appearing in the string, ignoring all other characters.
// A number is a series of 1 or more digit chars in a row.
// (Note: Character.isDigit(char) tests if a char is one of the chars '0', '1', .. '9'.  Integer.parseInt(string) converts a string to an int.)
//
// Example:
// Input: "abc123xyz"
// Output: 123
//
// Hint:
// Use two pointers: one to find the start of the next number, and one to find the end of the next number.
//
// Example:
// Input: "aa11b33"
// Output: 4
//
// Hint:
// Use two pointers: one to find the start of the next number, and one to find the end of the next number.
//
// Example:
// Input: "7 11"
// Output: 18
//
// Hint:
// Use two pointers: one to find the start of the next number, and one to find the end of the next number.
//
// Example:
// Input: "a"
// Output: 0
//
// Hint:
// Use two pointers: one to find the start of the next number, and one to find the end of the next number.

func sumNumbers(s: String) -> Int {
    var result = 0
    var i = 0
    var j = 0
    while i < s.length {
        while j < s.length && s[j] != " " {
            j += 1
        }
        var num = 0
        while i < s.length && s[i] != " " {
            num = num * 10 + Int(s[i]) - 48
            i += 1
        }
        result += num
        i += 1
        j += 1
    }
    return result
}

// 4
while i < s.length { // value of type 'String' has no member 'length'
while j < s.length && s[j] != " " { // value of type 'String' has no member 'length'
while i < s.length && s[i] != " " { // value of type 'String' has no member 'length'
num = num * 10 + Int(s[i]) - 48 // no exact matches in call to initializer

func incrList(l: [Int]) -> [Int] {
    return l.map { $0 + 1 }
}
```swift
// Return array with elements incremented by 1.
// incrList(l: [1, 2, 3]) == [2, 3, 4]
// incrList(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [6, 4, 6, 3, 4, 4, 10, 1, 124]
func incrList(l: [Int]) -> [Int] {
    return l.map { $0 + 1 }
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// ------

func incrList(l: [Int]) -> [Int] {
    return l.map { $0 + 1 }
}
```swift
// Return array with elements incremented by 1.
// incrList(l: [1, 2, 3]) == [2, 3, 4]
// incrList(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [6, 4, 6, 3, 4, 4, 10, 1, 124]
func incrList(l: [Int]) -> [Int] {
    return l.map { $0 + 1 }
}

// -----------------------------------------------------------------------------
// 1.1.2
//
// Write a function that takes a string and returns a new string with all the
// vowels removed.
//
// For example, removeVowels("I have never seen a thin person drinking Diet Coke.")
// == " hv nvr sn  thn prsn drnkng Dt Ck."
//
// Hint: You can use the characterSetNamed("Vowels") to get a set of all the
// vowels.
//
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.3
//
// Write a function that takes a string and returns a new string with all the
// vowels removed.
//
// For example, removeVowels("I have never seen a thin person drinking Diet Coke.")
// == " hv nvr sn  thn prsn drnkng Dt Ck."
//
// Hint: You can use the characterSetNamed("Vowels") to get a set of all the
// vowels.
//
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.4
//
// Write a function that takes a string and returns a new string with all the
// vowels removed.
//
// For example, removeVowels("I have never seen a thin person drinking Diet Coke.")
// == " hv nvr sn  thn prsn drnkng Dt Ck."
//
// Hint: You can use the characterSetNamed("Vowels") to get a set of all the
// vowels.
//
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.5
//
// Write a function that takes a string and returns a new string with all the
// vowels removed.
//
// For example, removeVowels("I have never seen a thin person drinking Diet Coke.")
// == " hv nvr sn  thn prsn drnkng Dt Ck."
//
// Hint: You can use the characterSetNamed("Vowels") to get a set of all the
// vowels.
//
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.6
//
// Write a function that takes a string and returns a new string with all the
// vowels removed.
//
// For example, removeVowels("I have never seen a thin person drinking Diet Coke.")
// == " hv nvr sn  thn prsn drnkng Dt Ck."
//
// Hint: You can use the characterSetNamed("Vowels") to get a set of all the
// vowels.
//
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.7
//
// Write a function that takes a string and returns a new string with all the
// vowels removed.
//
// For example, removeVowels("I have never seen a thin person drinking Diet Coke.")
// == " hv nvr sn  thn prsn drnkng Dt Ck."
//
// Hint: You can use the characterSetNamed("V

func incrList(l: [Int]) -> [Int] {
    return l.map { $0 + 1 }
}
```swift
// Return array with elements incremented by 1.
// incrList(l: [1, 2, 3]) == [2, 3, 4]
// incrList(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [6, 4, 6, 3, 4, 4, 10, 1, 124]
func incrList(l: [Int]) -> [Int] {
    return l.map { $0 + 1 }
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// ---------------------------------------------

func incrList(l: [Int]) -> [Int] {
    return l.map { $0 + 1 }
}
```swift
// Return array with elements incremented by 1.
// incrList(l: [1, 2, 3]) == [2, 3, 4]
// incrList(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [6, 4, 6, 3, 4, 4, 10, 1, 124]
func incrList(l: [Int]) -> [Int] {
    return l.map { $0 + 1 }
}

// -----------------------------------------------------------------------------
// 1.2.1.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.

func incrList(l: [Int]) -> [Int] {
    return l.map { $0 + 1 }
}
```swift
// Return array with elements incremented by 1.
// incrList(l: [1, 2, 3]) == [2, 3, 4]
// incrList(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [6, 4, 6, 3, 4, 4, 10, 1, 124]
func incrList(l: [Int]) -> [Int] {
    return l.map { $0 + 1 }
}

// -----------------------------------------------------------------------------
// 1.10.2.2.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1

func incrList(l: [Int]) -> [Int] {
    var result = l
    for i in 0..<l.count {
        result[i] = l[i] + 1
    }
    return result
}
```swift
// Return array with elements incremented by 1.
// incrList(l: [1, 2, 3]) == [2, 3, 4]
// incrList(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [6, 4, 6, 3, 4, 4, 10, 1, 124]
func incrList(l: [Int]) -> [Int] {
    var result = l
    for i in 0..<l.count {
        result[i] = l[i] + 1
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ---------------------------

func incrList(l: [Int]) -> [Int] {
    return l.map { $0 + 1 }
}
```swift
// Return array with elements incremented by 1.
// incrList(l: [1, 2, 3]) == [2, 3, 4]
// incrList(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [6, 4, 6, 3, 4, 4, 10, 1, 124]
func incrList(l: [Int]) -> [Int] {
    return l.map { $0 + 1 }
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ------------------------

func incrList(l: [Int]) -> [Int] {
    return l.map { $0 + 1 }
}
```swift
// Return array with elements incremented by 1.
// incrList(l: [1, 2, 3]) == [2, 3, 4]
// incrList(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [6, 4, 6, 3, 4, 4, 10, 1, 124]
func incrList(l: [Int]) -> [Int] {
    return l.map { $0 + 1 }
}

// -----------------------------------------------------------------------------
// MARK: - 1.3.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.2.

func incrList(l: [Int]) -> [Int] {
    return l.map { $0 + 1 }
}
```swift
// Return array with elements incremented by 1.
// incrList(l: [1, 2, 3]) == [2, 3, 4]
// incrList(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [6, 4, 6, 3, 4, 4, 10, 1, 124]
func incrList(l: [Int]) -> [Int] {
    return l.map { $0 + 1 }
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ------------------------

func incrList(l: [Int]) -> [Int] {
    return l.map { $0 + 1 }
}
```swift
// Return array with elements incremented by 1.
// incrList(l: [1, 2, 3]) == [2, 3, 4]
// incrList(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [6, 4, 6, 3, 4, 4, 10, 1, 124]
func incrList(l: [Int]) -> [Int] {
    return l.map { $0 + 1 }
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ------------------------

func pairsSumToZero(l: [Int]) -> Bool {
    var count = 0
    for i in l {
        if l.contains(i * -1) {
            count += 1
        }
    }
    return count > 1
}
```swift
// pairs_sum_to_zero takes an array of integers as an input.
// it returns true if there are two distinct elements in the array that
// sum to zero, and false otherwise.
// pairsSumToZero(l: [1, 3, 5, 0]) == false
// pairsSumToZero(l: [1, 3, -2, 1]) == false
// pairsSumToZero(l: [1, 2, 3, 7]) == false
// pairsSumToZero(l: [2, 4, -5, 3, 5, 7]) == true
// pairsSumToZero(l: [1]) == false
func pairsSumToZero(l: [Int]) -> Bool {
    var count = 0
    for i in l {
        if l.contains(i * -1) {
            count += 1
        }
    }
    return count > 1
}

// -----------------------------------------------------------------------------
// 1.1
// -----------------------------------------------------------------------------
// Given an array of integers, return a new array such that each element at
// index i of the new array is the product of all the numbers in the original
// array except the one at i.
//
// For example, if our input was [1, 2, 3, 4, 5], the expected output would be
// [120, 60, 40, 30, 24]. If our input was [3, 2, 1], the expected output would
// be [2, 3, 6].
//
// Follow-up: what if you can't use division?
//
// -----------------------------------------------------------------------------
// 1.1
// -----------------------------------------------------------------------------
// Given an array of integers, return a new array such that each element at
// index i of the new array is the product of all the numbers in the original
// array except the one at i.
//
// For example, if our input was [1, 2, 3, 4, 5], the expected output would be
// [120, 60, 40, 30, 24]. If our input was [3, 2, 1], the expected output would
// be [2, 3, 6].
//
// Follow-up: what if you can't use division?
//
// -----------------------------------------------------------------------------
// 1.1
// -----------------------------------------------------------------------------
// Given an array of integers, return a new array such that each element at
// index i of the new array is the product of all the numbers in the original
// array except the one at i.
//
// For example, if our input was [1, 2, 3, 4, 5], the expected output would be
// [120, 60, 40, 30, 24]. If our input was [3, 2, 1], the expected output would
// be [2, 3, 6].
//
// Follow-up: what if you can't use division?
//
// -----------------------------------------------------------------------------
// 1.1
// -----------------------------------------------------------------------------
// Given an array of integers, return a new array such that each element at
// index i of the new array is the product of all the numbers in the original
// array except the one at i.
//
// For example, if our input was [1, 2, 3, 4, 5], the expected output would be
// [120, 60, 40, 30, 24]. If our input was [3, 2, 1], the expected output would
// be [2, 3, 6].
//
// Follow-up: what if you can't use division?
//
// -----------------------------------------------------------------------------
// 1.1
// -----------------------------------------------------------------------------
// Given an array of integers, return a new array such that each element at
// index i of the new array is the product of all the numbers in the original
// array except the one at i.
//
// For example, if our input was

func pairsSumToZero(l: [Int]) -> Bool {
    var count = 0
    for i in l {
        if l.contains(i * -1) {
            count += 1
        }
    }
    return count > 1
}

func countVowels(s: String) -> Int {
    var count = 0
    for i in s {
        if i == "a" || i == "e" || i == "i" || i == "o" || i == "u" {
            count += 1
        }
    }
    return count
}

func countWords(s: String) -> Int {
    var count = 0
    for i in s {
        if i != " " {
            count += 1
        }
    }
    return count
}
```swift
// pairs_sum_to_zero takes an array of integers as an input.
// it returns true if there are two distinct elements in the array that
// sum to zero, and false otherwise.
// pairsSumToZero(l: [1, 3, 5, 0]) == false
// pairsSumToZero(l: [1, 3, -2, 1]) == false
// pairsSumToZero(l: [1, 2, 3, 7]) == false
// pairsSumToZero(l: [2, 4, -5, 3, 5, 7]) == true
// pairsSumToZero(l: [1]) == false
func pairsSumToZero(l: [Int]) -> Bool {
    var count = 0
    for i in l {
        if l.contains(i * -1) {
            count += 1
        }
    }
    return count > 1
}

// 1.1.2
// Write a function that takes a string as an input and returns the number of vowels in the string.
// Vowels are the letters 'a', 'e', 'i', 'o', and 'u'.
// countVowels("apple") == 2
// countVowels("hello world") == 3
// countVowels("h") == 0
// countVowels("") == 0
func countVowels(s: String) -> Int {
    var count = 0
    for i in s {
        if i == "a" || i == "e" || i == "i" || i == "o" || i == "u" {
            count += 1
        }
    }
    return count
}

// 1.1.3
// Write a function that takes a string as an input and returns the number of words in the string.
// A word is defined as a sequence of non-whitespace characters surrounded by whitespace or the beginning or end of the string.
// countWords("Hello world") == 2
// countWords("Hello world!") == 2
// countWords("Hello world!  ") == 2
// countWords("") == 0
// countWords("   ") == 0
func countWords(s: String) -> Int {
    var count = 0
    for i in s {
        if i != " " {
            count += 1
        }
    }
    return count
}

// 1.1.4
// Write a function that takes a string as an input and returns the number of sentences in the string.
// A sentence is defined as a sequence of non-whitespace characters surrounded by whitespace or the beginning or end of the string.
// countSentences("Hello world!") == 1
// countSentences("Hello world!  ") == 1
// countSentences("Hello world!  .") == 1
// countSentences("Hello world!  .  ") == 1
// countSentences("Hello world!  .  .") == 1
// countSentences("Hello world!  .  .  ") == 1
// countSentences("Hello world!  .  .  .") == 1
// countSentences("Hello world!  .  .  .  ") == 1
// countSentences("Hello world!  .  .  .  .") == 1
// countSentences("Hello world!  .  .  .  .  ") == 1
// countSentences("Hello world!  .  .  .  .  .") == 1
// countSentences("Hello world!  .  .  .  .  .  ") == 1
// countSentences("Hello world!  .  .  .  .  .  .") == 1
// countSentences("Hello world!  .  .  .  .  .  .  ") == 1
// countSentences("Hello world!  .  .  .  .  .  .  .") == 1
// countSentences("Hello world!  .  .  .  .  .  .  .  ") == 1
// countSentences("Hello world!  .  .  .  .  .  .  .  .") == 1
// countSentences("Hello world!  .  .  .  .  .  .  .  ..") == 1
// countSentences("Hello world!  .  .  .  .  .  .  .  ...") == 1
// countSentences("Hello world!  .  .  .  .  .  .  .  ....") == 1
// countSentences("Hello world!  .  .  .  .  .  .  .  .....") == 1
// countSentences("Hello world!  .  .  .

func pairsSumToZero(l: [Int]) -> Bool {
    var result = false
    for i in 0..<l.count-1 {
        for j in i+1..<l.count {
            if l[i] + l[j] == 0 {
                result = true
                break
            }
        }
        if result {
            break
        }
    }
    return result
}
```swift
// pairs_sum_to_zero takes an array of integers as an input.
// it returns true if there are two distinct elements in the array that
// sum to zero, and false otherwise.
// pairsSumToZero(l: [1, 3, 5, 0]) == false
// pairsSumToZero(l: [1, 3, -2, 1]) == false
// pairsSumToZero(l: [1, 2, 3, 7]) == false
// pairsSumToZero(l: [2, 4, -5, 3, 5, 7]) == true
// pairsSumToZero(l: [1]) == false
func pairsSumToZero(l: [Int]) -> Bool {
    var result = false
    for i in 0..<l.count-1 {
        for j in i+1..<l.count {
            if l[i] + l[j] == 0 {
                result = true
                break
            }
        }
        if result {
            break
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ------------------------------------------------------------------------

func pairsSumToZero(l: [Int]) -> Bool {
    var seen = Set<Int>()
    for i in l {
        if seen.contains(i * -1) {
            return true
        }
        seen.insert(i)
    }
    return false
}

func isUnivalueList(l: [Int]) -> Bool {
    var seen = Set<Int>()
    for i in l {
        if seen.contains(i) {
            return false
        }
        seen.insert(i)
    }
    return true
}
```swift
// pairs_sum_to_zero takes an array of integers as an input.
// it returns true if there are two distinct elements in the array that
// sum to zero, and false otherwise.
// pairsSumToZero(l: [1, 3, 5, 0]) == false
// pairsSumToZero(l: [1, 3, -2, 1]) == false
// pairsSumToZero(l: [1, 2, 3, 7]) == false
// pairsSumToZero(l: [2, 4, -5, 3, 5, 7]) == true
// pairsSumToZero(l: [1]) == false
func pairsSumToZero(l: [Int]) -> Bool {
    var seen = Set<Int>()
    for i in l {
        if seen.contains(i * -1) {
            return true
        }
        seen.insert(i)
    }
    return false
}

// -----------------------------------------------------------------------------
// 1.1
// -----------------------------------------------------------------------------
// is_univalue_list takes an input list of integers.
// it returns true if the list is univalue (all elements are the same),
// and false otherwise.
// isUnivalueList(l: [1, 1, 1]) == true
// isUnivalueList(l: [1, 2, 1]) == false
// isUnivalueList(l: [1, 1, 2]) == false
// isUnivalueList(l: [1]) == true
// isUnivalueList(l: []) == true
func isUnivalueList(l: [Int]) -> Bool {
    var seen = Set<Int>()
    for i in l {
        if seen.contains(i) {
            return false
        }
        seen.insert(i)
    }
    return true
}

// -----------------------------------------------------------------------------
// 1.2
// -----------------------------------------------------------------------------
// is_linked_list_palindrome takes an input list of integers.
// it returns true if the list is a palindrome, and false otherwise.
// isLinkedListPalindrome(l: [1, 2, 3, 2, 1]) == true
// isLinkedListPalindrome(l: [1, 2, 3, 2, 2]) == false
// isLinkedListPalindrome(l: [1, 2, 3, 3, 2, 1]) == true
// isLinkedListPalindrome(l: [1, 2, 3, 2, 1, 1]) == false
// isLinkedListPalindrome(l: [1, 2, 3, 2, 1, 2]) == false
// isLinkedListPalindrome(l: [1, 2, 3, 2, 1, 2, 1]) == false
// isLinkedListPalindrome(l: [1, 2, 3, 2, 1, 2, 1, 1]) == false
// isLinkedListPalindrome(l: [1, 2, 3, 2, 1, 2, 1, 2]) == false
// isLinkedListPalindrome(l: [1, 2, 3, 2, 1, 2, 1, 2, 1]) == false
// isLinkedListPalindrome(l: [1, 2, 3, 2, 1, 2, 1, 2, 2]) == false
// isLinkedListPalindrome(l: [1, 2, 3, 2, 1, 2, 1, 2, 2, 1]) == false
// isLinkedListPalindrome(l: [1, 2, 3, 2, 1, 2, 1, 2, 2, 2]) == false
// isLinkedListPalindrome(l: [1, 2, 3, 2, 1, 2, 1, 2, 2, 2, 1]) == false
// isLinkedListPalindrome(l: [1, 2, 3, 2, 1, 2, 1, 2, 2, 2, 2]) == false
// isLinkedListPalindrome(l: [1, 2, 3, 2, 1, 2, 1, 2, 2, 2, 2, 1]) == false
// isLinkedListPalindrome(l: [1, 2, 3, 2, 1, 2, 1, 2, 2, 2

func pairsSumToZero(l: [Int]) -> Bool {
    for i in 0..<l.count {
        for j in 0..<l.count {
            if i == j {
                continue
            }
            if l[i] + l[j] == 0 {
                return true
            }
        }
    }
    return false
}
```swift
// pairs_sum_to_zero takes an array of integers as an input.
// it returns true if there are two distinct elements in the array that
// sum to zero, and false otherwise.
// pairsSumToZero(l: [1, 3, 5, 0]) == false
// pairsSumToZero(l: [1, 3, -2, 1]) == false
// pairsSumToZero(l: [1, 2, 3, 7]) == false
// pairsSumToZero(l: [2, 4, -5, 3, 5, 7]) == true
// pairsSumToZero(l: [1]) == false
func pairsSumToZero(l: [Int]) -> Bool {
    for i in 0..<l.count {
        for j in 0..<l.count {
            if i == j {
                continue
            }
            if l[i] + l[j] == 0 {
                return true
            }
        }
    }
    return false
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// ---------------

func pairsSumToZero(l: [Int]) -> Bool {
    var sum = 0
    for i in l {
        if sum == 0 {
            return true
        }
        sum += i
    }
    return false
}

func isUnivalue(l: [Int]) -> Bool {
    var first = l[0]
    for i in l {
        if first != i {
            return false
        }
    }
    return true
}
```swift
// pairs_sum_to_zero takes an array of integers as an input.
// it returns true if there are two distinct elements in the array that
// sum to zero, and false otherwise.
// pairsSumToZero(l: [1, 3, 5, 0]) == false
// pairsSumToZero(l: [1, 3, -2, 1]) == false
// pairsSumToZero(l: [1, 2, 3, 7]) == false
// pairsSumToZero(l: [2, 4, -5, 3, 5, 7]) == true
// pairsSumToZero(l: [1]) == false
func pairsSumToZero(l: [Int]) -> Bool {
    var sum = 0
    for i in l {
        if sum == 0 {
            return true
        }
        sum += i
    }
    return false
}

// -----------------------------------------------------------------------------
// 1.1
// -----------------------------------------------------------------------------

// is_univalue takes an array of integers as an input.
// it returns true if all elements in the array are the same, and false otherwise.
// isUnivalue([1, 1, 1, 1, 1]) == true
// isUnivalue([1, 2, 1, 1, 1]) == false
// isUnivalue([1, 1, 2, 1, 1]) == false
// isUnivalue([1, 1, 1, 2, 1]) == false
// isUnivalue([1, 1, 1, 1]) == true
// isUnivalue([1]) == true
func isUnivalue(l: [Int]) -> Bool {
    var first = l[0]
    for i in l {
        if first != i {
            return false
        }
    }
    return true
}

// -----------------------------------------------------------------------------
// 1.2
// -----------------------------------------------------------------------------

// is_strictly_increasing takes an array of integers as an input.
// it returns true if the array is strictly increasing, and false otherwise.
// isStrictlyIncreasing([1, 2, 3, 4, 5]) == true
// isStrictlyIncreasing([1, 2, 3, 4, 5, 6]) == true
// isStrictlyIncreasing([1, 2, 3, 4, 5, 5]) == false
// isStrictlyIncreasing([1, 2, 3, 4, 5, 4]) == false
// isStrictlyIncreasing([1, 2, 3, 4, 5, 4, 3]) == false
// isStrictlyIncreasing([1, 2, 3, 4, 5, 4, 3, 2]) == false
// isStrictlyIncreasing([1, 2, 3, 4, 5, 4, 3, 2, 1]) == false
// isStrictlyIncreasing([1, 2, 3, 4, 5, 4, 3, 2, 1, 0]) == false
// isStrictlyIncreasing([1, 2, 3, 4, 5, 4, 3, 2, 1, 0, -1]) == false
// isStrictlyIncreasing([1, 2, 3, 4, 5, 4, 3, 2, 1, 0, -1, -2]) == false
// isStrictlyIncreasing([1, 2, 3, 4, 5, 4, 3, 2, 1, 0, -1, -2, -3]) == false
// isStrictlyIncreasing([1, 2, 3, 4, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4]) == false
// isStrictlyIncreasing([1, 2, 3, 4, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]) == false
// isStrictlyIncreasing([1, 2, 3, 4, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6]) == false
// isStrictlyIncreasing([1, 2, 3, 4, 5, 4, 3, 2, 1, 0, -1, -2, -3,
var first = l[0] // variable 'first' was never mutated; consider changing to 'let' constant
 // XCTAssertTrue failed

func pairsSumToZero(l: [Int]) -> Bool {
    var count = 0
    for i in l {
        if l.contains(i * -1) {
            count += 1
        }
    }
    return count > 1
}

func sumArray(l: [Int]) -> Int {
    var sum = 0
    for i in l {
        sum += i
    }
    return sum
}

func sumOfEven(l: [Int]) -> Int {
    var sum = 0
    for i in l {
        if i % 2 == 0 {
            sum += i
        }
    }
    return sum
}

func sumOfOdd(l: [Int]) -> Int {
    var sum = 0
    for i in l {
        if i % 2 != 0 {
            sum += i
        }
    }
    return sum
}

func sumOfGreaterThanFive(l: [Int]) -> Int {
    var sum = 0
    for i in l {
        if i > 5 {
            sum += i
        }
    }
    return sum
}
```swift
// pairs_sum_to_zero takes an array of integers as an input.
// it returns true if there are two distinct elements in the array that
// sum to zero, and false otherwise.
// pairsSumToZero(l: [1, 3, 5, 0]) == false
// pairsSumToZero(l: [1, 3, -2, 1]) == false
// pairsSumToZero(l: [1, 2, 3, 7]) == false
// pairsSumToZero(l: [2, 4, -5, 3, 5, 7]) == true
// pairsSumToZero(l: [1]) == false
func pairsSumToZero(l: [Int]) -> Bool {
    var count = 0
    for i in l {
        if l.contains(i * -1) {
            count += 1
        }
    }
    return count > 1
}

// -----------------------------------------------------------------------------
// 2. Write a function that takes an array of integers as an input and returns
// the sum of all the integers in the array.
// sumArray([1, 2, 3, 4, 5]) == 15
// sumArray([-1, 2, 3, 4, 5]) == 12
// sumArray([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55
// sumArray([-1, -2, -3, -4, -5]) == -15
// sumArray([]) == 0
func sumArray(l: [Int]) -> Int {
    var sum = 0
    for i in l {
        sum += i
    }
    return sum
}

// -----------------------------------------------------------------------------
// 3. Write a function that takes an array of integers as an input and returns
// the sum of all the even integers in the array.
// sumOfEven([1, 2, 3, 4, 5]) == 6
// sumOfEven([-1, 2, 3, 4, 5]) == 6
// sumOfEven([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 30
// sumOfEven([-1, -2, -3, -4, -5]) == 0
// sumOfEven([]) == 0
func sumOfEven(l: [Int]) -> Int {
    var sum = 0
    for i in l {
        if i % 2 == 0 {
            sum += i
        }
    }
    return sum
}

// -----------------------------------------------------------------------------
// 4. Write a function that takes an array of integers as an input and returns
// the sum of all the odd integers in the array.
// sumOfOdd([1, 2, 3, 4, 5]) == 9
// sumOfOdd([-1, 2, 3, 4, 5]) == 9
// sumOfOdd([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 25
// sumOfOdd([-1, -2, -3, -4, -5]) == 0
// sumOfOdd([]) == 0
func sumOfOdd(l: [Int]) -> Int {
    var sum = 0
    for i in l {
        if i % 2 != 0 {
            sum += i
        }
    }
    return sum
}

// -----------------------------------------------------------------------------
// 5. Write a function that takes an array of integers as an input and returns
// the sum of all the integers in the array that are greater than 5.
// sumOfGreaterThanFive([1, 2, 3, 4, 5]) == 15
// sumOfGreaterThanFive([-1, 2, 3, 4, 5]) == 15
// sumOfGreaterThanFive([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 30
// sumOfGreaterThanFive([-1, -2, -3, -4, -5]) == 0
// sumOfGreaterThanFive([]) == 0
func sumOfGreaterThanFive(l: [Int]) -> Int {
    var sum = 0
    for i in l {
        if i > 5 {
            sum += i
        }
    }
    return sum
}

func pairsSumToZero(l: [Int]) -> Bool {
    var result = false
    for i in 0..<l.count-1 {
        for j in i+1..<l.count {
            if l[i] + l[j] == 0 {
                result = true
                break
            }
        }
        if result {
            break
        }
    }
    return result
}
```swift
// pairs_sum_to_zero takes an array of integers as an input.
// it returns true if there are two distinct elements in the array that
// sum to zero, and false otherwise.
// pairsSumToZero(l: [1, 3, 5, 0]) == false
// pairsSumToZero(l: [1, 3, -2, 1]) == false
// pairsSumToZero(l: [1, 2, 3, 7]) == false
// pairsSumToZero(l: [2, 4, -5, 3, 5, 7]) == true
// pairsSumToZero(l: [1]) == false
func pairsSumToZero(l: [Int]) -> Bool {
    var result = false
    for i in 0..<l.count-1 {
        for j in i+1..<l.count {
            if l[i] + l[j] == 0 {
                result = true
                break
            }
        }
        if result {
            break
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.2
// -----------------------------------------------------------------------------
// Write a function that takes a string as an input and returns the number of
// times each letter appears in the string.
// countLetters("hello") == {"h": 1, "e": 1, "l": 2, "o": 1}
// countLetters("") == {"": 1}
// countLetters("a") == {"a": 1}
// countLetters("aa") == {"a": 2}
// countLetters("aab") == {"a": 2, "b": 1}
// countLetters("aabb") == {"a": 2, "b": 2}
// countLetters("aabbcc") == {"a": 2, "b": 2, "c": 2}
// countLetters("aabbccddee") == {"a": 2, "b": 2, "c": 2, "d": 2, "e": 2}
// countLetters("aabbccddeeff") == {"a": 2, "b": 2, "c": 2, "d": 2, "e": 2, "f": 1}
// countLetters("aabbccddeeffg") == {"a": 2, "b": 2, "c": 2, "d": 2, "e": 2, "f": 1, "g": 1}
// countLetters("aabbccddeeffgg") == {"a": 2, "b": 2, "c": 2, "d": 2, "e": 2, "f": 1, "g": 2}
// countLetters("aabbccddeeffggh") == {"a": 2, "b": 2, "c": 2, "d": 2, "e": 2, "f": 1, "g": 2, "h": 1}
// countLetters("aabbccddeeffggghi") == {"a": 2, "b": 2, "c": 2, "d": 2, "e": 2, "f": 1, "g": 2, "h": 1, "i": 1}
// countLetters("aabbccddeeffggghiij") == {"a": 2, "b": 2, "c": 2, "d": 2, "e": 2, "f": 1, "g": 2, "h": 1, "i": 2, "j": 1}
// countLetters("aabbccddeeffggghiijj") == {"a": 2, "b": 2, "c": 2, "d": 2, "e": 2, "f": 1, "g": 2, "h": 1, "i": 2, "j": 2, "k": 1}
// countLetters("aabbccddeeffggghiijjk") == {"a": 2, "b": 2, "c": 2, "d": 2, "e": 2, "f": 1, "g": 2, "h": 1, "i": 2, "j": 2, "k": 2, "l": 1}
// countLetters("aabbccddeeffggghiijjkk" == {"a": 2, "b": 2, "c": 2, "d": 2, "e": 2,

func pairsSumToZero(l: [Int]) -> Bool {
    var seen = Set<Int>()
    for num in l {
        if seen.contains(num * -1) {
            return true
        }
        seen.insert(num)
    }
    return false
}
```swift
// pairs_sum_to_zero takes an array of integers as an input.
// it returns true if there are two distinct elements in the array that
// sum to zero, and false otherwise.
// pairsSumToZero(l: [1, 3, 5, 0]) == false
// pairsSumToZero(l: [1, 3, -2, 1]) == false
// pairsSumToZero(l: [1, 2, 3, 7]) == false
// pairsSumToZero(l: [2, 4, -5, 3, 5, 7]) == true
// pairsSumToZero(l: [1]) == false
func pairsSumToZero(l: [Int]) -> Bool {
    var seen = Set<Int>()
    for num in l {
        if seen.contains(num * -1) {
            return true
        }
        seen.insert(num)
    }
    return false
}

// 1.1
// Given two strings, write a method to decide if one is a permutation of the other.
// permutation(s1: "abcd", s2: "dcba") == true
// permutation(s1: "abcd", s2: "dcbaa") == false
// permutation(s1: "abcd", s2: "dc") == false
// permutation(s1: "abcd", s2: "") == false
// permutation(s1: "abcd", s2: "abc") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
// permutation(s1: "abcd", s2: "abcde") == false
//

func pairsSumToZero(l: [Int]) -> Bool {
    var count = 0
    for i in 0..<l.count {
        for j in 0..<l.count {
            if i == j {
                continue
            }
            if l[i] + l[j] == 0 {
                count += 1
            }
        }
    }
    return count > 0
}
```swift
// pairs_sum_to_zero takes an array of integers as an input.
// it returns true if there are two distinct elements in the array that
// sum to zero, and false otherwise.
// pairsSumToZero(l: [1, 3, 5, 0]) == false
// pairsSumToZero(l: [1, 3, -2, 1]) == false
// pairsSumToZero(l: [1, 2, 3, 7]) == false
// pairsSumToZero(l: [2, 4, -5, 3, 5, 7]) == true
// pairsSumToZero(l: [1]) == false
func pairsSumToZero(l: [Int]) -> Bool {
    var count = 0
    for i in 0..<l.count {
        for j in 0..<l.count {
            if i == j {
                continue
            }
            if l[i] + l[j] == 0 {
                count += 1
            }
        }
    }
    return count > 0
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ---------------------------------------------------------------------

func changeBase(x: Int, base: Int) -> String {
    var result = ""
    var remainder = x
    while remainder > 0 {
        result = String(remainder % base) + result
        remainder = remainder / base
    }
    return result
}

func reverseString(s: String) -> String {
    return String(s.reversed())
}

func countBits(n: Int) -> Int {
    var count = 0
    while n > 0 {
        if n % 2 == 1 {
            count += 1
        }
        n = n / 2
    }
    return count
}

func countSetBits(n: Int) -> Int {
    var count = 0
    while n > 0 {
        if n % 2 == 1 {
            count += 1
        }
        n = n / 2
    }
    return count
}
```swift
// Change numerical base of input number x to base.
// return string representation after the conversion.
// base numbers are less than 10.
// changeBase(x: 8, base: 3) == "22"
// changeBase(x: 8, base: 2) == "1000"
// changeBase(x: 7, base: 2) == "111"
func changeBase(x: Int, base: Int) -> String {
    var result = ""
    var remainder = x
    while remainder > 0 {
        result = String(remainder % base) + result
        remainder = remainder / base
    }
    return result
}

// 2.
// Write a function that takes a string as input and returns the string reversed.
// reverseString("hello") == "olleh"
// reverseString("Greetings from Earth") == "htraE morf sgniteerG"
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// 3.
// Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number.
// Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case
// countBits(1234) == 5
func countBits(n: Int) -> Int {
    var count = 0
    while n > 0 {
        if n % 2 == 1 {
            count += 1
        }
        n = n / 2
    }
    return count
}

// 4.
// Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number, ignoring the most significant bit (the sign bit).
// Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case
// countSetBits(1234) == 5
func countSetBits(n: Int) -> Int {
    var count = 0
    while n > 0 {
        if n % 2 == 1 {
            count += 1
        }
        n = n / 2
    }
    return count
}

// 5.
// Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number, ignoring the most significant bit (the sign bit).
// Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case
// countSetBits(1234) == 5
func countSetBits(n: Int) -> Int {
    var count = 0
    while n > 0 {
        if n % 2 == 1 {
            count += 1
        }
        n = n / 2
    }
    return count
}

// 6.
// Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number, ignoring the most significant bit (the sign bit).
// Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case
// countSetBits(1234) == 5
func countSetBits(n: Int) -> Int {
    var count = 0
    while n > 0 {
        if n % 2 == 1 {
            count += 1
        }
        n = n / 2
    }
    return count
}

// 7.
// Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number, ignoring the most significant bit (the sign bit).
// Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case
// countSetBits(1234) == 5
func countSetBits(n: Int) -> Int {
    var count = 0
    while n > 0 {
        if n % 2 == 1 {
            count += 1
        }
        n = n / 2
    }
    return count
}

// 8.
// Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number, ignoring the most significant bit (the sign bit).
// Example: The binary representation of 1234 is 10011010010, so the
n = n / 2 // cannot assign to value: 'n' is a 'let' constant
n = n / 2 // cannot assign to value: 'n' is a 'let' constant

func changeBase(x: Int, base: Int) -> String {
    var result = ""
    while x > 0 {
        result = String(x % base) + result
        x /= base
    }
    return result
}

func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}
```swift
// Change numerical base of input number x to base.
// return string representation after the conversion.
// base numbers are less than 10.
// changeBase(x: 8, base: 3) == "22"
// changeBase(x: 8, base: 2) == "1000"
// changeBase(x: 7, base: 2) == "111"
func changeBase(x: Int, base: Int) -> String {
    var result = ""
    while x > 0 {
        result = String(x % base) + result
        x /= base
    }
    return result
}

// 1.2
// Write a function that takes a string and returns a string with all the vowels removed.
// removeVowels("I have never seen a thin person drinking Diet Coke on a scale.") == " hv nvr sn  thn prnng Dt Ck n  scl."
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// 1.3
// Write a function that takes a string and returns a string with all the vowels removed.
// removeVowels("I have never seen a thin person drinking Diet Coke on a scale.") == " hv nvr sn  thn prnng Dt Ck n  scl."
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// 1.4
// Write a function that takes a string and returns a string with all the vowels removed.
// removeVowels("I have never seen a thin person drinking Diet Coke on a scale.") == " hv nvr sn  thn prnng Dt Ck n  scl."
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// 1.5
// Write a function that takes a string and returns a string with all the vowels removed.
// removeVowels("I have never seen a thin person drinking Diet Coke on a scale.") == " hv nvr sn  thn prnng Dt Ck n  scl."
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// 1.6
// Write a function that takes a string and returns a string with all the vowels removed.
// removeVowels("I have never seen a thin person drinking Diet Coke on a scale.") == " hv nvr sn  thn prnng Dt Ck n  scl."
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// 1.7
// Write a function that takes a string and returns a string with all the vowels removed.
// removeVowels("I have never seen a thin person drinking Diet Coke on a scale.") == " hv nvr sn  thn prnng Dt Ck n  scl."
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// 1.8
// Write a function that takes a string and returns a string with all the vowels removed.
// removeVowels("I have never seen a thin person drinking Diet Coke on a scale.") == " hv nvr sn  thn prnng Dt Ck n  scl."
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// 1.9
// Write a function that takes a string and returns a string with all the vowels removed.
// removeVowels("I have never seen a thin person drinking Diet Coke on a scale.") == " hv nvr sn
x /= base // left side of mutating operator isn't mutable: 'x' is a 'let' constant
if !isVowel(char) { // cannot find 'isVowel' in scope
result += char // cannot convert value of type 'Character' to expected argument type 'String'

func changeBase(x: Int, base: Int) -> String {
    var result = ""
    var current = x
    while current > 0 {
        result = String(current % base) + result
        current /= base
    }
    return result
}

func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}
```swift
// Change numerical base of input number x to base.
// return string representation after the conversion.
// base numbers are less than 10.
// changeBase(x: 8, base: 3) == "22"
// changeBase(x: 8, base: 2) == "1000"
// changeBase(x: 7, base: 2) == "111"
func changeBase(x: Int, base: Int) -> String {
    var result = ""
    var current = x
    while current > 0 {
        result = String(current % base) + result
        current /= base
    }
    return result
}

// 1.10
// Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels("I am a student") == " m  stdn"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// 1.11
// Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels("I am a student") == " m  stdn"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// 1.12
// Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels("I am a student") == " m  stdn"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// 1.13
// Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels("I am a student") == " m  stdn"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// 1.14
// Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels("I am a student") == " m  stdn"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// 1.15
// Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels("I am a student") == " m  stdn"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// 1.16
// Write a function that takes a string and returns a new string with all the vowels removed.
// removeVowels("I am a student") == " m  stdn"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// 1.17
//
result += char // cannot convert value of type 'Character' to expected argument type 'String'

func changeBase(x: Int, base: Int) -> String {
    var result = ""
    while x > 0 {
        result = String(x % base) + result
        x /= base
    }
    return result
}

func reverseString(s: String) -> String {
    return String(s.reversed())
}

func countBits(n: Int) -> Int {
    var result = 0
    while n > 0 {
        result += n & 1
        n >>= 1
    }
    return result
}
```swift
// Change numerical base of input number x to base.
// return string representation after the conversion.
// base numbers are less than 10.
// changeBase(x: 8, base: 3) == "22"
// changeBase(x: 8, base: 2) == "1000"
// changeBase(x: 7, base: 2) == "111"
func changeBase(x: Int, base: Int) -> String {
    var result = ""
    while x > 0 {
        result = String(x % base) + result
        x /= base
    }
    return result
}

// 1.1.2
// Write a function that takes a string as input and returns the string reversed.
// reverseString("hello") == "olleh"
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// 1.1.3
// Write a function that takes an integer as input and returns the number of bits that are equal to one in the binary representation of that number.
// Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case
// countBits(1234) == 5
func countBits(n: Int) -> Int {
    var result = 0
    while n > 0 {
        result += n & 1
        n >>= 1
    }
    return result
}

// 1.1.4
// Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number.
// Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case
// countBits(1234) == 5
func countBits(n: Int) -> Int {
    var result = 0
    while n > 0 {
        result += n & 1
        n >>= 1
    }
    return result
}

// 1.1.5
// Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number.
// Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case
// countBits(1234) == 5
func countBits(n: Int) -> Int {
    var result = 0
    while n > 0 {
        result += n & 1
        n >>= 1
    }
    return result
}

// 1.1.6
// Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number.
// Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case
// countBits(1234) == 5
func countBits(n: Int) -> Int {
    var result = 0
    while n > 0 {
        result += n & 1
        n >>= 1
    }
    return result
}

// 1.1.7
// Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number.
// Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case
// countBits(1234) == 5
func countBits(n: Int) -> Int {
    var result = 0
    while n > 0 {
        result += n & 1
        n >>= 1
    }
    return result
}

// 1.1.8
// Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number.
// Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case
// countBits(1234) == 5
func countBits(n: Int) -> Int {
    var result = 0
    while n > 0 {
        result += n & 1
        n >>= 1
    }
    return result
}

// 1.1.9
// Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number.
// Example: The binary representation of 1234 is 10011010010, so the function should return
x /= base // left side of mutating operator isn't mutable: 'x' is a 'let' constant
n >>= 1 // left side of mutating operator isn't mutable: 'n' is a 'let' constant

func changeBase(x: Int, base: Int) -> String {
    var result = ""
    var current = x
    while current > 0 {
        result = String(current % base) + result
        current /= base
    }
    return result
}

func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}
```swift
// Change numerical base of input number x to base.
// return string representation after the conversion.
// base numbers are less than 10.
// changeBase(x: 8, base: 3) == "22"
// changeBase(x: 8, base: 2) == "1000"
// changeBase(x: 7, base: 2) == "111"
func changeBase(x: Int, base: Int) -> String {
    var result = ""
    var current = x
    while current > 0 {
        result = String(current % base) + result
        current /= base
    }
    return result
}

// 2.
// Given a string, return the string with all the vowels removed.
// removeVowels("I love coding") == " lvcdng"
// removeVowels("Hello world") == "Hll wrld"
// removeVowels("I love coding") == " lvcdng"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// 3.
// Given a string, return the string with all the vowels removed.
// removeVowels("I love coding") == " lvcdng"
// removeVowels("Hello world") == "Hll wrld"
// removeVowels("I love coding") == " lvcdng"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// 4.
// Given a string, return the string with all the vowels removed.
// removeVowels("I love coding") == " lvcdng"
// removeVowels("Hello world") == "Hll wrld"
// removeVowels("I love coding") == " lvcdng"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// 5.
// Given a string, return the string with all the vowels removed.
// removeVowels("I love coding") == " lvcdng"
// removeVowels("Hello world") == "Hll wrld"
// removeVowels("I love coding") == " lvcdng"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// 6.
// Given a string, return the string with all the vowels removed.
// removeVowels("I love coding") == " lvcdng"
// removeVowels("Hello world") == "Hll wrld"
// removeVowels("I love coding") == " lvcdng"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// 7.
// Given a string, return the string with all the vowels removed.
// removeVowels("I love coding") == " lvcdng"
// removeVowels("Hello world") == "Hll wrld"
// removeVowels("I love coding") == " lvcdng"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char != "a" && char != "e" && char !
result += char // cannot convert value of type 'Character' to expected argument type 'String'

func changeBase(x: Int, base: Int) -> String {
    var result = ""
    var remainder = x
    while remainder > 0 {
        result = String(remainder % base) + result
        remainder /= base
    }
    return result
}
```swift
// Change numerical base of input number x to base.
// return string representation after the conversion.
// base numbers are less than 10.
// changeBase(x: 8, base: 3) == "22"
// changeBase(x: 8, base: 2) == "1000"
// changeBase(x: 7, base: 2) == "111"
func changeBase(x: Int, base: Int) -> String {
    var result = ""
    var remainder = x
    while remainder > 0 {
        result = String(remainder % base) + result
        remainder /= base
    }
    return result
}

// 1.10
// 1.11
// 1.12
// 1.13
// 1.14
// 1.15
// 1.16
// 1.17
// 1.18
// 1.19
// 1.20
// 1.21
// 1.22
// 1.23
// 1.24
// 1.25
// 1.26
// 1.27
// 1.28
// 1.29
// 1.30
// 1.31
// 1.32
// 1.33
// 1.34
// 1.35
// 1.36
// 1.37
// 1.38
// 1.39
// 1.40
// 1.41
// 1.42
// 1.43
// 1.44
// 1.45
// 1.46
// 1.47
// 1.48
// 1.49
// 1.50
// 1.51
// 1.52
// 1.53
// 1.54
// 1.55
// 1.56
// 1.57
// 1.58
// 1.59
// 1.60
// 1.61
// 1.62
// 1.63
// 1.64
// 1.65
// 1.66
// 1.67
// 1.68
// 1.69
// 1.70
// 1.71
// 1.72
// 1.73
// 1.74
// 1.75
// 1.76
// 1.77
// 1.78
// 1.79
// 1.80
// 1.81
// 1.82
// 1.83
// 1.84
// 1.85
// 1.86
// 1.87
// 1.88
// 1.89
// 1.90
// 1.91
// 1.92
// 1.93
// 1.94
// 1.95
// 1.96
// 1.97
// 1.98
// 1.99
// 2.00
// 2.01
// 2.02
// 2.03
// 2.04
// 2.05
// 2.06
// 2.07
// 2.08
// 2.09
// 2.10
// 2.11
// 2.12
// 2.13
// 2.14
// 2.15
// 2.16
// 2.17
// 2.18
// 2.19
// 2.20
// 2.21
// 2.22
// 2.23
// 2.24
// 2.25
// 2.26
// 2.27
// 2.28
// 2.29
// 2.30
// 2.31
// 2.32
// 2.33
// 2.34
// 2.35
// 2.36
// 2.37
// 2.38
// 2.39
// 2.40
// 2.41
// 2.42
// 2.43
// 2.44
// 2.45
// 2.46
// 2.47
// 2.

func changeBase(x: Int, base: Int) -> String {
    var result = ""
    var remainder = x
    while remainder > 0 {
        result = String(remainder % base) + result
        remainder /= base
    }
    return result
}
```swift
// Change numerical base of input number x to base.
// return string representation after the conversion.
// base numbers are less than 10.
// changeBase(x: 8, base: 3) == "22"
// changeBase(x: 8, base: 2) == "1000"
// changeBase(x: 7, base: 2) == "111"
func changeBase(x: Int, base: Int) -> String {
    var result = ""
    var remainder = x
    while remainder > 0 {
        result = String(remainder % base) + result
        remainder /= base
    }
    return result
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ------------------------------------------------------------------------

func changeBase(x: Int, base: Int) -> String {
    var result = ""
    while x > 0 {
        result = String(x % base) + result
        x /= base
    }
    return result
}
```swift
// Change numerical base of input number x to base.
// return string representation after the conversion.
// base numbers are less than 10.
// changeBase(x: 8, base: 3) == "22"
// changeBase(x: 8, base: 2) == "1000"
// changeBase(x: 7, base: 2) == "111"
func changeBase(x: Int, base: Int) -> String {
    var result = ""
    while x > 0 {
        result = String(x % base) + result
        x /= base
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ------------------------------
x /= base // left side of mutating operator isn't mutable: 'x' is a 'let' constant

func changeBase(x: Int, base: Int) -> String {
    var result = ""
    var number = x
    while number > 0 {
        result = String(number % base) + result
        number /= base
    }
    return result
}
```swift
// Change numerical base of input number x to base.
// return string representation after the conversion.
// base numbers are less than 10.
// changeBase(x: 8, base: 3) == "22"
// changeBase(x: 8, base: 2) == "1000"
// changeBase(x: 7, base: 2) == "111"
func changeBase(x: Int, base: Int) -> String {
    var result = ""
    var number = x
    while number > 0 {
        result = String(number % base) + result
        number /= base
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// ------------

func changeBase(x: Int, base: Int) -> String {
    var result = ""
    var number = x
    while number > 0 {
        result = String(number % base) + result
        number /= base
    }
    return result
}
```swift
// Change numerical base of input number x to base.
// return string representation after the conversion.
// base numbers are less than 10.
// changeBase(x: 8, base: 3) == "22"
// changeBase(x: 8, base: 2) == "1000"
// changeBase(x: 7, base: 2) == "111"
func changeBase(x: Int, base: Int) -> String {
    var result = ""
    var number = x
    while number > 0 {
        result = String(number % base) + result
        number /= base
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ------------

func triangleArea(a: Int, h: Int) -> Double {
    return a * h / 2
}

func vowelFree(str: String) -> String {
    return str.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "")
}
```swift
// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Int, h: Int) -> Double {
    return a * h / 2
}

// Given a string, return a new string with all the vowels removed.
// vowelFree("apple") == "ppl"
func vowelFree(str: String) -> String {
    return str.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "")
}

// Given a string, return a new string with all the vowels removed.
// vowelFree("apple") == "ppl"
func vowelFree(str: String) -> String {
    return str.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "")
}

// Given a string, return a new string with all the vowels removed.
// vowelFree("apple") == "ppl"
func vowelFree(str: String) -> String {
    return str.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "")
}

// Given a string, return a new string with all the vowels removed.
// vowelFree("apple") == "ppl"
func vowelFree(str: String) -> String {
    return str.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "")
}

// Given a string, return a new string with all the vowels removed.
// vowelFree("apple") == "ppl"
func vowelFree(str: String) -> String {
    return str.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "")
}

// Given a string, return a new string with all the vowels removed.
// vowelFree("apple") == "ppl"
func vowelFree(str: String) -> String {
    return str.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "")
}

// Given a string, return a new string with all the vowels removed.
// vowelFree("apple") == "ppl"
func vowelFree(str: String) -> String {
    return str.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "")
}

// Given a string, return a new string with all the vowels removed.
// vowelFree("apple") == "ppl"
func vowelFree(str: String) -> String {
    return str.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "")
}

// Given a string, return a new string with all the vowels removed.
// vowelFree("apple") == "ppl"
func vowelFree(str: String) -> String {
    return str.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "")
}

// Given a string, return a new string with all the vowels removed.
// vowelFree("apple") == "ppl"
func vowelFree(str: String) -> String {
    return str.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "")
}

//
return a * h / 2 // cannot convert return expression of type 'Int' to return type 'Double'
return str.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "") // cannot use mutating member on immutable value: 'str' is a 'let' constant
return str.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "") // missing argument label 'with:' in call
return str.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "") // value of tuple type '()' has no member 'replace'

func triangleArea(a: Int, h: Int) -> Double {
    return Double(a) * h / 2
}

func changeCase(input: String) -> String {
    return input.map { $0.isUpperCase == true ? $0.toLowerCase() : $0.toUpperCase() }.joined()
}

func doubleArray(array: [Int]) -> [Int] {
    return array.map { $0 * 2 }
}

func multiplyArray(array: [Int]) -> Int {
    return array.reduce(1, { $0 * $1 })
}

func multiplicationTable(number: Int) -> String {
    var result = ""
    for i in 1...10 {
        result += "\(i) * \(number) = \(i * number)\n"
    }
    return result
}

func findOdd(array: [Int]) -> Int {
    return array.filter { $0 % 2 == 1 }.first!
}

func reverseString(input: String) -> String {
    return input.reversed().join()
}
```swift
// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Int, h: Int) -> Double {
    return Double(a) * h / 2
}

// Given a string, return a new string that has transformed based on the input:
// Change case of every character, ie. lower case to upper case, upper case to lower case.
// Reverse the order of words from the input.
// Note: You will have to handle multiple spaces, and leading/trailing spaces.
// For example:
// "Example Input" ==> "iNPUT eXAMPLE"
// "   Hello Case    " ==> "cASE HElLO   "
// "     " ==> ""
// "" ==> ""
func changeCase(input: String) -> String {
    return input.map { $0.isUpperCase == true ? $0.toLowerCase() : $0.toUpperCase() }.joined()
}

// Given an array of integers, return a new array with each value doubled.
// For example:
// [1, 2, 3] ==> [2, 4, 6]
func doubleArray(array: [Int]) -> [Int] {
    return array.map { $0 * 2 }
}

// Given a non-empty array of integers, return the result of multiplying the values together in order.
// For example:
// [1, 2, 3, 4] ==> 1 * 2 * 3 * 4 = 24
func multiplyArray(array: [Int]) -> Int {
    return array.reduce(1, { $0 * $1 })
}

// Your goal is to return multiplication table for number that is always an integer from 1 to 10.
// For example, a multiplication table (string) for number == 5 looks like below:
// 1 * 5 = 5
// 2 * 5 = 10
// 3 * 5 = 15
// 4 * 5 = 20
// 5 * 5 = 25
// 6 * 5 = 30
// 7 * 5 = 35
// 8 * 5 = 40
// 9 * 5 = 45
// 10 * 5 = 50
// P. S. You can use \n in string to jump to the next line.
func multiplicationTable(number: Int) -> String {
    var result = ""
    for i in 1...10 {
        result += "\(i) * \(number) = \(i * number)\n"
    }
    return result
}

// Given an array of integers, find the one that appears an odd number of times.
// There will always be only one integer that appears an odd number of times.
// Examples
// [7] should return 7, because it occurs 1 time (which is odd).
// [0] should return 0, because it occurs 1 time (which is odd).
// [1,1,2] should return 2, because it occurs 1 time (which is odd).
// [0,1,0,1,0] should return 0, because it occurs 3 times (which is odd).
// [1,2,2,3,3,3,4,3,3,3,2,2,1] should return 4, because it appears 1 time (which is odd).
func findOdd(array: [Int]) -> Int {
    return array.filter { $0 % 2 == 1 }.first!
}

// Given a string, return a new string with the reversed order of characters.
// For example:
// "Hi There" ==> "eerht iH"
// "Hi" ==> "iH"
// "" ==> ""
func reverseString(input: String) -> String {
    return input.reversed().join()
}

// Given an array of integers, return a new array with each value doubled.
// For example:
// [1, 2, 3] ==> [2, 4, 6]
func doubleArray(array: [Int]) -> [Int] {
    return array.map { $0 * 2 }
}

// Given a non-empty array of integers, return the result of multiplying the values together in order.
// For example:
// [1, 2, 3] ==> 6
func multiplyArray(array
return Double(a) * h / 2 // cannot convert value of type 'Int' to expected argument type 'Double'
return input.map { $0.isUpperCase == true ? $0.toLowerCase() : $0.toUpperCase() }.joined() // value of type 'String.Element' (aka 'Character') has no member 'toUpperCase'
return input.map { $0.isUpperCase == true ? $0.toLowerCase() : $0.toUpperCase() }.joined() // value of type 'String.Element' (aka 'Character') has no member 'toLowerCase'
return input.map { $0.isUpperCase == true ? $0.toLowerCase() : $0.toUpperCase() }.joined() // value of type 'String.Element' (aka 'Character') has no member 'isUpperCase'
return input.reversed().join() // reference to member 'join' cannot be resolved without a contextual type

func triangleArea(a: Int, h: Int) -> Double {
    return a * h / 2
}

func reverseString(_ string: String) -> String {
    return string.reversed().join()
}
```swift
// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Int, h: Int) -> Double {
    return a * h / 2
}

// Given a string, return a new string with the reversed order of characters.
// reverseString("hello") == "olleh"
func reverseString(_ string: String) -> String {
    return string.reversed().join()
}

// Given a string, return a new string with the reversed order of characters.
// reverseString("hello") == "olleh"
func reverseString(_ string: String) -> String {
    return string.reversed().join()
}

// Given a string, return a new string with the reversed order of characters.
// reverseString("hello") == "olleh"
func reverseString(_ string: String) -> String {
    return string.reversed().join()
}

// Given a string, return a new string with the reversed order of characters.
// reverseString("hello") == "olleh"
func reverseString(_ string: String) -> String {
    return string.reversed().join()
}

// Given a string, return a new string with the reversed order of characters.
// reverseString("hello") == "olleh"
func reverseString(_ string: String) -> String {
    return string.reversed().join()
}

// Given a string, return a new string with the reversed order of characters.
// reverseString("hello") == "olleh"
func reverseString(_ string: String) -> String {
    return string.reversed().join()
}

// Given a string, return a new string with the reversed order of characters.
// reverseString("hello") == "olleh"
func reverseString(_ string: String) -> String {
    return string.reversed().join()
}

// Given a string, return a new string with the reversed order of characters.
// reverseString("hello") == "olleh"
func reverseString(_ string: String) -> String {
    return string.reversed().join()
}

// Given a string, return a new string with the reversed order of characters.
// reverseString("hello") == "olleh"
func reverseString(_ string: String) -> String {
    return string.reversed().join()
}

// Given a string, return a new string with the reversed order of characters.
// reverseString("hello") == "olleh"
func reverseString(_ string: String) -> String {
    return string.reversed().join()
}

// Given a string, return a new string with the reversed order of characters.
// reverseString("hello") == "olleh"
func reverseString(_ string: String) -> String {
    return string.reversed().join()
}

// Given a string, return a new string with the reversed order of characters.
// reverseString("hello") == "olleh"
func reverseString(_ string: String) -> String {
    return string.reversed().join()
}

// Given a string, return a new string with the reversed order of characters.
// reverseString("hello") == "olleh"
func reverseString(_ string: String) -> String {
    return string.reversed().join()
}

// Given a string, return a new string with the reversed order of characters.
// reverseString("hello") == "olleh"
func reverseString(_ string: String) -> String {
    return string.reversed().join()
}

// Given a string, return a new string with the reversed order of characters.
// reverseString("hello") == "olleh"
func reverseString(_ string: String) -> String {
    return string.reversed().join()
}

// Given a string, return a new string with the reversed order of characters.
// reverseString("hello") == "olleh"
func reverseString(_ string: String) -> String {
    return string.reversed().join()
}

// Given a string, return a new string with the reversed order of characters.
// reverseString("hello") == "olleh"
func reverseString(_ string: String) -> String {
    return string.reversed().join()
}

// Given a string, return a new string with the reversed order of characters.
// reverseString("hello")
return a * h / 2 // cannot convert return expression of type 'Int' to return type 'Double'
return string.reversed().join() // reference to member 'join' cannot be resolved without a contextual type

func triangleArea(a: Int, h: Int) -> Double {
    return a * h / 2
}
```swift
// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Int, h: Int) -> Double {
    return a * h / 2
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ------------------------------------
return a * h / 2 // cannot convert return expression of type 'Int' to return type 'Double'

func triangleArea(a: Int, h: Int) -> Double {
    return Double(a) * h / 2
}

func vowelFree(str: String) -> String {
    return str.filter { !"aeiouAEIOU".contains(Character(c: $0)) }
}

func charCount(str: String, char: Character) -> Int {
    return str.count(for: char)
}
```swift
// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Int, h: Int) -> Double {
    return Double(a) * h / 2
}

// Given a string, return a new string with all the vowels removed.
// vowelFree("Hello") == "Hll"
func vowelFree(str: String) -> String {
    return str.filter { !"aeiouAEIOU".contains(Character(c: $0)) }
}

// Given a string, return the number of times the character appears in the string.
// charCount("Hello", "l") == 2
func charCount(str: String, char: Character) -> Int {
    return str.count(for: char)
}

// Given a string, return the number of times the character appears in the string.
// charCount("Hello", "l") == 2
func charCount(str: String, char: Character) -> Int {
    return str.count(for: char)
}

// Given a string, return the number of times the character appears in the string.
// charCount("Hello", "l") == 2
func charCount(str: String, char: Character) -> Int {
    return str.count(for: char)
}

// Given a string, return the number of times the character appears in the string.
// charCount("Hello", "l") == 2
func charCount(str: String, char: Character) -> Int {
    return str.count(for: char)
}

// Given a string, return the number of times the character appears in the string.
// charCount("Hello", "l") == 2
func charCount(str: String, char: Character) -> Int {
    return str.count(for: char)
}

// Given a string, return the number of times the character appears in the string.
// charCount("Hello", "l") == 2
func charCount(str: String, char: Character) -> Int {
    return str.count(for: char)
}

// Given a string, return the number of times the character appears in the string.
// charCount("Hello", "l") == 2
func charCount(str: String, char: Character) -> Int {
    return str.count(for: char)
}

// Given a string, return the number of times the character appears in the string.
// charCount("Hello", "l") == 2
func charCount(str: String, char: Character) -> Int {
    return str.count(for: char)
}

// Given a string, return the number of times the character appears in the string.
// charCount("Hello", "l") == 2
func charCount(str: String, char: Character) -> Int {
    return str.count(for: char)
}

// Given a string, return the number of times the character appears in the string.
// charCount("Hello", "l") == 2
func charCount(str: String, char: Character) -> Int {
    return str.count(for: char)
}

// Given a string, return the number of times the character appears in the string.
// charCount("Hello", "l") == 2
func charCount(str: String, char: Character) -> Int {
    return str.count(for: char)
}

// Given a string, return the number of times the character appears in the string.
// charCount("Hello", "l") == 2
func charCount(str: String, char: Character) -> Int {
    return str.count(for: char)
}

// Given a string, return the number of times the character appears in the string.
// charCount("Hello", "l") == 2
func charCount(str: String, char: Character) -> Int {
    return str.count(for: char)
}

// Given a string, return the number of times the character appears in the string.
// charCount("Hello", "l") == 2
func charCount(str: String, char: Character) -> Int {
    return str.count(for: char)
}

// Given a string, return the number of times the character appears in the string.
// charCount("Hello", "l") == 2
func char
return Double(a) * h / 2 // cannot convert value of type 'Int' to expected argument type 'Double'
return str.filter { !"aeiouAEIOU".contains(Character(c: $0)) } // incorrect argument label in call (have 'c:', expected 'extendedGraphemeClusterLiteral:')
return str.count(for: char) // cannot call value of non-function type 'Int'

func triangleArea(a: Int, h: Int) -> Double {
    return Double(a) * h / 2
}

func vowelFree(s: String) -> String {
    var result = ""
    for char in s {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

func countChar(s: String, c: Character) -> Int {
    var count = 0
    for char in s {
        if char == c {
            count += 1
        }
    }
    return count
}
```swift
// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Int, h: Int) -> Double {
    return Double(a) * h / 2
}

// Given a string, return a new string with all the vowels removed.
// vowelFree("Hello") == "Hll"
func vowelFree(s: String) -> String {
    var result = ""
    for char in s {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// Given a string, return the number of times the character appears in the string.
// countChar("Hello", "l") == 2
func countChar(s: String, c: Character) -> Int {
    var count = 0
    for char in s {
        if char == c {
            count += 1
        }
    }
    return count
}

// Given a string, return the number of times the character appears in the string.
// countChar("Hello", "l") == 2
func countChar(s: String, c: Character) -> Int {
    var count = 0
    for char in s {
        if char == c {
            count += 1
        }
    }
    return count
}

// Given a string, return the number of times the character appears in the string.
// countChar("Hello", "l") == 2
func countChar(s: String, c: Character) -> Int {
    var count = 0
    for char in s {
        if char == c {
            count += 1
        }
    }
    return count
}

// Given a string, return the number of times the character appears in the string.
// countChar("Hello", "l") == 2
func countChar(s: String, c: Character) -> Int {
    var count = 0
    for char in s {
        if char == c {
            count += 1
        }
    }
    return count
}

// Given a string, return the number of times the character appears in the string.
// countChar("Hello", "l") == 2
func countChar(s: String, c: Character) -> Int {
    var count = 0
    for char in s {
        if char == c {
            count += 1
        }
    }
    return count
}

// Given a string, return the number of times the character appears in the string.
// countChar("Hello", "l") == 2
func countChar(s: String, c: Character) -> Int {
    var count = 0
    for char in s {
        if char == c {
            count += 1
        }
    }
    return count
}

// Given a string, return the number of times the character appears in the string.
// countChar("Hello", "l") == 2
func countChar(s: String, c: Character) -> Int {
    var count = 0
    for char in s {
        if char == c {
            count += 1
        }
    }
    return count
}

// Given a string, return the number of times the character appears in the string.
// countChar("Hello", "l") == 2
func countChar(s: String, c: Character) -> Int {
    var count = 0
    for char in s {
        if char == c {
            count += 1
        }
    }
    return count
}

// Given a string, return the number of times the character appears in the string.
// countChar("Hello", "l") == 2
func countChar(s: String, c: Character) -> Int {
    var count = 0
    for char in s {
        if char == c {
            count += 1
        }
    }
    return count
}

// Given a string, return the number of times the character appears in the string.
// countChar("Hello", "l") == 2
func countChar(s: String, c: Character) -> Int {
    var count = 0
    for char in s {
        if char == c {
            count += 1
        }
    }
    return count
}

// Given a string, return the number of times the character appears in the string.
return Double(a) * h / 2 // cannot convert value of type 'Int' to expected argument type 'Double'
if !isVowel(char) { // cannot find 'isVowel' in scope
result += char // cannot convert value of type 'Character' to expected argument type 'String'

func triangleArea(a: Int, h: Int) -> Double {
    return a * h / 2
}

func stringTransformer(str: String) -> String {
    var newStr = ""
    for char in str {
        if char == " " {
            newStr += " "
        } else if char.isUpper {
            newStr += char.lowerCasedString
        } else {
            newStr += char.upperCasedString
        }
    }
    return newStr.trimmingCharacters(in: .whitespace)
}
```swift
// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Int, h: Int) -> Double {
    return a * h / 2
}

// Given a string, return a new string that has transformed based on the input:
// Change case of every character, ie. lower case to upper case, upper case to lower case.
// Reverse the order of words from the input.
// Note: You will have to handle multiple spaces, and leading/trailing spaces.
// For example:
// "Example Input" ==> "iNPUT eXAMPLE"
// "   Hello World  " ==> "dLOw NSRE HILlE"
// "" ==> ""

func stringTransformer(str: String) -> String {
    var newStr = ""
    for char in str {
        if char == " " {
            newStr += " "
        } else if char.isUpper {
            newStr += char.lowerCasedString
        } else {
            newStr += char.upperCasedString
        }
    }
    return newStr.trimmingCharacters(in: .whitespace)
}

// Given a string, return a new string that has transformed based on the input:
// Change case of every character, ie. lower case to upper case, upper case to lower case.
// Reverse the order of words from the input.
// Note: You will have to handle multiple spaces, and leading/trailing spaces.
// For example:
// "Example Input" ==> "iNPUT eXAMPLE"
// "   Hello World  " ==> "dLOw NSRE HILlE"
// "" ==> ""

func stringTransformer(str: String) -> String {
    var newStr = ""
    for char in str {
        if char == " " {
            newStr += " "
        } else if char.isUpper {
            newStr += char.lowerCasedString
        } else {
            newStr += char.upperCasedString
        }
    }
    return newStr.trimmingCharacters(in: .whitespace)
}

// Given a string, return a new string that has transformed based on the input:
// Change case of every character, ie. lower case to upper case, upper case to lower case.
// Reverse the order of words from the input.
// Note: You will have to handle multiple spaces, and leading/trailing spaces.
// For example:
// "Example Input" ==> "iNPUT eXAMPLE"
// "   Hello World  " ==> "dLOw NSRE HILlE"
// "" ==> ""

func stringTransformer(str: String) -> String {
    var newStr = ""
    for char in str {
        if char == " " {
            newStr += " "
        } else if char.isUpper {
            newStr += char.lowerCasedString
        } else {
            newStr += char.upperCasedString
        }
    }
    return newStr.trimmingCharacters(in: .whitespace)
}

// Given a string, return a new string that has transformed based on the input:
// Change case of every character, ie. lower case to upper case, upper case to lower case.
// Reverse the order of words from the input.
// Note: You will have to handle multiple spaces, and leading/trailing spaces.
// For example:
// "Example Input" ==> "iNPUT eXAMPLE"
// "   Hello World  " ==> "dLOw NSRE HILlE"
// "" ==> ""

func stringTransformer(str: String) -> String {
    var newStr = ""
    for char in str {
        if char == " " {
            newStr += " "
        } else if char.isUpper {
            newStr += char.lowerCasedString
        } else {
            newStr += char.upperCasedString
        }
    }
    return newStr.trimmingCharacters(in: .whitespace)
}

// Given a string, return a new string that has transformed based on the input:
// Change case of every character, ie. lower case to upper case, upper case to lower case.
// Reverse the order of words from the input.
// Note: You will have to handle multiple spaces, and leading/trailing spaces.
// For example:
// "Example Input" ==> "iNPUT
return a * h / 2 // cannot convert return expression of type 'Int' to return type 'Double'
} else if char.isUpper { // value of type 'Character' has no member 'isUpper'
newStr += char.lowerCasedString // value of type 'Character' has no member 'lowerCasedString'
newStr += char.upperCasedString // value of type 'Character' has no member 'upperCasedString'
return newStr.trimmingCharacters(in: .whitespace) // type 'CharacterSet' has no member 'whitespace'

func triangleArea(a: Int, h: Int) -> Double {
    return a * h / 2
}

func vowelFree(string: String) -> String {
    return string.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "")
}
```swift
// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Int, h: Int) -> Double {
    return a * h / 2
}

// Given a string, return a new string with all the vowels removed.
// vowelFree("Hello") == "Hll"
func vowelFree(string: String) -> String {
    return string.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "")
}

// Given a string, return the string with all the vowels removed.
// vowelFree("Hello") == "Hll"
func vowelFree(string: String) -> String {
    return string.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "")
}

// Given a string, return the string with all the vowels removed.
// vowelFree("Hello") == "Hll"
func vowelFree(string: String) -> String {
    return string.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "")
}

// Given a string, return the string with all the vowels removed.
// vowelFree("Hello") == "Hll"
func vowelFree(string: String) -> String {
    return string.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "")
}

// Given a string, return the string with all the vowels removed.
// vowelFree("Hello") == "Hll"
func vowelFree(string: String) -> String {
    return string.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "")
}

// Given a string, return the string with all the vowels removed.
// vowelFree("Hello") == "Hll"
func vowelFree(string: String) -> String {
    return string.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "")
}

// Given a string, return the string with all the vowels removed.
// vowelFree("Hello") == "Hll"
func vowelFree(string: String) -> String {
    return string.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "")
}

// Given a string, return the string with all the vowels removed.
// vowelFree("Hello") == "Hll"
func vowelFree(string: String) -> String {
    return string.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "")
}

// Given a string, return the string with all the vowels removed.
// vowelFree("Hello") == "Hll"
func vowelFree(string: String) -> String {
    return string.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "")
}

// Given a string, return the string with all the vowels removed.
// vowelFree("Hello") == "Hll"
func vowelFree(string: String) -> String {
    return string.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "")
}

return a * h / 2 // cannot convert return expression of type 'Int' to return type 'Double'
return string.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "") // cannot use mutating member on immutable value: 'string' is a 'let' constant
return string.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "") // value of tuple type '()' has no member 'replace'
return string.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "") // missing argument label 'with:' in call

func triangleArea(a: Int, h: Int) -> Double {
    return a * h / 2
}

func vowelFree(str: String) -> String {
    return str.filter { !"aeiou".contains($0) }
}
```swift
// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Int, h: Int) -> Double {
    return a * h / 2
}

// Given a string, return a new string with all the vowels removed.
// vowelFree("Hello") == "Hll"
func vowelFree(str: String) -> String {
    return str.filter { !"aeiou".contains($0) }
}

// Given a string, return a new string with all the vowels removed.
// vowelFree("Hello") == "Hll"
func vowelFree(str: String) -> String {
    return str.filter { !"aeiou".contains($0) }
}

// Given a string, return a new string with all the vowels removed.
// vowelFree("Hello") == "Hll"
func vowelFree(str: String) -> String {
    return str.filter { !"aeiou".contains($0) }
}

// Given a string, return a new string with all the vowels removed.
// vowelFree("Hello") == "Hll"
func vowelFree(str: String) -> String {
    return str.filter { !"aeiou".contains($0) }
}

// Given a string, return a new string with all the vowels removed.
// vowelFree("Hello") == "Hll"
func vowelFree(str: String) -> String {
    return str.filter { !"aeiou".contains($0) }
}

// Given a string, return a new string with all the vowels removed.
// vowelFree("Hello") == "Hll"
func vowelFree(str: String) -> String {
    return str.filter { !"aeiou".contains($0) }
}

// Given a string, return a new string with all the vowels removed.
// vowelFree("Hello") == "Hll"
func vowelFree(str: String) -> String {
    return str.filter { !"aeiou".contains($0) }
}

// Given a string, return a new string with all the vowels removed.
// vowelFree("Hello") == "Hll"
func vowelFree(str: String) -> String {
    return str.filter { !"aeiou".contains($0) }
}

// Given a string, return a new string with all the vowels removed.
// vowelFree("Hello") == "Hll"
func vowelFree(str: String) -> String {
    return str.filter { !"aeiou".contains($0) }
}

// Given a string, return a new string with all the vowels removed.
// vowelFree("Hello") == "Hll"
func vowelFree(str: String) -> String {
    return str.filter { !"aeiou".contains($0) }
}

// Given a string, return a new string with all the vowels removed.
// vowelFree("Hello") == "Hll"
func vowelFree(str: String) -> String {
    return str.filter { !"aeiou".contains($0) }
}

// Given a string, return a new string with all the vowels removed.
// vowelFree("Hello") == "Hll"
func vowelFree(str: String) -> String {
    return str.filter { !"aeiou".contains($0) }
}

// Given a string, return a new string with all the vowels removed.
// vowelFree("Hello") == "Hll"
func vowelFree(str: String) -> String {
    return str.filter { !"aeiou".contains($0) }
}

// Given a string, return a new string with all the vowels removed.
// vowelFree("Hello") == "Hll"
func vowelFree(str: String) -> String {
    return str.filter { !"aeiou".contains($0) }
}

// Given a string, return a new string with all the vowels removed.
// vowelFree("Hello") == "Hll"
func vowelFree(str: String) -> String {
    return str.filter { !"aeiou".
return a * h / 2 // cannot convert return expression of type 'Int' to return type 'Double'

func triangleArea(a: Int, h: Int) -> Double {
    return Double(a) * h / 2
}

func transform(s: String) -> String {
    var transformed = ""
    for char in s {
        if char == " " {
            transformed += " "
        } else {
            if char.isUpper {
                transformed += char.lower
            } else {
                transformed += char.upper
            }
        }
    }
    return transformed
}

func sumOfMultiples(number: Int) -> Int {
    var sum = 0
    for i in 1..<number {
        if i % 3 == 0 || i % 5 == 0 {
            sum += i
        }
    }
    return sum
}
```swift
// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Int, h: Int) -> Double {
    return Double(a) * h / 2
}

// Given a string, return a new string that has transformed based on the input:
// Change case of every character, ie. lower case to upper case, upper case to lower case.
// Reverse the order of words from the input.
// Note: You will have to handle multiple spaces, and leading/trailing spaces.
// For example:
// "Example Input" ==> "iNPUT eXAMPLE"
// "   Hello World   " ==> "dLOw NSRE HOLO"
// "   Hello   World   " ==> "dLOw NSRE hLLO"
func transform(s: String) -> String {
    var transformed = ""
    for char in s {
        if char == " " {
            transformed += " "
        } else {
            if char.isUpper {
                transformed += char.lower
            } else {
                transformed += char.upper
            }
        }
    }
    return transformed
}

// Given a number, find the sum of all the unique multiples of particular numbers up to but not including that number.
// If we list all the natural numbers below 30 that are multiples of 3 or 5, we get 3, 5, 6, 9, 10, 12 and 15.
// The sum of these multiples is 33.
// Find the sum of all the multiples of 3 or 5 below the provided parameter value number.
// We will not be given a value less than 1.
func sumOfMultiples(number: Int) -> Int {
    var sum = 0
    for i in 1..<number {
        if i % 3 == 0 || i % 5 == 0 {
            sum += i
        }
    }
    return sum
}

// Given a string, return a new string that has transformed based on the input:
// Change case of every character, ie. lower case to upper case, upper case to lower case.
// Reverse the order of words from the input.
// Note: You will have to handle multiple spaces, and leading/trailing spaces.
// For example:
// "Example Input" ==> "iNPUT eXAMPLE"
// "   Hello World   " ==> "dLOw NSRE HOLO"
// "   Hello   World   " ==> "dLOw NSRE hLLO"
func transform(s: String) -> String {
    var transformed = ""
    for char in s {
        if char == " " {
            transformed += " "
        } else {
            if char.isUpper {
                transformed += char.lower
            } else {
                transformed += char.upper
            }
        }
    }
    return transformed
}

// Given a string, return a new string that has transformed based on the input:
// Change case of every character, ie. lower case to upper case, upper case to lower case.
// Reverse the order of words from the input.
// Note: You will have to handle multiple spaces, and leading/trailing spaces.
// For example:
// "Example Input" ==> "iNPUT eXAMPLE"
// "   Hello World   " ==> "dLOw NSRE HOLO"
// "   Hello   World   " ==> "dLOw NSRE hLLO"
func transform(s: String) -> String {
    var transformed = ""
    for char in s {
        if char == " " {
            transformed += " "
        } else {
            if char.isUpper {
                transformed += char.lower
            } else {
                transformed += char.upper
            }
        }
    }
    return transformed
}

// Given a string, return a new string that has transformed based on the input:
// Change case of every character, ie. lower case to upper case, upper case to lower case.
// Reverse the order of words from the input.
// Note: You will have to handle multiple spaces, and leading/trailing spaces.
// For example:
// "Example Input" ==> "iNPUT eXAMPLE"
// "   Hello World   " ==> "dLOw NSRE HOLO"
// "   Hello   World   " ==> "dLOw NSRE hLLO"
func transform(s: String
return Double(a) * h / 2 // cannot convert value of type 'Int' to expected argument type 'Double'
if char.isUpper { // value of type 'Character' has no member 'isUpper'
transformed += char.lower // value of type 'Character' has no member 'lower'
transformed += char.upper // value of type 'Character' has no member 'upper'

func fib4(n: Int) -> Int {
    if n == 0 {
        return 0
    } else if n == 1 {
        return 0
    } else if n == 2 {
        return 2
    } else if n == 3 {
        return 0
    } else {
        return fib4(n - 1) + fib4(n - 2) + fib4(n - 3) + fib4(n - 4)
    }
}
```swift
// The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
// fib4(0) -> 0
// fib4(1) -> 0
// fib4(2) -> 2
// fib4(3) -> 0
// fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4).
// Please write a function to efficiently compute the n-th element of the fib4 number sequence.  Do not use recursion.
// fib4(n: 5) == 4
// fib4(n: 6) == 8
// fib4(n: 7) == 14
func fib4(n: Int) -> Int {
    if n == 0 {
        return 0
    } else if n == 1 {
        return 0
    } else if n == 2 {
        return 2
    } else if n == 3 {
        return 0
    } else {
        return fib4(n - 1) + fib4(n - 2) + fib4(n - 3) + fib4(n - 4)
    }
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------------
return fib4(n - 1) + fib4(n - 2) + fib4(n - 3) + fib4(n - 4) // missing argument label 'n:' in call
return fib4(n - 1) + fib4(n - 2) + fib4(n - 3) + fib4(n - 4) // missing argument label 'n:' in call
return fib4(n - 1) + fib4(n - 2) + fib4(n - 3) + fib4(n - 4) // missing argument label 'n:' in call
return fib4(n - 1) + fib4(n - 2) + fib4(n - 3) + fib4(n - 4) // missing argument label 'n:' in call

func fib4(n: Int) -> Int {
    if n == 0 {
        return 0
    } else if n == 1 {
        return 0
    } else if n == 2 {
        return 2
    } else if n == 3 {
        return 0
    } else {
        return fib4(n - 1) + fib4(n - 2) + fib4(n - 3) + fib4(n - 4)
    }
}

func alphabetical(s: String) -> String {
    if s.isEmpty {
        return ""
    } else {
        return String(s.characters.sorted())
    }
}

func reverseAlphabetical(s: String) -> String {
    if s.isEmpty {
        return ""
    } else {
        return String(s.characters.reversed())
    }
}

func alphabeticalAndCount(s: String) -> String {
    if s.isEmpty {
        return ""
    } else {
        var result = ""
        var count = 1
        for i in 1..<s.count {
            if s[i] == s[i - 1] {
                count += 1
            } else {
                result += String(s[i - 1]) + String(count)
                count = 1
            }
        }
        result += String(s[s.count - 1]) + String(count)
        return result
    }
}
```swift
// The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
// fib4(0) -> 0
// fib4(1) -> 0
// fib4(2) -> 2
// fib4(3) -> 0
// fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4).
// Please write a function to efficiently compute the n-th element of the fib4 number sequence.  Do not use recursion.
// fib4(n: 5) == 4
// fib4(n: 6) == 8
// fib4(n: 7) == 14
func fib4(n: Int) -> Int {
    if n == 0 {
        return 0
    } else if n == 1 {
        return 0
    } else if n == 2 {
        return 2
    } else if n == 3 {
        return 0
    } else {
        return fib4(n - 1) + fib4(n - 2) + fib4(n - 3) + fib4(n - 4)
    }
}

// 11. Write a function that takes a string and returns a string with the letters in alphabetical order.
// Example:
// alphabetical("hello") == "ehllo"
// alphabetical("hello world") == "dehllloorw"
// alphabetical("edabit") == "abdeit"
// alphabetical("") == ""
// alphabetical("h") == "h"
// alphabetical("coding") == "codin"
// alphabetical("algorithm") == "aaalgort"
// alphabetical("z") == "z"
// alphabetical("zoo") == "ooz"
func alphabetical(s: String) -> String {
    if s.isEmpty {
        return ""
    } else {
        return String(s.characters.sorted())
    }
}

// 12. Write a function that takes a string and returns a string with the letters in reverse alphabetical order.
// Example:
// reverseAlphabetical("hello") == "olleh"
// reverseAlphabetical("hello world") == "dlrow olleh"
// reverseAlphabetical("edabit") == "tabide"
// reverseAlphabetical("") == ""
// reverseAlphabetical("h") == "h"
// reverseAlphabetical("coding") == "gniido"
// reverseAlphabetical("algorithm") == "gortlima"
// reverseAlphabetical("z") == "z"
// reverseAlphabetical("zoo") == "ooz"
func reverseAlphabetical(s: String) -> String {
    if s.isEmpty {
        return ""
    } else {
        return String(s.characters.reversed())
    }
}

// 13. Write a function that takes a string and returns a string with the letters in alphabetical order and the number of times each letter appears.
// Example:
// alphabeticalAndCount("hello") == "e1l1o3h1"
// alphabeticalAndCount("hello world") == "d1e1l1o1r1l1w1o1r1"
// alphabeticalAndCount("edabit") == "a1b1d1e1t1"
// alphabeticalAndCount("") == ""
// alphabeticalAndCount("h") == "h1"
// alphabeticalAndCount("coding") == "c1d1i1n1g1o1"
// alphabeticalAndCount("algorithm") == "a1c1g1l1o1m1t1r1i1"
// alphabeticalAndCount("z") == "z1"
// alphabeticalAndCount("zoo") == "o1z2"
func alphabeticalAndCount(s: String) -> String {
    if s.isEmpty {
        return ""
    } else {
        var result = ""
        var count = 1
        for i in 1..<s.count {
            if s[i] == s[i - 1] {
                count += 1
            } else {
                result += String(s[i - 1]) + String(count)
                count = 1
            }
        }
        result += String(s[s.count - 1]) + String(count)
        return result
    }
}

// 14. Write a function that takes a string and returns a string with the letters in reverse alphabetical order and the number of times each letter appears.
// Example:
// reverseAlphabeticalAndCount("hello") == "e1l1o3h1"
// reverseAlphabeticalAndCount("hello world") == "d1e1l1o1r1l1w1
return fib4(n - 1) + fib4(n - 2) + fib4(n - 3) + fib4(n - 4) // missing argument label 'n:' in call
return fib4(n - 1) + fib4(n - 2) + fib4(n - 3) + fib4(n - 4) // missing argument label 'n:' in call
return fib4(n - 1) + fib4(n - 2) + fib4(n - 3) + fib4(n - 4) // missing argument label 'n:' in call
return fib4(n - 1) + fib4(n - 2) + fib4(n - 3) + fib4(n - 4) // missing argument label 'n:' in call
return String(s.characters.sorted()) // 'characters' is unavailable: Please use String directly
return String(s.characters.reversed()) // 'characters' is unavailable: Please use String directly
if s[i] == s[i - 1] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i - 1] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
result += String(s[i - 1]) + String(count) // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
result += String(s[s.count - 1]) + String(count) // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.

func fib4(n: Int) -> Int {
    var fib = [0, 0, 0, 0]
    for i in 0...n {
        if i == 0 {
            fib[i] = 0
        } else if i == 1 {
            fib[i] = 0
        } else if i == 2 {
            fib[i] = 2
        } else if i == 3 {
            fib[i] = 0
        } else {
            fib[i] = fib[i - 1] + fib[i - 2] + fib[i - 3] + fib[i - 4]
        }
    }
    return fib[n]
}
```swift
// The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
// fib4(0) -> 0
// fib4(1) -> 0
// fib4(2) -> 2
// fib4(3) -> 0
// fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4).
// Please write a function to efficiently compute the n-th element of the fib4 number sequence.  Do not use recursion.
// fib4(n: 5) == 4
// fib4(n: 6) == 8
// fib4(n: 7) == 14
func fib4(n: Int) -> Int {
    var fib = [0, 0, 0, 0]
    for i in 0...n {
        if i == 0 {
            fib[i] = 0
        } else if i == 1 {
            fib[i] = 0
        } else if i == 2 {
            fib[i] = 2
        } else if i == 3 {
            fib[i] = 0
        } else {
            fib[i] = fib[i - 1] + fib[i - 2] + fib[i - 3] + fib[i - 4]
        }
    }
    return fib[n]
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// ------------------------
 // Fatal error: Index out of range

func fib4(n: Int) -> Int {
    var fib = [0, 0, 0, 0]
    for i in 0..<4 {
        fib[i] = i
    }
    for i in 4..<n {
        fib[i % 4] = fib[0] + fib[1] + fib[2] + fib[3]
    }
    return fib[n % 4]
}
```swift
// The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
// fib4(0) -> 0
// fib4(1) -> 0
// fib4(2) -> 2
// fib4(3) -> 0
// fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4).
// Please write a function to efficiently compute the n-th element of the fib4 number sequence.  Do not use recursion.
// fib4(n: 5) == 4
// fib4(n: 6) == 8
// fib4(n: 7) == 14
func fib4(n: Int) -> Int {
    var fib = [0, 0, 0, 0]
    for i in 0..<4 {
        fib[i] = i
    }
    for i in 4..<n {
        fib[i % 4] = fib[0] + fib[1] + fib[2] + fib[3]
    }
    return fib[n % 4]
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// 
 // XCTAssertTrue failed

func fib4(n: Int) -> Int {
    if n < 4 {
        return 0
    }
    var fibs = [0, 0, 0, 0]
    for i in 0...3 {
        fibs[i] = 1
    }
    for _ in 0...n - 4 {
        var sum = 0
        for i in 0...3 {
            sum += fibs[i]
        }
        fibs[0] = fibs[1]
        fibs[1] = fibs[2]
        fibs[2] = fibs[3]
        fibs[3] = sum
    }
    return fibs[3]
}
```swift
// The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
// fib4(0) -> 0
// fib4(1) -> 0
// fib4(2) -> 2
// fib4(3) -> 0
// fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4).
// Please write a function to efficiently compute the n-th element of the fib4 number sequence.  Do not use recursion.
// fib4(n: 5) == 4
// fib4(n: 6) == 8
// fib4(n: 7) == 14
func fib4(n: Int) -> Int {
    if n < 4 {
        return 0
    }
    var fibs = [0, 0, 0, 0]
    for i in 0...3 {
        fibs[i] = 1
    }
    for _ in 0...n - 4 {
        var sum = 0
        for i in 0...3 {
            sum += fibs[i]
        }
        fibs[0] = fibs[1]
        fibs[1] = fibs[2]
        fibs[2] = fibs[3]
        fibs[3] = sum
    }
    return fibs[3]
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ------------
 // XCTAssertTrue failed

func fib4(n: Int) -> Int {
    var fib = [0, 0, 0, 0]
    for i in 0...n {
        if i == 0 {
            fib[i] = 0
        } else if i == 1 {
            fib[i] = 0
        } else if i == 2 {
            fib[i] = 2
        } else if i == 3 {
            fib[i] = 0
        } else {
            fib[i] = fib[i-1] + fib[i-2] + fib[i-3] + fib[i-4]
        }
    }
    return fib[n]
}

func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}
```swift
// The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
// fib4(0) -> 0
// fib4(1) -> 0
// fib4(2) -> 2
// fib4(3) -> 0
// fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4).
// Please write a function to efficiently compute the n-th element of the fib4 number sequence.  Do not use recursion.
// fib4(n: 5) == 4
// fib4(n: 6) == 8
// fib4(n: 7) == 14
func fib4(n: Int) -> Int {
    var fib = [0, 0, 0, 0]
    for i in 0...n {
        if i == 0 {
            fib[i] = 0
        } else if i == 1 {
            fib[i] = 0
        } else if i == 2 {
            fib[i] = 2
        } else if i == 3 {
            fib[i] = 0
        } else {
            fib[i] = fib[i-1] + fib[i-2] + fib[i-3] + fib[i-4]
        }
    }
    return fib[n]
}

// 10. Write a function that takes a string and returns a new string with all the vowels removed.
// The vowels are a, e, i, o, u.
// If the string doesn't consist of vowels, return the string unchanged.
// removeVowels("The quick brown fox jumps over the lazy dog") == "Th qck brwn fx jmps vr th lzy dg"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// 11. Write a function that takes a string and returns a new string with all the vowels removed.
// The vowels are a, e, i, o, u.
// If the string doesn't consist of vowels, return the string unchanged.
// removeVowels("The quick brown fox jumps over the lazy dog") == "Th qck brwn fx jmps vr th lzy dg"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// 12. Write a function that takes a string and returns a new string with all the vowels removed.
// The vowels are a, e, i, o, u.
// If the string doesn't consist of vowels, return the string unchanged.
// removeVowels("The quick brown fox jumps over the lazy dog") == "Th qck brwn fx jmps vr th lzy dg"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// 13. Write a function that takes a string and returns a new string with all the vowels removed.
// The vowels are a, e, i, o, u.
// If the string doesn't consist of vowels, return the string unchanged.
// removeVowels("The quick brown fox jumps over the lazy dog") == "Th qck brwn fx jmps vr th lzy dg"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// 14. Write a function that takes a string and returns a new string with all the vowels removed.
// The vowels are a, e, i, o, u.
// If the string doesn't consist of vowels, return the string unchanged.
// removeVowels("The quick brown fox jumps over the lazy dog") == "Th qck brwn fx jmps vr th lzy dg"
func removeVowels(input: String) -> String {
    var result = "
result += char // cannot convert value of type 'Character' to expected argument type 'String'

func fib4(n: Int) -> Int {
    return 0
}
```swift
// The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
// fib4(0) -> 0
// fib4(1) -> 0
// fib4(2) -> 2
// fib4(3) -> 0
// fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4).
// Please write a function to efficiently compute the n-th element of the fib4 number sequence.  Do not use recursion.
// fib4(n: 5) == 4
// fib4(n: 6) == 8
// fib4(n: 7) == 14
func fib4(n: Int) -> Int {
    return 0
}

// 2. Write a function that takes a string and returns the number of vowels in the string.
// The vowel letters are a, e, i, o, u.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string
 // XCTAssertTrue failed

func fib4(n: Int) -> Int {
    if n == 0 {
        return 0
    } else if n == 1 {
        return 0
    } else if n == 2 {
        return 2
    } else if n == 3 {
        return 0
    } else {
        return fib4(n - 1) + fib4(n - 2) + fib4(n - 3) + fib4(n - 4)
    }
}

func reverseString(s: String) -> String {
    return String(s.reversed())
}

func twoSum(nums: [Int], target: Int) -> [Int] {
    var result = [Int]()
    for i in 0..<nums.count {
        for j in i + 1..<nums.count {
            if nums[i] + nums[j] == target {
                result.append(i)
                result.append(j)
                return result
            }
        }
    }
    return result
}

func containsDuplicate(nums: [Int]) -> Bool {
    var set = Set<Int>()
    for num in nums {
        if set.contains(num) {
            return true
        } else {
            set.insert(num)
        }
    }
    return false
}
```swift
// The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
// fib4(0) -> 0
// fib4(1) -> 0
// fib4(2) -> 2
// fib4(3) -> 0
// fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4).
// Please write a function to efficiently compute the n-th element of the fib4 number sequence.  Do not use recursion.
// fib4(n: 5) == 4
// fib4(n: 6) == 8
// fib4(n: 7) == 14
func fib4(n: Int) -> Int {
    if n == 0 {
        return 0
    } else if n == 1 {
        return 0
    } else if n == 2 {
        return 2
    } else if n == 3 {
        return 0
    } else {
        return fib4(n - 1) + fib4(n - 2) + fib4(n - 3) + fib4(n - 4)
    }
}

// 2. Write a function that takes a string as input and returns the string reversed.
// Example:
// Given s = "hello", return "olleh".
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// 3. Given an array of integers, return indices of the two numbers such that they add up to a specific target.
// You may assume that each input would have exactly one solution, and you may not use the same element twice.
// Example:
// Given nums = [2, 7, 11, 15], target = 9,
// Because nums[0] + nums[1] = 2 + 7 = 9,
// return [0, 1].
func twoSum(nums: [Int], target: Int) -> [Int] {
    var result = [Int]()
    for i in 0..<nums.count {
        for j in i + 1..<nums.count {
            if nums[i] + nums[j] == target {
                result.append(i)
                result.append(j)
                return result
            }
        }
    }
    return result
}

// 4. Given an array of integers, find if the array contains any duplicates.
// Your function should return true if any value appears at least twice in the array, and it should return false if every element is distinct.
// Example 1:
// Input: [1,2,3,1]
// Output: true
// Example 2:
// Input: [1,2,3,4]
// Output: false
// Example 3:
// Input: [1,1,1,3,3,4,3,2,4,2]
// Output: true
func containsDuplicate(nums: [Int]) -> Bool {
    var set = Set<Int>()
    for num in nums {
        if set.contains(num) {
            return true
        } else {
            set.insert(num)
        }
    }
    return false
}

// 5. Given an array of integers, return indices of the two numbers such that they add up to a specific target.
// You may assume that each input would have exactly one solution, and you may not use the same element twice.
// Example:
// Given nums = [2, 7, 11, 15], target = 9,
// Because nums[0] + nums[1] = 2 + 7 = 9,
// return [0, 1].
// 6. Given an array of integers, return indices of the two numbers such that they add up to a specific target.
// You may assume that each input would have exactly one solution, and you may not use the same element twice.
// Example:
// Given nums = [2, 7, 11, 15], target = 9,
// Because nums[0] + nums[1] = 2 + 7 = 9,
// return [0, 1].
// 7. Given an array of integers, return indices of the two numbers such that they add up to a specific target.
// You may assume that each input would have exactly one solution, and you may not use the same element twice.
// Example:
// Given nums = [2, 7, 11, 15], target = 9,
// Because nums[0] + nums[1] = 2 + 7 = 9,
// return [0, 1].
// 8. Given an array of integers, return indices of the two numbers such that they add up to a specific target.
// You may assume that each input would have exactly one solution, and you may not use the same element twice.
// Example:
// Given nums = [2, 7, 11,
return fib4(n - 1) + fib4(n - 2) + fib4(n - 3) + fib4(n - 4) // missing argument label 'n:' in call
return fib4(n - 1) + fib4(n - 2) + fib4(n - 3) + fib4(n - 4) // missing argument label 'n:' in call
return fib4(n - 1) + fib4(n - 2) + fib4(n - 3) + fib4(n - 4) // missing argument label 'n:' in call
return fib4(n - 1) + fib4(n - 2) + fib4(n - 3) + fib4(n - 4) // missing argument label 'n:' in call

func fib4(n: Int) -> Int {
    var fib = [0, 0, 0, 0]
    for i in 0..<n {
        if i == 0 {
            fib[i] = 0
        } else if i == 1 {
            fib[i] = 0
        } else if i == 2 {
            fib[i] = 2
        } else if i == 3 {
            fib[i] = 0
        } else {
            fib[i] = fib[i - 1] + fib[i - 2] + fib[i - 3] + fib[i - 4]
        }
    }
    return fib[n]
}

func vowelCount(string: String) -> Int {
    var count = 0
    for char in string {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}

func wordCount(string: String) -> Int {
    var count = 0
    var isWord = false
    for char in string {
        if char == " " {
            isWord = false
        } else if !isWord {
            isWord = true
            count += 1
        }
    }
    return count
}

func consonantCount(string: String) -> Int {
    var count = 0
    for char in string {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" || char == " " {
            continue
        } else {
            count += 1
        }
    }
    return count
}
```swift
// The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
// fib4(0) -> 0
// fib4(1) -> 0
// fib4(2) -> 2
// fib4(3) -> 0
// fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4).
// Please write a function to efficiently compute the n-th element of the fib4 number sequence.  Do not use recursion.
// fib4(n: 5) == 4
// fib4(n: 6) == 8
// fib4(n: 7) == 14
func fib4(n: Int) -> Int {
    var fib = [0, 0, 0, 0]
    for i in 0..<n {
        if i == 0 {
            fib[i] = 0
        } else if i == 1 {
            fib[i] = 0
        } else if i == 2 {
            fib[i] = 2
        } else if i == 3 {
            fib[i] = 0
        } else {
            fib[i] = fib[i - 1] + fib[i - 2] + fib[i - 3] + fib[i - 4]
        }
    }
    return fib[n]
}

// 10. Write a function that takes a string and returns the number of vowels in the string.
// You should treat a letter's case as alphabetical when determining the number of vowels, and you should treat the letter y as a vowel.
// Assume the input will always be a string.
// vowelCount("Crab up!") == 5
// vowelCount("abracadabra") == 5
// vowelCount("rhythm repeating") == 2
func vowelCount(string: String) -> Int {
    var count = 0
    for char in string {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}

// 11. Write a function that takes a string and returns the number of words in the string.
// You should treat a letter's case as alphabetical when determining the number of words, and you should treat the letter y as a word.
// Assume the input will always be a string.
// wordCount("Crab up!") == 1
// wordCount("abracadabra") == 6
// wordCount("rhythm repeating") == 2
func wordCount(string: String) -> Int {
    var count = 0
    var isWord = false
    for char in string {
        if char == " " {
            isWord = false
        } else if !isWord {
            isWord = true
            count += 1
        }
    }
    return count
}

// 12. Write a function that takes a string and returns the number of consonants in the string.
// You should treat a letter's case as alphabetical when determining the number of consonants, and you should treat the letter y as a consonant.
// Assume the input will always be a string.
// consonantCount("Crab up!") == 3
// consonantCount("abracadabra") == 5
// consonantCount("rhythm repeating") == 3
func consonantCount(string: String) -> Int {
    var count = 0
    for char in string {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" || char == " " {
            continue
        } else {
            count += 1
        }
    }
    return count
}

// 13. Write a function that takes a string and returns the number of consonants in the string.
// You should treat a letter's case as alphabetical when determining the number of consonants, and you should treat the letter y as a consonant.
// Assume the input will always be a string.
// consonantCount("Crab up!") == 3
// consonantCount("abracadabra") == 5
// consonantCount("rhythm repeating") == 3
func consonantCount(string: String) -> Int {
    var count = 0
    for char in string {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" || char == " " {
            continue
        } else {
            count += 1
        }
    }
    return count
}

// 14. Write a function that takes a string and returns the number of consonants in the string.
// You should treat a letter's case as alphabetical when determining the number of conson
 // Fatal error: Index out of range

func fib4(n: Int) -> Int {
    if n == 0 {
        return 0
    }
    if n == 1 {
        return 0
    }
    if n == 2 {
        return 2
    }
    if n == 3 {
        return 0
    }
    var fib4 = [0, 0, 2, 0]
    for i in 4...n {
        fib4.append(fib4[i-1] + fib4[i-2] + fib4[i-3] + fib4[i-4])
    }
    return fib4[n]
}
```swift
// The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
// fib4(0) -> 0
// fib4(1) -> 0
// fib4(2) -> 2
// fib4(3) -> 0
// fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4).
// Please write a function to efficiently compute the n-th element of the fib4 number sequence.  Do not use recursion.
// fib4(n: 5) == 4
// fib4(n: 6) == 8
// fib4(n: 7) == 14
func fib4(n: Int) -> Int {
    if n == 0 {
        return 0
    }
    if n == 1 {
        return 0
    }
    if n == 2 {
        return 2
    }
    if n == 3 {
        return 0
    }
    var fib4 = [0, 0, 2, 0]
    for i in 4...n {
        fib4.append(fib4[i-1] + fib4[i-2] + fib4[i-3] + fib4[i-4])
    }
    return fib4[n]
}

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ---------------------------

func median(l: [Int]) -> Double {
    let sorted = l.sorted()
    let middle = sorted.count / 2
    if sorted.count % 2 == 0 {
        return (sorted[middle - 1] + sorted[middle]) / 2
    } else {
        return sorted[middle]
    }
}
```swift
// Return median of elements in the array l.
// median(l: [3, 1, 2, 4, 5]) == 3
// median(l: [-10, 4, 6, 1000, 10, 20]) == 15.0
func median(l: [Int]) -> Double {
    let sorted = l.sorted()
    let middle = sorted.count / 2
    if sorted.count % 2 == 0 {
        return (sorted[middle - 1] + sorted[middle]) / 2
    } else {
        return sorted[middle]
    }
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// ---------------------------------------------------------
return (sorted[middle - 1] + sorted[middle]) / 2 // cannot convert return expression of type 'Int' to return type 'Double'
return sorted[middle] // cannot convert return expression of type 'Int' to return type 'Double'

func median(l: [Int]) -> Double {
    let sorted = l.sorted()
    let middle = sorted.count / 2
    return sorted.count % 2 == 0
        ? (sorted[middle - 1] + sorted[middle]) / 2
        : sorted[middle]
}
```swift
// Return median of elements in the array l.
// median(l: [3, 1, 2, 4, 5]) == 3
// median(l: [-10, 4, 6, 1000, 10, 20]) == 15.0
func median(l: [Int]) -> Double {
    let sorted = l.sorted()
    let middle = sorted.count / 2
    return sorted.count % 2 == 0
        ? (sorted[middle - 1] + sorted[middle]) / 2
        : sorted[middle]
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

? (sorted[middle - 1] + sorted[middle]) / 2 // cannot convert return expression of type 'Int' to return type 'Double'

func median(l: [Int]) -> Double {
    let sorted = l.sorted()
    let middle = sorted.count / 2
    return sorted.count % 2 == 0
        ? (sorted[middle - 1] + sorted[middle]) / 2
        : sorted[middle]
}
```swift
// Return median of elements in the array l.
// median(l: [3, 1, 2, 4, 5]) == 3
// median(l: [-10, 4, 6, 1000, 10, 20]) == 15.0
func median(l: [Int]) -> Double {
    let sorted = l.sorted()
    let middle = sorted.count / 2
    return sorted.count % 2 == 0
        ? (sorted[middle - 1] + sorted[middle]) / 2
        : sorted[middle]
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ------------------------------------------------------------
? (sorted[middle - 1] + sorted[middle]) / 2 // cannot convert return expression of type 'Int' to return type 'Double'

func median(l: [Int]) -> Double {
    let sorted = l.sorted()
    let middle = sorted.count / 2
    return sorted.count % 2 == 0 ? (sorted[middle - 1] + sorted[middle]) / 2 : sorted[middle]
}
```swift
// Return median of elements in the array l.
// median(l: [3, 1, 2, 4, 5]) == 3
// median(l: [-10, 4, 6, 1000, 10, 20]) == 15.0
func median(l: [Int]) -> Double {
    let sorted = l.sorted()
    let middle = sorted.count / 2
    return sorted.count % 2 == 0 ? (sorted[middle - 1] + sorted[middle]) / 2 : sorted[middle]
}

print(median([3, 1, 2, 4, 5]))
print(median([-10, 4, 6, 1000, 10, 20]))

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------
return sorted.count % 2 == 0 ? (sorted[middle - 1] + sorted[middle]) / 2 : sorted[middle] // cannot convert return expression of type 'Int' to return type 'Double'

func median(l: [Int]) -> Double {
    let l = l.sorted()
    let middle = l.count / 2
    return l.count % 2 == 0 ? (l[middle - 1] + l[middle]) / 2 : l[middle]
}
```swift
// Return median of elements in the array l.
// median(l: [3, 1, 2, 4, 5]) == 3
// median(l: [-10, 4, 6, 1000, 10, 20]) == 15.0
func median(l: [Int]) -> Double {
    let l = l.sorted()
    let middle = l.count / 2
    return l.count % 2 == 0 ? (l[middle - 1] + l[middle]) / 2 : l[middle]
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ------------------------------------------------------
return l.count % 2 == 0 ? (l[middle - 1] + l[middle]) / 2 : l[middle] // cannot convert return expression of type 'Int' to return type 'Double'

func median(l: [Int]) -> Double {
    let count = l.count
    if count == 0 {
        return 0
    }
    if count % 2 == 0 {
        return (l[count / 2 - 1] + l[count / 2]) / 2
    } else {
        return l[count / 2]
    }
}
```swift
// Return median of elements in the array l.
// median(l: [3, 1, 2, 4, 5]) == 3
// median(l: [-10, 4, 6, 1000, 10, 20]) == 15.0
func median(l: [Int]) -> Double {
    let count = l.count
    if count == 0 {
        return 0
    }
    if count % 2 == 0 {
        return (l[count / 2 - 1] + l[count / 2]) / 2
    } else {
        return l[count / 2]
    }
}

// -----------------------------------------------------------------------------
// MARK: - 1.1.2
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: - 1.1.3
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: - 1.1.4
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: - 1.1.5
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: - 1.1.6
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: - 1.1.7
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: - 1.1.8
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: - 1.1.9
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: - 1.1.10
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: - 1.1.11
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: - 1.1.12
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: - 1.1.13
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// MARK: - 1.1.14
// -----------------------------------------------------------------------------

// ------------------------------------
return (l[count / 2 - 1] + l[count / 2]) / 2 // cannot convert return expression of type 'Int' to return type 'Double'
return l[count / 2] // cannot convert return expression of type 'Int' to return type 'Double'

func median(l: [Int]) -> Double {
    let sorted = l.sorted()
    let middle = sorted.count / 2
    return sorted.count % 2 == 0 ? (sorted[middle - 1] + sorted[middle]) / 2 : sorted[middle]
}
```swift
// Return median of elements in the array l.
// median(l: [3, 1, 2, 4, 5]) == 3
// median(l: [-10, 4, 6, 1000, 10, 20]) == 15.0
func median(l: [Int]) -> Double {
    let sorted = l.sorted()
    let middle = sorted.count / 2
    return sorted.count % 2 == 0 ? (sorted[middle - 1] + sorted[middle]) / 2 : sorted[middle]
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ---------------------------------------------------------------------
return sorted.count % 2 == 0 ? (sorted[middle - 1] + sorted[middle]) / 2 : sorted[middle] // cannot convert return expression of type 'Int' to return type 'Double'

func median(l: [Int]) -> Double {
    let sorted = l.sorted()
    let middle = sorted.count / 2
    if sorted.count % 2 == 0 {
        return (sorted[middle - 1] + sorted[middle]) / 2
    } else {
        return sorted[middle]
    }
}
```swift
// Return median of elements in the array l.
// median(l: [3, 1, 2, 4, 5]) == 3
// median(l: [-10, 4, 6, 1000, 10, 20]) == 15.0
func median(l: [Int]) -> Double {
    let sorted = l.sorted()
    let middle = sorted.count / 2
    if sorted.count % 2 == 0 {
        return (sorted[middle - 1] + sorted[middle]) / 2
    } else {
        return sorted[middle]
    }
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ---------------------------------
return (sorted[middle - 1] + sorted[middle]) / 2 // cannot convert return expression of type 'Int' to return type 'Double'
return sorted[middle] // cannot convert return expression of type 'Int' to return type 'Double'

func median(l: [Int]) -> Double {
    let sorted = l.sorted()
    let middle = sorted.count / 2
    if sorted.count % 2 == 0 {
        return (sorted[middle - 1] + sorted[middle]) / 2
    } else {
        return sorted[middle]
    }
}
```swift
// Return median of elements in the array l.
// median(l: [3, 1, 2, 4, 5]) == 3
// median(l: [-10, 4, 6, 1000, 10, 20]) == 15.0
func median(l: [Int]) -> Double {
    let sorted = l.sorted()
    let middle = sorted.count / 2
    if sorted.count % 2 == 0 {
        return (sorted[middle - 1] + sorted[middle]) / 2
    } else {
        return sorted[middle]
    }
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// ------------------------------
return (sorted[middle - 1] + sorted[middle]) / 2 // cannot convert return expression of type 'Int' to return type 'Double'
return sorted[middle] // cannot convert return expression of type 'Int' to return type 'Double'

func median(l: [Int]) -> Double {
    let sorted = l.sorted()
    let middle = sorted.count / 2
    return sorted.count % 2 == 0
        ? (sorted[middle - 1] + sorted[middle]) / 2
        : sorted[middle]
}
```swift
// Return median of elements in the array l.
// median(l: [3, 1, 2, 4, 5]) == 3
// median(l: [-10, 4, 6, 1000, 10, 20]) == 15.0
func median(l: [Int]) -> Double {
    let sorted = l.sorted()
    let middle = sorted.count / 2
    return sorted.count % 2 == 0
        ? (sorted[middle - 1] + sorted[middle]) / 2
        : sorted[middle]
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// ---------------------------------------------------------
? (sorted[middle - 1] + sorted[middle]) / 2 // cannot convert return expression of type 'Int' to return type 'Double'

func isPalindrome(text: String) -> Bool {
    let reversed = String(text.reversed())
    return text == reversed
}
```swift
// Checks if given string is a palindrome
// isPalindrome(text: "") == true
// isPalindrome(text: "aba") == true
// isPalindrome(text: "aaaaa") == true
// isPalindrome(text: "zbcd") == false
func isPalindrome(text: String) -> Bool {
    let reversed = String(text.reversed())
    return text == reversed
}

// -----------------------------------------------------------------------------
// 2. Write a function that takes a string as a parameter and returns the number
// of vowels in the string.
//
// For example, the number of vowels in "abracadabra" is 5.
//
// Don't count y as a vowel.
//
// Hint: Use the characterSet property of the String class.
//
// isVowel(character: "a") == true
// isVowel(character: "b") == false
// isVowel(character: "y") == false
// isVowel(character: "z") == false
// isVowel(character: "Y") == false
// isVowel(character: "") == false
// isVowel(character: " ") == false
// isVowel(character: "1") == false
// isVowel(character: "2") == false
// isVowel(character: "3") == false
// isVowel(character: "4") == false
// isVowel(character: "5") == false
// isVowel(character: "6") == false
// isVowel(character: "7") == false
// isVowel(character: "8") == false
// isVowel(character: "9") == false
// isVowel(character: "0") == false
// isVowel(character: "a") == true
// isVowel(character: "b") == false
// isVowel(character: "c") == false
// isVowel(character: "d") == false
// isVowel(character: "e") == true
// isVowel(character: "f") == false
// isVowel(character: "g") == false
// isVowel(character: "h") == false
// isVowel(character: "i") == true
// isVowel(character: "j") == false
// isVowel(character: "k") == false
// isVowel(character: "l") == false
// isVowel(character: "m") == false
// isVowel(character: "n") == true
// isVowel(character: "o") == true
// isVowel(character: "p") == false
// isVowel(character: "q") == false
// isVowel(character: "r") == true
// isVowel(character: "s") == true
// isVowel(character: "t") == true
// isVowel(character: "u") == true
// isVowel(character: "v") == false
// isVowel(character: "w") == false
// isVowel(character: "x") == false
// isVowel(character: "y") == false
// isVowel(character: "z") == false
// isVowel(character: "A") == true
// isVowel(character: "B") == false
// isVowel(character: "C") == false
// isVowel(character: "D") == false
// isVowel(character: "E") == true
// isVowel(character: "F") == false
// isVowel(character: "G") == false
// isVowel(character: "H") == false
// isVowel(character: "I") == true
// isVowel(character: "J") == false
// isVowel(character: "K") == false
// isVowel(character: "L") == false
// isVowel(character: "M") == false
// isVowel(character: "N") == true
// isVowel(character: "O") == true
// isVowel(character: "P") == false
// isVowel

func isPalindrome(text: String) -> Bool {
    return text.reversed() == text
}
```swift
// Checks if given string is a palindrome
// isPalindrome(text: "") == true
// isPalindrome(text: "aba") == true
// isPalindrome(text: "aaaaa") == true
// isPalindrome(text: "zbcd") == false
func isPalindrome(text: String) -> Bool {
    return text.reversed() == text
}

// -----------------------------------------------------------------------------
// 1.2
// -----------------------------------------------------------------------------
// Checks if given string is a palindrome
// isPalindrome(text: "") == true
// isPalindrome(text: "aba") == true
// isPalindrome(text: "aaaaa") == true
// isPalindrome(text: "zbcd") == false
func isPalindrome(text: String) -> Bool {
    return text.reversed() == text
}

// -----------------------------------------------------------------------------
// 1.3
// -----------------------------------------------------------------------------
// Checks if given string is a palindrome
// isPalindrome(text: "") == true
// isPalindrome(text: "aba") == true
// isPalindrome(text: "aaaaa") == true
// isPalindrome(text: "zbcd") == false
func isPalindrome(text: String) -> Bool {
    return text.reversed() == text
}

// -----------------------------------------------------------------------------
// 1.4
// -----------------------------------------------------------------------------
// Checks if given string is a palindrome
// isPalindrome(text: "") == true
// isPalindrome(text: "aba") == true
// isPalindrome(text: "aaaaa") == true
// isPalindrome(text: "zbcd") == false
func isPalindrome(text: String) -> Bool {
    return text.reversed() == text
}

// -----------------------------------------------------------------------------
// 1.5
// -----------------------------------------------------------------------------
// Checks if given string is a palindrome
// isPalindrome(text: "") == true
// isPalindrome(text: "aba") == true
// isPalindrome(text: "aaaaa") == true
// isPalindrome(text: "zbcd") == false
func isPalindrome(text: String) -> Bool {
    return text.reversed() == text
}

// -----------------------------------------------------------------------------
// 1.6
// -----------------------------------------------------------------------------
// Checks if given string is a palindrome
// isPalindrome(text: "") == true
// isPalindrome(text: "aba") == true
// isPalindrome(text: "aaaaa") == true
// isPalindrome(text: "zbcd") == false
func isPalindrome(text: String) -> Bool {
    return text.reversed() == text
}

// -----------------------------------------------------------------------------
// 1.7
// -----------------------------------------------------------------------------
// Checks if given string is a palindrome
// isPalindrome(text: "") == true
// isPalindrome(text: "aba") == true
// isPalindrome(text: "aaaaa") == true
// isPalindrome(text: "zbcd") == false
func isPalindrome(text: String) -> Bool {
    return text.reversed() == text
}

// ------------------------------------------------------
return text.reversed() == text // binary operator '==' cannot be applied to operands of type '[String.Element]' (aka 'Array<Character>') and 'String'

func isPalindrome(text: String) -> Bool {
    var left = 0
    var right = text.length - 1
    while left < right {
        if text[left] != text[right] {
            return false
        }
        left += 1
        right -= 1
    }
    return true
}
```swift
// Checks if given string is a palindrome
// isPalindrome(text: "") == true
// isPalindrome(text: "aba") == true
// isPalindrome(text: "aaaaa") == true
// isPalindrome(text: "zbcd") == false
func isPalindrome(text: String) -> Bool {
    var left = 0
    var right = text.length - 1
    while left < right {
        if text[left] != text[right] {
            return false
        }
        left += 1
        right -= 1
    }
    return true
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// ---------------------------------------
var right = text.length - 1 // value of type 'String' has no member 'length'

func isPalindrome(text: String) -> Bool {
    return text == String(text.reversed())
}
```swift
// Checks if given string is a palindrome
// isPalindrome(text: "") == true
// isPalindrome(text: "aba") == true
// isPalindrome(text: "aaaaa") == true
// isPalindrome(text: "zbcd") == false
func isPalindrome(text: String) -> Bool {
    return text == String(text.reversed())
}

// -----------------------------------------------------------------------------
// 2. Write a function that takes a string and returns the number of vowels
//    in the string.
//
//    vowels("aeiou") == 5
//    vowels("bcdfghjklmnpqrstvwxyz") == 0
//    vowels("") == 0
//    vowels(" ") == 0
//    vowels("a") == 1
//    vowels("aeioua") == 5
//    vowels("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

func isPalindrome(text: String) -> Bool {
    return text == String(text.reversed())
}
```swift
// Checks if given string is a palindrome
// isPalindrome(text: "") == true
// isPalindrome(text: "aba") == true
// isPalindrome(text: "aaaaa") == true
// isPalindrome(text: "zbcd") == false
func isPalindrome(text: String) -> Bool {
    return text == String(text.reversed())
}

// -----------------------------------------------------------------------------
// 1.1
// -----------------------------------------------------------------------------
// Checks if given string is a palindrome
// isPalindrome(text: "") == true
// isPalindrome(text: "aba") == true
// isPalindrome(text: "aaaaa") == true
// isPalindrome(text: "zbcd") == false
func isPalindrome(text: String) -> Bool {
    return text == String(text.reversed())
}

// -----------------------------------------------------------------------------
// 1.2
// -----------------------------------------------------------------------------
// Checks if given string is a palindrome
// isPalindrome(text: "") == true
// isPalindrome(text: "aba") == true
// isPalindrome(text: "aaaaa") == true
// isPalindrome(text: "zbcd") == false
func isPalindrome(text: String) -> Bool {
    return text == String(text.reversed())
}

// -----------------------------------------------------------------------------
// 1.3
// -----------------------------------------------------------------------------
// Checks if given string is a palindrome
// isPalindrome(text: "") == true
// isPalindrome(text: "aba") == true
// isPalindrome(text: "aaaaa") == true
// isPalindrome(text: "zbcd") == false
func isPalindrome(text: String) -> Bool {
    return text == String(text.reversed())
}

// -----------------------------------------------------------------------------
// 1.4
// -----------------------------------------------------------------------------
// Checks if given string is a palindrome
// isPalindrome(text: "") == true
// isPalindrome(text: "aba") == true
// isPalindrome(text: "aaaaa") == true
// isPalindrome(text: "zbcd") == false
func isPalindrome(text: String) -> Bool {
    return text == String(text.reversed())
}

// -----------------------------------------------------------------------------
// 1.5
// -----------------------------------------------------------------------------
// Checks if given string is a palindrome
// isPalindrome(text: "") == true
// isPalindrome(text: "aba") == true
// isPalindrome(text: "aaaaa") == true
// isPalindrome(text: "zbcd") == false
func isPalindrome(text: String) -> Bool {
    return text == String(text.reversed())
}

// -----------------------------------------------------------------------------
// 1.6
// -----------------------------------------------------------------------------
// Checks if given string is a palindrome
// isPalindrome(text: "") == true
// isPalindrome(text: "aba") == true
// isPalindrome(text: "aaaaa") == true
// isPalindrome(text: "zbcd") == false
func isPalindrome(text: String) -> Bool {
    return text == String(text.reversed())
}

// ------------

func isPalindrome(text: String) -> Bool {
    return text == String(text.reversed())
}
```swift
// Checks if given string is a palindrome
// isPalindrome(text: "") == true
// isPalindrome(text: "aba") == true
// isPalindrome(text: "aaaaa") == true
// isPalindrome(text: "zbcd") == false
func isPalindrome(text: String) -> Bool {
    return text == String(text.reversed())
}

// -----------------------------------------------------------------------------
// 2. Write a function that takes a string as input and returns the string with all
// lowercase letters reversed.
//
// lowercaseLettersReversed(text: "") == ""
// lowercaseLettersReversed(text: "a") == "a"
// lowercaseLettersReversed(text: "A") == "a"
// lowercaseLettersReversed(text: "aBc") == "cba"
// lowercaseLettersReversed(text: "Abc") == "cba"
// lowercaseLettersReversed(text: "aBcD") == "dcba"
// lowercaseLettersReversed(text: "AbcD") == "dcba"
// lowercaseLettersReversed(text: "aBcDeFgHiJkLmNoPqRsTuVwXyZ") == "zyXwvutsrqponmlkjihgfedcba"
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 3. Write a function that takes a string as input and returns the string with all
// uppercase letters reversed.
//
// uppercaseLettersReversed(text: "") == ""
// uppercaseLettersReversed(text: "a") == "A"
// uppercaseLettersReversed(text: "A") == "a"
// uppercaseLettersReversed(text: "aBc") == "cBa"
// uppercaseLettersReversed(text: "aBcD") == "dcBa"
// uppercaseLettersReversed(text: "AbcD") == "dcBa"
// uppercaseLettersReversed(text: "aBcDeFgHiJkLmNoPqRsTuVwXyZ") == "zyXwvutsrqponmlkjihgfedcba"
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 4. Write a function that takes a string as input and returns the string with all
// lowercase letters replaced by uppercase letters and all uppercase letters
// replaced by lowercase letters.
//
// swapCase(text: "") == ""
// swapCase(text: "a") == "A"
// swapCase(text: "A") == "a"
// swapCase(text: "aBc") == "cBa"
// swapCase(text: "aBcD") == "dcBa"
// swapCase(text: "AbcD") == "dcBa"
// swapCase(text: "aBcDeFgHiJkLmNoPqRsTuVwXyZ") == "zyXwvutsrqponmlkjihgfedcba"
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 5. Write a function that takes a string as input and returns the string with all
// lowercase letters replaced by uppercase letters and all uppercase letters
// replaced by lowercase letters.
//
// swapCase(text: "") == ""
// swapCase(text: "a") == "A"
// swapCase(text: "A") == "a"
// swapCase(text: "aBc") == "cBa"
// swapCase(text: "aBcD") == "dcBa"
// swapCase(text: "AbcD") == "dcBa"
// swapCase(text: "aBcDeFgHiJkLmNoP

func isPalindrome(text: String) -> Bool {
    return text == String(text.reversed())
}
```swift
// Checks if given string is a palindrome
// isPalindrome(text: "") == true
// isPalindrome(text: "aba") == true
// isPalindrome(text: "aaaaa") == true
// isPalindrome(text: "zbcd") == false
func isPalindrome(text: String) -> Bool {
    return text == String(text.reversed())
}

// -----------------------------------------------------------------------------
// 1.1.2
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.3
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.4
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.5
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.6
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.7
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.8
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.9
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.10
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.11
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.12
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.13
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.14
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.15
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.16
// ------------------------------------------------------------------------

func isPalindrome(text: String) -> Bool {
    return text == String(text.reversed())
}
```swift
// Checks if given string is a palindrome
// isPalindrome(text: "") == true
// isPalindrome(text: "aba") == true
// isPalindrome(text: "aaaaa") == true
// isPalindrome(text: "zbcd") == false
func isPalindrome(text: String) -> Bool {
    return text == String(text.reversed())
}

// -----------------------------------------------------------------------------
// 1.2
//
// Given a string, compute recursively (no loops) a new string where all the
// lowercase 'x' chars have been changed to 'y' chars.
//
// xChangeY("") == ""
// xChangeY("x") == "y"
// xChangeY("xx") == "yy"
// xChangeY("xy") == "yx"
// xChangeY("xyx") == "yxy"
// xChangeY("xyxxy") == "yxyxy"
// xChangeY("xyxxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy

func isPalindrome(text: String) -> Bool {
    return text == String(text.reversed())
}
```swift
// Checks if given string is a palindrome
// isPalindrome(text: "") == true
// isPalindrome(text: "aba") == true
// isPalindrome(text: "aaaaa") == true
// isPalindrome(text: "zbcd") == false
func isPalindrome(text: String) -> Bool {
    return text == String(text.reversed())
}

// -----------------------------------------------------------------------------
// 1.1
// -----------------------------------------------------------------------------
// Checks if given string is a palindrome
// isPalindrome(text: "") == true
// isPalindrome(text: "aba") == true
// isPalindrome(text: "aaaaa") == true
// isPalindrome(text: "zbcd") == false
func isPalindrome(text: String) -> Bool {
    return text == String(text.reversed())
}

// -----------------------------------------------------------------------------
// 1.2
// -----------------------------------------------------------------------------
// Checks if given string is a palindrome
// isPalindrome(text: "") == true
// isPalindrome(text: "aba") == true
// isPalindrome(text: "aaaaa") == true
// isPalindrome(text: "zbcd") == false
func isPalindrome(text: String) -> Bool {
    return text == String(text.reversed())
}

// -----------------------------------------------------------------------------
// 1.3
// -----------------------------------------------------------------------------
// Checks if given string is a palindrome
// isPalindrome(text: "") == true
// isPalindrome(text: "aba") == true
// isPalindrome(text: "aaaaa") == true
// isPalindrome(text: "zbcd") == false
func isPalindrome(text: String) -> Bool {
    return text == String(text.reversed())
}

// -----------------------------------------------------------------------------
// 1.4
// -----------------------------------------------------------------------------
// Checks if given string is a palindrome
// isPalindrome(text: "") == true
// isPalindrome(text: "aba") == true
// isPalindrome(text: "aaaaa") == true
// isPalindrome(text: "zbcd") == false
func isPalindrome(text: String) -> Bool {
    return text == String(text.reversed())
}

// -----------------------------------------------------------------------------
// 1.5
// -----------------------------------------------------------------------------
// Checks if given string is a palindrome
// isPalindrome(text: "") == true
// isPalindrome(text: "aba") == true
// isPalindrome(text: "aaaaa") == true
// isPalindrome(text: "zbcd") == false
func isPalindrome(text: String) -> Bool {
    return text == String(text.reversed())
}

// -----------------------------------------------------------------------------
// 1.6
// -----------------------------------------------------------------------------
// Checks if given string is a palindrome
// isPalindrome(text: "") == true
// isPalindrome(text: "aba") == true
// isPalindrome(text: "aaaaa") == true
// isPalindrome(text: "zbcd") == false
func isPalindrome(text: String) -> Bool {
    return text == String(text.reversed())
}

// ------------

func isPalindrome(text: String) -> Bool {
    let reversed = String(text.reversed())
    return text == reversed
}
```swift
// Checks if given string is a palindrome
// isPalindrome(text: "") == true
// isPalindrome(text: "aba") == true
// isPalindrome(text: "aaaaa") == true
// isPalindrome(text: "zbcd") == false
func isPalindrome(text: String) -> Bool {
    let reversed = String(text.reversed())
    return text == reversed
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

func modp(n: Int, p: Int) -> Int {
    return pow(2, n, p)
}
```swift
// Return 2^n modulo p (be aware of numerics).
// modp(n: 3, p: 5) == 3
// modp(n: 1101, p: 101) == 2
// modp(n: 0, p: 101) == 1
// modp(n: 3, p: 11) == 8
// modp(n: 100, p: 101) == 1
func modp(n: Int, p: Int) -> Int {
    return pow(2, n, p)
}

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
//  pow
//

//
return pow(2, n, p) // cannot convert return expression of type 'Decimal' to return type 'Int'
return pow(2, n, p) // extra argument in call

func modp(n: Int, p: Int) -> Int {
    return pow(2, n, p)
}
```swift
// Return 2^n modulo p (be aware of numerics).
// modp(n: 3, p: 5) == 3
// modp(n: 1101, p: 101) == 2
// modp(n: 0, p: 101) == 1
// modp(n: 3, p: 11) == 8
// modp(n: 100, p: 101) == 1
func modp(n: Int, p: Int) -> Int {
    return pow(2, n, p)
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

public struct BigInt {
    public var digits: [Int]
    public var sign: Int

    public var isZero: Bool {
        return digits.count == 1 && digits[0] == 0
    }

    public var isNegative: Bool {
        return sign == -1
    }

    public var isPositive: Bool {
        return sign == 1
    }

    public var isEven: Bool {
        return digits.count % 2 == 0
    }

    public var isOdd: Bool {
        return digits.count % 2 == 1
    }

    public var isOne: Bool {
        return digits.count == 1 && digits[0] == 1
    }

    public var isTwo: Bool {
        return digits.count == 1 && digits[0] == 2
    }

    public var isThree: Bool {
        return digits.count == 1 && digits[0] == 3
    }

    public var isFour: Bool {
        return digits.count == 1 && digits[0] == 4
    }

    public var isFive: Bool {
        return digits.count == 1 && digits[0] == 5
    }

    public var isSix: Bool {
        return digits.count == 1 && digits[0] == 6
    }

    public var isSeven: Bool {
        return digits.count == 1 && digits[0] == 7
    }

    public var isEight: Bool {
        return digits.count == 1 && digits[0] == 8
    }

    public var isNine: Bool {
        return digits.count == 1 && digits[0] == 9
    }

    public var isTen: Bool {
        return digits.count == 1 && digits[0] == 10
    }

    public var isEleven: Bool {
        return digits.count == 1 && digits[0] == 11
    }

    public var isTwelve: Bool {
        return digits.count == 1 && digits[0] == 12
    }

    public var isThirteen: Bool {
        return digits.count == 1 && digits[0] == 13
    }

    public var isFourteen: Bool {
        return digits.count == 1 && digits[0] == 14
    }

    public var isFifteen: Bool {
        return digits.count == 1 && digits[0] == 15
    }

    public var isSixteen: Bool {
        return digits.count == 1 && digits[0] == 16
    }

    public var isSeventeen: Bool {
        return digits.count == 1 && digits[0] == 17
    }

    public var isEighteen: Bool {
        return digits.count == 1 && digits[0] == 18
    }

    public var isNineteen: Bool {
        return digits.count == 1 && digits[0] == 19
    }

    public var isTwenty: Bool {
        return digits.count == 1 && digits[0] == 20
    }

    public var isThirty: Bool {
        return digits.count == 1 && digits[0] == 30
    }

    public var isForty: Bool {
        return digits.count == 1 && digits[0] == 40
    }

    public var isFifty: Bool {
        return digits.count == 1 && digits[0] == 50
    }

    public var isSixty: Bool {
        return digits.count == 1 &&
return pow(2, n, p) // cannot convert return expression of type 'Decimal' to return type 'Int'
return pow(2, n, p) // extra argument in call

func modp(n: Int, p: Int) -> Int {
    let pow = powmod(n, p - 2, p)
    return pow % p
}
```swift
// Return 2^n modulo p (be aware of numerics).
// modp(n: 3, p: 5) == 3
// modp(n: 1101, p: 101) == 2
// modp(n: 0, p: 101) == 1
// modp(n: 3, p: 11) == 8
// modp(n: 100, p: 101) == 1
func modp(n: Int, p: Int) -> Int {
    let pow = powmod(n, p - 2, p)
    return pow % p
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
let pow = powmod(n, p - 2, p) // cannot find 'powmod' in scope

func modp(n: Int, p: Int) -> Int {
    return pow(2, n, p)
}
```swift
// Return 2^n modulo p (be aware of numerics).
// modp(n: 3, p: 5) == 3
// modp(n: 1101, p: 101) == 2
// modp(n: 0, p: 101) == 1
// modp(n: 3, p: 11) == 8
// modp(n: 100, p: 101) == 1
func modp(n: Int, p: Int) -> Int {
    return pow(2, n, p)
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ------------------------------
return pow(2, n, p) // cannot convert return expression of type 'Decimal' to return type 'Int'
return pow(2, n, p) // extra argument in call

func modp(n: Int, p: Int) -> Int {
    return pow(2, n, p)
}
```swift
// Return 2^n modulo p (be aware of numerics).
// modp(n: 3, p: 5) == 3
// modp(n: 1101, p: 101) == 2
// modp(n: 0, p: 101) == 1
// modp(n: 3, p: 11) == 8
// modp(n: 100, p: 101) == 1
func modp(n: Int, p: Int) -> Int {
    return pow(2, n, p)
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ------------------------------
return pow(2, n, p) // cannot convert return expression of type 'Decimal' to return type 'Int'
return pow(2, n, p) // extra argument in call

func modp(n: Int, p: Int) -> Int {
    return pow(2, n, p)
}
```swift
// Return 2^n modulo p (be aware of numerics).
// modp(n: 3, p: 5) == 3
// modp(n: 1101, p: 101) == 2
// modp(n: 0, p: 101) == 1
// modp(n: 3, p: 11) == 8
// modp(n: 100, p: 101) == 1
func modp(n: Int, p: Int) -> Int {
    return pow(2, n, p)
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ------------------------------------
return pow(2, n, p) // cannot convert return expression of type 'Decimal' to return type 'Int'
return pow(2, n, p) // extra argument in call

func modp(n: Int, p: Int) -> Int {
    return pow(2, n, p)
}

struct Solution {
    var result: Int
}

func main() {
    let input = readInput()
    let solution = Solution(result: 0)
    solve(input: input, solution: &solution)
    print(solution.result)
}

func readInput() -> Int {
    let input = readLines()
    return Int(input[0])!
}

func solve(input: Int, solution: inout Solution) {
    solution.result = modp(n: input, p: 101)
}

func readLines() -> [String] {
    let lines = readInput()
    return lines.split(separator: "\n").map { $0 }
}

func readInput() -> String {
    let file = open("input.txt")
    let input = read(from: file)
    close(file)
    return input
}

func print(input: Int) {
    print(input)
}

func print(input: [Int]) {
    print(input.map { $0 }.map { "\($0)" }.join(separator: ", "))
}

func print(input: [String]) {
    print(input.map { $0 }.map { "\($0)" }.join(separator: ", "))
}

func print(input: [Int], separator: String) {
    print(input.map { $0 }.map { "\($0)" }.join(separator: separator))
}

func print(input: [String], separator: String) {
    print(input.map { $0 }.map { "\($0)" }.join(separator: separator))
}

func print(input: Int, separator: String) {
    print(input, separator: separator)
}

func print(input: Int, separator: String, terminator: String) {
    print(input, separator: separator, terminator: terminator)
}

func print(input: [Int], separator: String, terminator: String) {
    print(input.map { $0 }.map { "\($0)" }.join(separator: separator), terminator: terminator)
}

func print(input: [String], separator: String, terminator: String) {
    print(input.map { $0 }.map { "\($0)" }.join(separator: separator), terminator: terminator)
}
```swift
// Return 2^n modulo p (be aware of numerics).
// modp(n: 3, p: 5) == 3
// modp(n: 1101, p: 101) == 2
// modp(n: 0, p: 101) == 1
// modp(n: 3, p: 11) == 8
// modp(n: 100, p: 101) == 1
func modp(n: Int, p: Int) -> Int {
    return pow(2, n, p)
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

struct Solution {
    var result: Int
}

func main() {
    let input = readInput()
    let solution = Solution(result: 0)
    solve(input: input, solution: &solution)
    print(solution.result)
}

func readInput() -> Int {
    let input = readLines()
    return Int(input[0])!
}

func solve(input: Int, solution: inout Solution) {
    solution.result = modp(n: input, p: 101)
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

func readLines() -> [String] {
    let lines = readInput()
    return lines.split(separator: "\n").map { $0 }
}

func readInput() -> String {
    let file = open("input.txt")
    let input = read(from: file)
    close(file)
    return input
}

func print(input: Int) {
    print(input)
}

func print(input: [Int]) {
    print(input.map { $0 }.map { "\($0)" }.join(separator: ", "))
}

func print(input: [String]) {
    print(input.map { $0 }.map { "\($0)" }.join(separator: ", "))
}

func print(input: [Int], separator: String) {
    print(input.map { $0 }.map { "\($0)" }.join(separator: separator))
}

func print(input: [String], separator: String) {
    print(input.map { $0 }.map { "\($0)" }.join(separator: separator))
}

func print(input: Int, separator: String) {
    print(input, separator: separator)
}

func print(input: [Int], separator: String) {
    print(input.map { $0 }.map { "\($0)" }.join(separator: separator))
}

func print(input: [String], separator: String) {
    print(input.map { $0 }.map { "\($0)" }.join(separator: separator))
}

func print(input: Int, separator: String, terminator: String) {
    print(input, separator: separator, terminator: terminator)
}

func print(input: [Int], separator: String, terminator: String) {
    print(input.map { $0 }.map { "\($0)" }.join(separator: separator), terminator: terminator)
}

func print(input: [String], separator: String, terminator: String) {
    print(input.map { $0 }.map { "\($0)" }.join(separator: separator), terminator: terminator)
}

func print(input: Int, separator: String, terminator: String) {
    print(input, separator: separator, terminator: terminator)
}

func print(input: [Int], separator: String, terminator: String) {
    print(input.map { $0 }.map { "\($0)" }.join(separator: separator), terminator: terminator)
}

func print(input: [String], separator: String, terminator: String) {
    print(input.map { $0 }.map { "\($0)" }.
return pow(2, n, p) // cannot convert return expression of type 'Decimal' to return type 'Int'
return pow(2, n, p) // extra argument in call
let input = readInput() // ambiguous use of 'readInput()'
solve(input: input, solution: &solution) // cannot pass immutable value as inout argument: 'solution' is a 'let' constant
let lines = readInput() // ambiguous use of 'readInput()'
let file = open("input.txt") // missing argument for parameter #2 in call
let input = read(from: file) // missing arguments for parameters #2, #3 in call
let input = read(from: file) // extraneous argument label 'from:' in call
print(input.map { $0 }.map { "\($0)" }.join(separator: ", ")) // value of type '[String]' has no member 'join'
print(input.map { $0 }.map { "\($0)" }.join(separator: ", ")) // value of type '[String]' has no member 'join'
print(input.map { $0 }.map { "\($0)" }.join(separator: separator)) // value of type '[String]' has no member 'join'
print(input.map { $0 }.map { "\($0)" }.join(separator: separator)) // value of type '[String]' has no member 'join'
print(input.map { $0 }.map { "\($0)" }.join(separator: separator), terminator: terminator) // value of type '[String]' has no member 'join'
print(input.map { $0 }.map { "\($0)" }.join(separator: separator), terminator: terminator) // value of type '[String]' has no member 'join'

func modp(n: Int, p: Int) -> Int {
    return pow(2, n, p)
}
```swift
// Return 2^n modulo p (be aware of numerics).
// modp(n: 3, p: 5) == 3
// modp(n: 1101, p: 101) == 2
// modp(n: 0, p: 101) == 1
// modp(n: 3, p: 11) == 8
// modp(n: 100, p: 101) == 1
func modp(n: Int, p: Int) -> Int {
    return pow(2, n, p)
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ------------------------------
return pow(2, n, p) // cannot convert return expression of type 'Decimal' to return type 'Int'
return pow(2, n, p) // extra argument in call

func modp(n: Int, p: Int) -> Int {
    return pow(2, n, p)
}
```swift
// Return 2^n modulo p (be aware of numerics).
// modp(n: 3, p: 5) == 3
// modp(n: 1101, p: 101) == 2
// modp(n: 0, p: 101) == 1
// modp(n: 3, p: 11) == 8
// modp(n: 100, p: 101) == 1
func modp(n: Int, p: Int) -> Int {
    return pow(2, n, p)
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ------------------------------
return pow(2, n, p) // cannot convert return expression of type 'Decimal' to return type 'Int'
return pow(2, n, p) // extra argument in call

func modp(n: Int, p: Int) -> Int {
    return pow(2, n, p)
}
```swift
// Return 2^n modulo p (be aware of numerics).
// modp(n: 3, p: 5) == 3
// modp(n: 1101, p: 101) == 2
// modp(n: 0, p: 101) == 1
// modp(n: 3, p: 11) == 8
// modp(n: 100, p: 101) == 1
func modp(n: Int, p: Int) -> Int {
    return pow(2, n, p)
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ------------------------------
return pow(2, n, p) // cannot convert return expression of type 'Decimal' to return type 'Int'
return pow(2, n, p) // extra argument in call

func removeVowels(text: String) -> String {
    var result = ""
    for char in text {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}
```swift
// remove_vowels is a function that takes string and returns string without vowels.
// removeVowels(text: "") == ""
// removeVowels(text: "abcdef") == "bcdf"
// removeVowels(text: "aaaaa") == ""
// removeVowels(text: "aaBAA") == "B"
// removeVowels(text: "zbcd") == "zbcd"
func removeVowels(text: String) -> String {
    var result = ""
    for char in text {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 2. Write a function that takes a string and returns a new string with all
//    vowels removed.
//
//    remove_vowels("") == ""
//    remove_vowels("abcdef") == "bcdf"
//    remove_vowels("aaaaa") == ""
//    remove_vowels("aaBAA") == "B"
//    remove_vowels("zbcd") == "zbcd"
//
//    You may assume the input will always be a string.
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 3. Write a function that takes a string and returns a new string with all
//    vowels removed.
//
//    remove_vowels("") == ""
//    remove_vowels("abcdef") == "bcdf"
//    remove_vowels("aaaaa") == ""
//    remove_vowels("aaBAA") == "B"
//    remove_vowels("zbcd") == "zbcd"
//
//    You may assume the input will always be a string.
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 4. Write a function that takes a string and returns a new string with all
//    vowels removed.
//
//    remove_vowels("") == ""
//    remove_vowels("abcdef") == "bcdf"
//    remove_vowels("aaaaa") == ""
//    remove_vowels("aaBAA") == "B"
//    remove_vowels("zbcd") == "zbcd"
//
//    You may assume the input will always be a string.
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 5. Write a function that takes a string and returns a new string with all
//    vowels removed.
//
//    remove_vowels("") == ""
//    remove_vowels("abcdef") == "bcdf"
//    remove_vowels("aaaaa") == ""
//    remove_vowels("aaBAA") == "B"
//    remove_vowels("zbcd") == "zbcd"
//
//    You may assume the input will always be a string.
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 6. Write a function that takes a string and returns a new string with all
//    vowels removed.
//
//    remove_vowels("") == ""
//    remove_vowels("abcdef") == "bcdf"
//    remove_vowels("aaaaa") == ""
//    remove_vowels("aaBAA") == "B"
//    remove_vowels("zbcd") == "zbcd"
//
//    You may assume the input will always be a string.
// ---------------------------------
result += char // cannot convert value of type 'Character' to expected argument type 'String'

func removeVowels(text: String) -> String {
    var result = ""
    for char in text {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

func makeTitle(text: String) -> String {
    var result = ""
    var words = text.split(" ")
    for word in words {
        result += word.capitalized
    }
    return result
}
```swift
// remove_vowels is a function that takes string and returns string without vowels.
// removeVowels(text: "") == ""
// removeVowels(text: "abcdef") == "bcdf"
// removeVowels(text: "aaaaa") == ""
// removeVowels(text: "aaBAA") == "B"
// removeVowels(text: "zbcd") == "zbcd"
func removeVowels(text: String) -> String {
    var result = ""
    for char in text {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// 12. Write a function that takes a string and returns a string with the first letter of each word capitalized.
// makeTitle("the quick brown fox") == "The Quick Brown Fox"
// makeTitle("t") == "T"
// makeTitle("") == ""
// makeTitle("a b c d e f g h i j k l m n o p q r s t u v w x y z") == "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"
func makeTitle(text: String) -> String {
    var result = ""
    var words = text.split(" ")
    for word in words {
        result += word.capitalized
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// 13. Write a function that takes a string and returns a string with the first letter of each word capitalized.
// makeTitle("the quick brown fox") == "The Quick Brown Fox"
// makeTitle("t") == "T"
// makeTitle("") == ""
// makeTitle("a b c d e f g h i j k l m n o p q r s t u v w x y z") == "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"
func makeTitle(text: String) -> String {
    var result = ""
    var words = text.split(" ")
    for word in words {
        result += word.capitalized
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// 14. Write a function that takes a string and returns a string with the first letter of each word capitalized.
// makeTitle("the quick brown fox") == "The Quick Brown Fox"
// makeTitle("t") == "T"
// makeTitle("") == ""
// makeTitle("a b c d e f g h i j k l m n o p q r s t u v w x y z") == "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"
func makeTitle(text: String) -> String {
    var result = ""
    var words = text.split(" ")
    for word in words {
        result += word.capitalized
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// 15. Write a function that takes a string and returns a string with the first letter of each word capitalized.
// makeTitle("the quick brown fox") == "The Quick Brown Fox"
// makeTitle("t") == "T"
// makeTitle("") == ""
// makeTitle("a b c d e f g h i j k l m n o p q r s t u v w x y z") == "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"
func makeTitle(text: String) -> String {
    var result = ""
    var words = text.split(" ")
    for word in words {
        result += word.capitalized
    }
    return result
}

// ------------------------------------------
result += char // cannot convert value of type 'Character' to expected argument type 'String'
var words = text.split(" ") // no exact matches in call to instance method 'split'

func removeVowels(text: String) -> String {
    var result = ""
    for char in text {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}
```swift
// remove_vowels is a function that takes string and returns string without vowels.
// removeVowels(text: "") == ""
// removeVowels(text: "abcdef") == "bcdf"
// removeVowels(text: "aaaaa") == ""
// removeVowels(text: "aaBAA") == "B"
// removeVowels(text: "zbcd") == "zbcd"
func removeVowels(text: String) -> String {
    var result = ""
    for char in text {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 2. Write a function that takes a string and returns a string with the first
//    character of each word capitalized.
//
//    capitalizeFirst("") == ""
//    capitalizeFirst("abc def") == "Abc Def"
//    capitalizeFirst("cat dog") == "Cat Dog"
//    capitalizeFirst("cat dog dog") == "Cat Dog Dog"
//    capitalizeFirst("cat dog dog cat") == "Cat Dog Dog Cat"
//    capitalizeFirst("cat dog dog cat dog") == "Cat Dog Dog Cat Dog"
//    capitalizeFirst("cat dog dog cat dog dog") == "Cat Dog Dog Cat Dog Dog"
//    capitalizeFirst("cat dog dog cat dog dog dog") == "Cat Dog Dog Cat Dog Dog Dog"
//    capitalizeFirst("cat dog dog cat dog dog dog dog") == "Cat Dog Dog Cat Dog Dog Dog Dog"
//    capitalizeFirst("cat dog dog cat dog dog dog dog dog") == "Cat Dog Dog Cat Dog Dog Dog Dog Dog"
//    capitalizeFirst("cat dog dog cat dog dog dog dog dog dog") == "Cat Dog Dog Cat Dog Dog Dog Dog Dog Dog"
//    capitalizeFirst("cat dog dog cat dog dog dog dog dog dog dog") == "Cat Dog Dog Cat Dog Dog Dog Dog Dog Dog Dog"
//    capitalizeFirst("cat dog dog cat dog dog dog dog dog dog dog dog") == "Cat Dog Dog Cat Dog Dog Dog Dog Dog Dog Dog Dog"
//    capitalizeFirst("cat dog dog cat dog dog dog dog dog dog dog dog dog") == "Cat Dog Dog Cat Dog Dog Dog Dog Dog Dog Dog Dog Dog"
//    capitalizeFirst("cat dog dog cat dog dog dog dog dog dog dog dog dog dog") == "Cat Dog Dog Cat Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog"
//    capitalizeFirst("cat dog dog cat dog dog dog dog dog dog dog dog dog dog dog") == "Cat Dog Dog Cat Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog"
//    capitalizeFirst("cat dog dog cat dog dog dog dog dog dog dog dog dog dog dog dog") == "Cat Dog Dog Cat Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog"
//    capitalizeFirst("cat dog dog cat dog dog dog dog dog dog dog dog dog dog dog dog dog") == "Cat Dog Dog Cat Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog"
//    capitalizeFirst("cat dog dog cat dog dog dog dog dog dog dog dog dog dog dog dog dog dog") == "Cat Dog Dog Cat Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog"
//    capitalizeFirst("cat dog dog cat dog dog dog dog dog dog dog dog dog dog dog dog dog dog dog") == "Cat Dog Dog Cat Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog"
//    capitalizeFirst("cat dog dog cat dog dog dog dog dog dog dog dog dog dog dog dog dog dog dog dog") == "Cat Dog Dog Cat Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog"
//    capitalizeFirst("cat dog dog cat dog dog dog dog dog dog dog dog dog dog dog dog dog dog dog dog dog dog") == "Cat Dog Dog Cat Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog"
//    capitalizeFirst("cat dog dog cat dog dog dog dog dog dog dog dog dog dog dog dog dog dog dog dog dog dog dog") == "Cat Dog Dog Cat Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog"
//    capitalizeFirst("cat dog dog cat dog dog dog dog dog dog dog dog dog dog dog dog dog dog dog dog dog dog dog dog") == "Cat Dog Dog Cat Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog Dog"
//    capitalizeFirst("cat dog dog cat dog dog dog dog dog dog dog dog dog dog dog dog dog
result += char // cannot convert value of type 'Character' to expected argument type 'String'

func removeVowels(text: String) -> String {
    let vowels = "aeiouAEIOU"
    var result = ""
    for char in text {
        if !vowels.contains(char) {
            result += char
        }
    }
    return result
}
```swift
// remove_vowels is a function that takes string and returns string without vowels.
// removeVowels(text: "") == ""
// removeVowels(text: "abcdef") == "bcdf"
// removeVowels(text: "aaaaa") == ""
// removeVowels(text: "aaBAA") == "B"
// removeVowels(text: "zbcd") == "zbcd"
func removeVowels(text: String) -> String {
    let vowels = "aeiouAEIOU"
    var result = ""
    for char in text {
        if !vowels.contains(char) {
            result += char
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.1.11
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.12
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.13
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.14
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.15
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.16
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.17
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.18
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.19
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.20
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.21
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.22
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.23
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.24
// -----------------------------------------------------------------------------

// ---------------------------
result += char // cannot convert value of type 'Character' to expected argument type 'String'

func removeVowels(text: String) -> String {
    var result = ""
    for char in text {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

func capitalizeFirstLetter(text: String) -> String {
    return String(text.first!.uppercased) + text.substring(1)
}
```swift
// remove_vowels is a function that takes string and returns string without vowels.
// removeVowels(text: "") == ""
// removeVowels(text: "abcdef") == "bcdf"
// removeVowels(text: "aaaaa") == ""
// removeVowels(text: "aaBAA") == "B"
// removeVowels(text: "zbcd") == "zbcd"
func removeVowels(text: String) -> String {
    var result = ""
    for char in text {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// 2. Write a function that takes a string and returns a string with the first letter capitalized.
// capitalizeFirstLetter("") == ""
// capitalizeFirstLetter("abc") == "Abc"
// capitalizeFirstLetter("aBc") == "ABc"
// capitalizeFirstLetter("aBC") == "ABC"
// capitalizeFirstLetter("aBCd") == "ABCd"
func capitalizeFirstLetter(text: String) -> String {
    return String(text.first!.uppercased) + text.substring(1)
}

// 3. Write a function that takes a string and returns a string with the first letter of each word capitalized.
// capitalizeFirstLetterOfEachWord("") == ""
// capitalizeFirstLetterOfEachWord("abc") == "Abc"
// capitalizeFirstLetterOfEachWord("aBc") == "ABc"
// capitalizeFirstLetterOfEachWord("aBC") == "ABC"
// capitalizeFirstLetterOfEachWord("aBCd") == "ABCd"
// capitalizeFirstLetterOfEachWord("aBCdef") == "ABCdef"
// capitalizeFirstLetterOfEachWord("aBCdefg") == "ABCdefg"
// capitalizeFirstLetterOfEachWord("aBCdefgh") == "ABCdefgh"
// capitalizeFirstLetterOfEachWord("aBCdefghi") == "ABCdefghi"
// capitalizeFirstLetterOfEachWord("aBCdefghij") == "ABCdefghij"
// capitalizeFirstLetterOfEachWord("aBCdefghijk") == "ABCdefghijk"
// capitalizeFirstLetterOfEachWord("aBCdefghijkl") == "ABCdefghijkl"
// capitalizeFirstLetterOfEachWord("aBCdefghijklm") == "ABCdefghijklm"
// capitalizeFirstLetterOfEachWord("aBCdefghijklmn") == "ABCdefghijklmn"
// capitalizeFirstLetterOfEachWord("aBCdefghijklmno") == "ABCdefghijklmno"
// capitalizeFirstLetterOfEachWord("aBCdefghijklmno") == "ABCdefghijklmno"
// capitalizeFirstLetterOfEachWord("aBCdefghijklmno") == "ABCdefghijklmno"
// capitalizeFirstLetterOfEachWord("aBCdefghijklmno") == "ABCdefghijklmno"
// capitalizeFirstLetterOfEachWord("aBCdefghijklmno") == "ABCdefghijklmno"
// capitalizeFirstLetterOfEachWord("aBCdefghijklmno") == "ABCdefghijklmno"
// capitalizeFirstLetterOfEachWord("aBCdefghijklmno") == "ABCdefghijklmno"
// capitalizeFirstLetterOfEachWord("aBCdefghijklmno") == "ABCdefghijklmno"
// capitalizeFirstLetterOfEachWord("aBCdefghijklmno") == "ABCdefghijklmno"
// capitalizeFirstLetterOfEachWord("aBCdefghijklmno") == "ABCdefghijklmno"
// capitalizeFirstLetterOfEachWord("aBCdefghijklmno") == "ABCdefghijklmno"
// capitalizeFirstLetterOfEachWord("aBCdefghijklmno") == "ABCdefghijklmno"
// capitalizeFirstLetterOfEachWord("aBCdefghijklmno") == "ABCdefghijklmno"
// capitalizeFirstLetterOfEachWord("aBCdefghijklmno") == "ABCdefghijklmno"
// capitalizeFirstLetterOfEachWord("aBCdefghijklmno") == "ABC
result += char // cannot convert value of type 'Character' to expected argument type 'String'
return String(text.first!.uppercased) + text.substring(1) // type '() -> String' cannot conform to 'LosslessStringConvertible'
return String(text.first!.uppercased) + text.substring(1) // no exact matches in call to instance method 'substring'

func removeVowels(text: String) -> String {
    var result = ""
    for char in text {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}
```swift
// remove_vowels is a function that takes string and returns string without vowels.
// removeVowels(text: "") == ""
// removeVowels(text: "abcdef") == "bcdf"
// removeVowels(text: "aaaaa") == ""
// removeVowels(text: "aaBAA") == "B"
// removeVowels(text: "zbcd") == "zbcd"
func removeVowels(text: String) -> String {
    var result = ""
    for char in text {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// 2. Write a function that takes a string and returns a string with the first letter capitalized.
// capitalizeFirstLetter(text: "") == ""
// capitalizeFirstLetter(text: "abcdef") == "Abcdef"
// capitalizeFirstLetter(text: "aBcDeF") == "ABcdef"
// capitalizeFirstLetter(text: "Abcdef") == "Abcdef"
// capitalizeFirstLetter(text: "aBcdef") == "ABcdef"
// capitalizeFirstLetter(text: "Abcdefg") == "Abcdefg"
// capitalizeFirstLetter(text: "AbcdefG") == "AbcdefG"
// capitalizeFirstLetter(text: "AbcdefGh") == "AbcdefGh"
// capitalizeFirstLetter(text: "AbcdefGhI") == "AbcdefGhI"
// capitalizeFirstLetter(text: "AbcdefGhIj") == "AbcdefGhIj"
// capitalizeFirstLetter(text: "AbcdefGhIjK") == "AbcdefGhIjK"
// capitalizeFirstLetter(text: "AbcdefGhIjKl") == "AbcdefGhIjKl"
// capitalizeFirstLetter(text: "AbcdefGhIjKlm") == "AbcdefGhIjKlm"
// capitalizeFirstLetter(text: "AbcdefGhIjKlmn") == "AbcdefGhIjKlmn"
// capitalizeFirstLetter(text: "AbcdefGhIjKlmnop") == "AbcdefGhIjKlmnop"
// capitalizeFirstLetter(text: "AbcdefGhIjKlmnopQ") == "AbcdefGhIjKlmnopQ"
// capitalizeFirstLetter(text: "AbcdefGhIjKlmnopQr") == "AbcdefGhIjKlmnopQr"
// capitalizeFirstLetter(text: "AbcdefGhIjKlmnopQrs") == "AbcdefGhIjKlmnopQrs"
// capitalizeFirstLetter(text: "AbcdefGhIjKlmnopQrsT") == "AbcdefGhIjKlmnopQrsT"
// capitalizeFirstLetter(text: "AbcdefGhIjKlmnopQrsTu") == "AbcdefGhIjKlmnopQrsTu"
// capitalizeFirstLetter(text: "AbcdefGhIjKlmnopQrsTuv") == "AbcdefGhIjKlmnopQrsTuv"
// capitalizeFirstLetter(text: "AbcdefGhIjKlmnopQrsTuvW") == "AbcdefGhIjKlmnopQrsTuvW"
// capitalizeFirstLetter(text: "AbcdefGhIjKlmnopQrsTuvWX") == "AbcdefGhIjKlmnopQrsTuvWX"
// capitalizeFirstLetter(text: "AbcdefGhIjKlmnopQrsTuvWXY") == "AbcdefGhIjKlmnopQrsTuvWXY"
// capitalizeFirstLetter(text: "AbcdefGhIjKlmnopQrsTuvWXYZ") == "AbcdefGhIjKlmnopQrsTuvWXYZ"
// capitalizeFirstLetter(text: "AbcdefGhIjKlmnopQrsTuvWXYZa") == "AbcdefGhIjKlmnopQrsTuvWXYZa"
// capitalizeFirstLetter(text: "AbcdefGhIjKlmnopQrsTuvW
result += char // cannot convert value of type 'Character' to expected argument type 'String'

func removeVowels(text: String) -> String {
    var result = ""
    for char in text {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

func capitalizeFirstLetter(text: String) -> String {
    if text.isEmpty {
        return ""
    }
    return String(text.first!.uppercased() + text.dropFirst())
}

func lowercase(text: String) -> String {
    return text.lowercased
}

func uppercase(text: String) -> String {
    return text.uppercased
}

func swapCase(text: String) -> String {
    return text.swapCase
}

func reverse(text: String) -> String {
    return String(text.reversed)
}

func capitalizeFirstLetter(text: String) -> String {
    return String(text.capitalized)
}
```swift
// remove_vowels is a function that takes string and returns string without vowels.
// removeVowels(text: "") == ""
// removeVowels(text: "abcdef") == "bcdf"
// removeVowels(text: "aaaaa") == ""
// removeVowels(text: "aaBAA") == "B"
// removeVowels(text: "zbcd") == "zbcd"
func removeVowels(text: String) -> String {
    var result = ""
    for char in text {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// 2. Write a function that takes a string and returns a string with the first letter capitalized.
// capitalizeFirstLetter("") == ""
// capitalizeFirstLetter("a") == "A"
// capitalizeFirstLetter("hello") == "Hello"
// capitalizeFirstLetter("hElLo") == "Hello"
// capitalizeFirstLetter("hElLo world") == "Hello world"
func capitalizeFirstLetter(text: String) -> String {
    if text.isEmpty {
        return ""
    }
    return String(text.first!.uppercased() + text.dropFirst())
}

// 3. Write a function that takes a string and returns a string with all the letters converted to lowercase.
// lowercase("") == ""
// lowercase("A") == "a"
// lowercase("Hello") == "hello"
// lowercase("hElLo") == "hello"
// lowercase("hElLo world") == "hello world"
func lowercase(text: String) -> String {
    return text.lowercased
}

// 4. Write a function that takes a string and returns a string with all the letters converted to uppercase.
// uppercase("") == ""
// uppercase("A") == "A"
// uppercase("Hello") == "HELLO"
// uppercase("hElLo") == "HELLO"
// uppercase("hElLo world") == "HELLO WORLD"
func uppercase(text: String) -> String {
    return text.uppercased
}

// 5. Write a function that takes a string and returns a string with all the letters converted to uppercase.
// swapCase("") == ""
// swapCase("A") == "a"
// swapCase("Hello") == "hElLo"
// swapCase("hElLo") == "HELLO"
// swapCase("hElLo world") == "hElLo WORLD"
func swapCase(text: String) -> String {
    return text.swapCase
}

// 6. Write a function that takes a string and returns a string with all the letters converted to uppercase.
// reverse("") == ""
// reverse("a") == "a"
// reverse("Hello") == "olleH"
// reverse("hElLo") == "olleH"
// reverse("hElLo world") == "dlrow olleH"
func reverse(text: String) -> String {
    return String(text.reversed)
}

// 7. Write a function that takes a string and returns a string with all the letters converted to uppercase.
// capitalizeFirstLetter("") == ""
// capitalizeFirstLetter("a") == "A"
// capitalizeFirstLetter("hello") == "Hello"
// capitalizeFirstLetter("hElLo") == "Hello"
// capitalizeFirstLetter("hElLo world") == "Hello world"
// capitalizeFirstLetter("hElLo world hello") == "Hello world hello"
func capitalizeFirstLetter(text: String) -> String {
    return String(text.capitalized)
}

// 8. Write a function that takes a string and returns a string with all the letters converted to uppercase.
// capitalizeFirstLetter("") == ""
// capitalizeFirstLetter("a") == "A"
// capitalizeFirstLetter("hello") == "Hello"
// capitalizeFirstLetter("hElLo") == "Hello"
// capitalizeFirstLetter("hElLo world") == "Hello world"
// capitalizeFirstLetter("hElLo world hello") == "Hello world hello"
// capitalizeFirstLetter("hElLo world hello world") == "Hello world hello world"
func capitalizeFirstLetter(text: String) -> String
result += char // cannot convert value of type 'Character' to expected argument type 'String'
return text.lowercased // function produces expected type 'String'; did you mean to call it with '()'?
return text.uppercased // function produces expected type 'String'; did you mean to call it with '()'?
return text.swapCase // value of type 'String' has no member 'swapCase'
return String(text.reversed) // no exact matches in call to initializer
func capitalizeFirstLetter(text: String) -> String { // invalid redeclaration of 'capitalizeFirstLetter(text:)'

func removeVowels(text: String) -> String {
    var result = ""
    for char in text {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}
```swift
// remove_vowels is a function that takes string and returns string without vowels.
// removeVowels(text: "") == ""
// removeVowels(text: "abcdef") == "bcdf"
// removeVowels(text: "aaaaa") == ""
// removeVowels(text: "aaBAA") == "B"
// removeVowels(text: "zbcd") == "zbcd"
func removeVowels(text: String) -> String {
    var result = ""
    for char in text {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// Task 2
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// Task 2.1
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// Task 2.2
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// Task 2.3
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// Task 2.4
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// Task 2.5
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// Task 2.6
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// Task 2.7
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// Task 2.8
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// Task 2.9
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// Task 2.10
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// Task 2.11
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// Task 2.12
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// Task 2.13
// -----------------------------------------------------------------------------

// ------------------------------------------------------------
result += char // cannot convert value of type 'Character' to expected argument type 'String'

func removeVowels(text: String) -> String {
    var result = ""
    for char in text {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

func capitalizeFirstLetter(text: String) -> String {
    return String(text.first!.uppercaseString) + text.substring(1)
}

func reverseLetters(text: String) -> String {
    return String(text.reversed())
}

func reverseWords(text: String) -> String {
    return String(text.split(" ").reversed())
}

func alphabetPosition(text: String) -> String {
    var result = ""
    for char in text {
        if char.isAlpha {
            result += String(char.asciiValue - 96) + " "
        }
    }
    return result.trim()
}
```swift
// remove_vowels is a function that takes string and returns string without vowels.
// removeVowels(text: "") == ""
// removeVowels(text: "abcdef") == "bcdf"
// removeVowels(text: "aaaaa") == ""
// removeVowels(text: "aaBAA") == "B"
// removeVowels(text: "zbcd") == "zbcd"
func removeVowels(text: String) -> String {
    var result = ""
    for char in text {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// 2. Write a function that takes a string and returns a string with the first letter capitalized.
// capitalizeFirstLetter(text: "") == ""
// capitalizeFirstLetter(text: "abcdef") == "Abcdef"
// capitalizeFirstLetter(text: "aaaaa") == "Aaaaa"
// capitalizeFirstLetter(text: "aaBAA") == "AaBAA"
// capitalizeFirstLetter(text: "zbcd") == "Zbcd"
func capitalizeFirstLetter(text: String) -> String {
    return String(text.first!.uppercaseString) + text.substring(1)
}

// 3. Write a function that takes a string and returns a string with all the letters reversed.
// reverseLetters(text: "") == ""
// reverseLetters(text: "abcdef") == "fedcba"
// reverseLetters(text: "aaaaa") == "aaaaa"
// reverseLetters(text: "aaBAA") == "aAAb"
// reverseLetters(text: "zbcd") == "dczb"
func reverseLetters(text: String) -> String {
    return String(text.reversed())
}

// 4. Write a function that takes a string and returns a string with all the words reversed.
// reverseWords(text: "") == ""
// reverseWords(text: "abc def") == "def abc"
// reverseWords(text: "aaaaa") == "aaaaa"
// reverseWords(text: "aaBAA") == "BAAaa"
// reverseWords(text: "zbcd") == "dczb"
func reverseWords(text: String) -> String {
    return String(text.split(" ").reversed())
}

// 5. Write a function that takes a string and returns a string with all the letters replaced by their position in the alphabet.
// alphabetPosition(text: "") == ""
// alphabetPosition(text: "abcdef") == "1 2 3 4 5 6"
// alphabetPosition(text: "aaaaa") == "1 1 1 1 1"
// alphabetPosition(text: "aaBAA") == "1 2 3 1 2"
// alphabetPosition(text: "zbcd") == "2 3 4 5"
func alphabetPosition(text: String) -> String {
    var result = ""
    for char in text {
        if char.isAlpha {
            result += String(char.asciiValue - 96) + " "
        }
    }
    return result.trim()
}

// 6. Write a function that takes a string and returns a string with all the letters replaced by their position in the alphabet.
// alphabetPosition(text: "") == ""
// alphabetPosition(text: "abcdef") == "1 2 3 4 5 6"
// alphabetPosition(text: "aaaaa") == "1 1 1 1 1"
// alphabetPosition(text: "aaBAA") == "1 2 3 1 2"
// alphabetPosition(text: "zbcd") == "2 3 4 5"
func alphabetPosition(text: String) -> String {
    var result = ""
    for char in text {
        if char.isAlpha {
            result += String(char.asciiValue - 96) + " "
        }
    }
    return result.trim()
}

// 7. Write a function that takes a string and returns a string with all the letters replaced by their position in the alphabet.
// alphabetPosition(text: "") == ""
// alphabetPosition(text: "abcdef") == "1 2 3 4 5 6"
// alphabetPosition(text: "aaaaa") == "1 1 1 1 1"
// alphabetPosition(text: "aaBAA") == "
result += char // cannot convert value of type 'Character' to expected argument type 'String'
return String(text.first!.uppercaseString) + text.substring(1) // value of type 'String.Element' (aka 'Character') has no member 'uppercaseString'
return String(text.first!.uppercaseString) + text.substring(1) // no exact matches in call to instance method 'substring'
return String(text.split(" ").reversed()) // no exact matches in call to instance method 'split'
return String(text.split(" ").reversed()) // initializer 'init(_:)' requires the types 'ReversedCollection<[ArraySlice<String.Element>]>.Element' (aka 'ArraySlice<Character>') and 'Character' be equivalent
if char.isAlpha { // value of type 'Character' has no member 'isAlpha'
result += String(char.asciiValue - 96) + " " // value of optional type 'UInt8?' must be unwrapped to a value of type 'UInt8'
return result.trim() // value of type 'String' has no member 'trim'

func removeVowels(text: String) -> String {
    var result = ""
    for char in text {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

func capitalizeFirstLetter(text: String) -> String {
    if text.isEmpty {
        return ""
    }
    return String(text.first!.uppercased) + text.substring(1)
}

func capitalizeFirstAndLastLetters(text: String) -> String {
    if text.isEmpty {
        return ""
    }
    return String(text.first!.uppercased) + text.substring(1, text.count - 1) + String(text.last!.uppercased)
}
```swift
// remove_vowels is a function that takes string and returns string without vowels.
// removeVowels(text: "") == ""
// removeVowels(text: "abcdef") == "bcdf"
// removeVowels(text: "aaaaa") == ""
// removeVowels(text: "aaBAA") == "B"
// removeVowels(text: "zbcd") == "zbcd"
func removeVowels(text: String) -> String {
    var result = ""
    for char in text {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// 2. Write a function that takes a string and returns a string with the first letter capitalized.
// capitalizeFirstLetter is a function that takes string and returns string with the first letter capitalized.
// capitalizeFirstLetter("") == ""
// capitalizeFirstLetter("a") == "A"
// capitalizeFirstLetter("hello") == "Hello"
// capitalizeFirstLetter("aBCdef") == "ABCdef"
func capitalizeFirstLetter(text: String) -> String {
    if text.isEmpty {
        return ""
    }
    return String(text.first!.uppercased) + text.substring(1)
}

// 3. Write a function that takes a string and returns a string with the first and last letters capitalized.
// capitalizeFirstAndLastLetters is a function that takes string and returns string with the first and last letters capitalized.
// capitalizeFirstAndLastLetters("") == ""
// capitalizeFirstAndLastLetters("a") == "A"
// capitalizeFirstAndLastLetters("hello") == "Hello"
// capitalizeFirstAndLastLetters("aBCdef") == "ABCdef"
// capitalizeFirstAndLastLetters("aBCdefg") == "ABCdefG"
func capitalizeFirstAndLastLetters(text: String) -> String {
    if text.isEmpty {
        return ""
    }
    return String(text.first!.uppercased) + text.substring(1, text.count - 1) + String(text.last!.uppercased)
}

// 4. Write a function that takes a string and returns a string with the first and last letters capitalized.
// capitalizeFirstAndLastLetters is a function that takes string and returns string with the first and last letters capitalized.
// capitalizeFirstAndLastLetters("") == ""
// capitalizeFirstAndLastLetters("a") == "A"
// capitalizeFirstAndLastLetters("hello") == "Hello"
// capitalizeFirstAndLastLetters("aBCdef") == "ABCdef"
// capitalizeFirstAndLastLetters("aBCdefg") == "ABCdefG"
func capitalizeFirstAndLastLetters(text: String) -> String {
    if text.isEmpty {
        return ""
    }
    return String(text.first!.uppercased) + text.substring(1, text.count - 1) + String(text.last!.uppercased)
}

// 5. Write a function that takes a string and returns a string with the first and last letters capitalized.
// capitalizeFirstAndLastLetters is a function that takes string and returns string with the first and last letters capitalized.
// capitalizeFirstAndLastLetters("") == ""
// capitalizeFirstAndLastLetters("a") == "A"
// capitalizeFirstAndLastLetters("hello") == "Hello"
// capitalizeFirstAndLastLetters("aBCdef") == "ABCdef"
// capitalizeFirstAndLastLetters("aBCdefg") == "ABCdefG"
func capitalizeFirstAndLastLetters(text: String) -> String {
    if text.isEmpty {
        return ""
    }
    return String(text.first!.uppercased) + text.substring(1, text.count - 1) + String(text.last!.uppercased)
}

// 6. Write a function that takes a string and returns a string with the first and last letters capitalized.
// capitalizeFirstAndLastLetters is a function that takes string and returns string with the first and last letters capitalized.
// capitalizeFirstAndLastLetters("") == ""
// capitalizeFirstAndLastLetters("a") == "A"
// capitalizeFirstAndLastLetters("hello") == "Hello"
// capitalizeFirstAndLastLetters("aBCdef") == "ABCdef"
// capitalizeFirstAndLastLetters("aBCdefg") == "ABCdefG"
result += char // cannot convert value of type 'Character' to expected argument type 'String'
return String(text.first!.uppercased) + text.substring(1) // no exact matches in call to instance method 'substring'
return String(text.first!.uppercased) + text.substring(1) // type '() -> String' cannot conform to 'LosslessStringConvertible'
return String(text.first!.uppercased) + text.substring(1, text.count - 1) + String(text.last!.uppercased) // type '() -> String' cannot conform to 'LosslessStringConvertible'
return String(text.first!.uppercased) + text.substring(1, text.count - 1) + String(text.last!.uppercased) // no exact matches in call to instance method 'substring'
return String(text.first!.uppercased) + text.substring(1, text.count - 1) + String(text.last!.uppercased) // type '() -> String' cannot conform to 'LosslessStringConvertible'

func belowThreshold(l: [Int], t: Int) -> Bool {
    return l.all(where: { $0 < t })
}
```swift
// Return true if all numbers in the array l are below threshold t.
// belowThreshold(l: [1, 2, 4, 10], t: 100) == true
// belowThreshold(l: [1, 20, 4, 10], t: 5) == false
func belowThreshold(l: [Int], t: Int) -> Bool {
    return l.all(where: { $0 < t })
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ------------------
return l.all(where: { $0 < t }) // value of type '[Int]' has no member 'all'

func belowThreshold(l: [Int], t: Int) -> Bool {
    return l.all(where: { $0 < t })
}
```swift
// Return true if all numbers in the array l are below threshold t.
// belowThreshold(l: [1, 2, 4, 10], t: 100) == true
// belowThreshold(l: [1, 20, 4, 10], t: 5) == false
func belowThreshold(l: [Int], t: Int) -> Bool {
    return l.all(where: { $0 < t })
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ------------------
return l.all(where: { $0 < t }) // value of type '[Int]' has no member 'all'

func belowThreshold(l: [Int], t: Int) -> Bool {
    return l.all(where: { $0 < t })
}
```swift
// Return true if all numbers in the array l are below threshold t.
// belowThreshold(l: [1, 2, 4, 10], t: 100) == true
// belowThreshold(l: [1, 20, 4, 10], t: 5) == false
func belowThreshold(l: [Int], t: Int) -> Bool {
    return l.all(where: { $0 < t })
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ------------------
return l.all(where: { $0 < t }) // value of type '[Int]' has no member 'all'

func belowThreshold(l: [Int], t: Int) -> Bool {
    return l.all(where: { $0 < t })
}
```swift
// Return true if all numbers in the array l are below threshold t.
// belowThreshold(l: [1, 2, 4, 10], t: 100) == true
// belowThreshold(l: [1, 20, 4, 10], t: 5) == false
func belowThreshold(l: [Int], t: Int) -> Bool {
    return l.all(where: { $0 < t })
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ------------------
return l.all(where: { $0 < t }) // value of type '[Int]' has no member 'all'

func belowThreshold(l: [Int], t: Int) -> Bool {
    return l.all(where: { $0 < t })
}
```swift
// Return true if all numbers in the array l are below threshold t.
// belowThreshold(l: [1, 2, 4, 10], t: 100) == true
// belowThreshold(l: [1, 20, 4, 10], t: 5) == false
func belowThreshold(l: [Int], t: Int) -> Bool {
    return l.all(where: { $0 < t })
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ------------------
return l.all(where: { $0 < t }) // value of type '[Int]' has no member 'all'

func belowThreshold(l: [Int], t: Int) -> Bool {
    return l.all(where: { $0 < t })
}
```swift
// Return true if all numbers in the array l are below threshold t.
// belowThreshold(l: [1, 2, 4, 10], t: 100) == true
// belowThreshold(l: [1, 20, 4, 10], t: 5) == false
func belowThreshold(l: [Int], t: Int) -> Bool {
    return l.all(where: { $0 < t })
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ---------------------------------------------------
return l.all(where: { $0 < t }) // value of type '[Int]' has no member 'all'

func belowThreshold(l: [Int], t: Int) -> Bool {
    return l.all(where: { $0 < t })
}
```swift
// Return true if all numbers in the array l are below threshold t.
// belowThreshold(l: [1, 2, 4, 10], t: 100) == true
// belowThreshold(l: [1, 20, 4, 10], t: 5) == false
func belowThreshold(l: [Int], t: Int) -> Bool {
    return l.all(where: { $0 < t })
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ------------------
return l.all(where: { $0 < t }) // value of type '[Int]' has no member 'all'

func belowThreshold(l: [Int], t: Int) -> Bool {
    return l.all(where: { $0 < t })
}
```swift
// Return true if all numbers in the array l are below threshold t.
// belowThreshold(l: [1, 2, 4, 10], t: 100) == true
// belowThreshold(l: [1, 20, 4, 10], t: 5) == false
func belowThreshold(l: [Int], t: Int) -> Bool {
    return l.all(where: { $0 < t })
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ------------------
return l.all(where: { $0 < t }) // value of type '[Int]' has no member 'all'

func belowThreshold(l: [Int], t: Int) -> Bool {
    for i in l {
        if i >= t {
            return false
        }
    }
    return true
}
```swift
// Return true if all numbers in the array l are below threshold t.
// belowThreshold(l: [1, 2, 4, 10], t: 100) == true
// belowThreshold(l: [1, 20, 4, 10], t: 5) == false
func belowThreshold(l: [Int], t: Int) -> Bool {
    for i in l {
        if i >= t {
            return false
        }
    }
    return true
}

// -----------------------------------------------------------------------------
// 2. Write a function that takes a string and returns the number of vowels
//    in the string.
//
//    vowelCount("Hello") == 2
//    vowelCount("Apple") == 2
//    vowelCount("") == 0
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 3. Write a function that takes a string and returns the number of words in
//    the string.
//
//    wordCount("Hello") == 1
//    wordCount("Hello, World!") == 2
//    wordCount("") == 0
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 4. Write a function that takes a string and returns the number of consonants
//    in the string.
//
//    consonantCount("Hello") == 3
//    consonantCount("Apple") == 5
//    consonantCount("") == 0
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 5. Write a function that takes a string and returns the number of vowels
//    in the string.
//
//    vowelCount("Hello") == 2
//    vowelCount("Apple") == 2
//    vowelCount("") == 0
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 6. Write a function that takes a string and returns the number of words
//    in the string.
//
//    wordCount("Hello") == 1
//    wordCount("Hello, World!") == 2
//    wordCount("") == 0
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 7. Write a function that takes a string and returns the number of consonants
//    in the string.
//
//    consonantCount("Hello") == 3
//    consonantCount("Apple") == 5
//    consonantCount("") == 0
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 8. Write a function that takes a string and returns the number of vowels
//    in the string.
//
//    vowelCount("Hello") == 2
//    vowelCount("Apple") == 2
//    vowelCount("") == 0
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 9. Write a function that takes a string and returns the number of words
//    in the string.
//
//    wordCount("Hello") == 1
//    wordCount("Hello, World!")

func belowThreshold(l: [Int], t: Int) -> Bool {
    for element in l {
        if element >= t {
            return false
        }
    }
    return true
}
```swift
// Return true if all numbers in the array l are below threshold t.
// belowThreshold(l: [1, 2, 4, 10], t: 100) == true
// belowThreshold(l: [1, 20, 4, 10], t: 5) == false
func belowThreshold(l: [Int], t: Int) -> Bool {
    for element in l {
        if element >= t {
            return false
        }
    }
    return true
}

// -----------------------------------------------------------------------------
// 1.2.1
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.2.2
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.2.3
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.2.4
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.2.5
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.2.6
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.2.7
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.2.8
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.2.9
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.2.10
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.2.11
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.2.12
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.2.13
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.2.14
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.2.15
// ---------------------------

func add(x: Int, y: Int) -> Int {
    return x + y
}
```swift
// Add two numbers x and y
// add(x: 2, y: 3) == 5
// add(x: 5, y: 7) == 12
func add(x: Int, y: Int) -> Int {
    return x + y
}

// 2.
// 인자를 받아서 반환하는 함수
// 함수의 인자는 언제나 하나여야 한다.
// 함수의 반환값은 언제나 하나여야 한다.
// 함수의 인자와 반환값은 모두 옵션이 없어야 한다.
// 함수의 인자와 반환값은 모두 옵션이 없어야 한다.
// 함수의 인자와 반환값은 모두 옵션이 없어야 한다.
// 함수의 인자와 반환값은 모두 옵션이 없어야 한다.
// 함수의 인자와 반환값은 모두 옵션이 없어야 한다.
// 함수의 인자와 반환값은 모두 옵션이 없어야 한다.
// 함수의 인자와 반환값은 모두 옵션이 없어야 한다.
// 함수의 인자와 반환값은 모두 옵션이 없어야 한다.
// 함수의 인자와 반환값은 모두 옵션이 없어야 한다.
// 함수의 인자와 반환값은 모두 옵션이 없어야 한다.
// 함수의 인자와 반환값은 모두 옵션이 없어야 한다.
// 함수의 인자와 반환값은 모두 옵션이 없어야 한다.
// 함수의 인자와 반환값은 모두 옵션이 없어야 한다.
// 함수의 인자와 반환값은 모두 옵션이 없어야 한다.
// 함수의 인자와 반환값은 모두 옵션이 없어야 한다.
// 함수의 인자와 반환값은 모두 옵션이 없어야 한다.

func add(x: Int, y: Int) -> Int {
    return x + y
}

func square(x: Int) -> Int {
    return x * x
}

func squareRoot(x: Int) -> Int {
    return Int(sqrt(Double(x)))
}

func factorial(x: Int) -> Int {
    var result = 1
    for i in 1...x {
        result *= i
    }
    return result
}

func sum(x: Int) -> Int {
    var result = 0
    for i in 1...x {
        result += i
    }
    return result
}

func sumOfEvenNumbers(x: Int) -> Int {
    var result = 0
    for i in 1...x {
        if i % 2 == 0 {
            result += i
        }
    }
    return result
}

func sumOfOddNumbers(x: Int) -> Int {
    var result = 0
    for i in 1...x {
        if i % 2 != 0 {
            result += i
        }
    }
    return result
}

func sumOfMultiplesOf3And5(x: Int) -> Int {
    var result = 0
    for i in 1...x {
        if i % 3 == 0 || i % 5 == 0 {
            result += i
        }
    }
    return result
}

func sumOfMultiplesOf3And5(x: Int) -> Int {
    var result = 0
    for i in 1...x {
        if i % 3 == 0 && i % 5 == 0 {
            result += i
        }
    }
    return result
}
```swift
// Add two numbers x and y
// add(x: 2, y: 3) == 5
// add(x: 5, y: 7) == 12
func add(x: Int, y: Int) -> Int {
    return x + y
}

// 2. Write a function that takes a number as an argument and returns the square of that number.
// square(2) == 4
// square(5) == 25
func square(x: Int) -> Int {
    return x * x
}

// 3. Write a function that takes a number as an argument and returns the square root of that number.
// squareRoot(4) == 2
// squareRoot(9) == 3
func squareRoot(x: Int) -> Int {
    return Int(sqrt(Double(x)))
}

// 4. Write a function that takes a number as an argument and returns the factorial of that number.
// factorial(5) == 120
// factorial(0) == 1
func factorial(x: Int) -> Int {
    var result = 1
    for i in 1...x {
        result *= i
    }
    return result
}

// 5. Write a function that takes a number as an argument and returns the sum of all numbers from 1 to that number.
// sum(5) == 15
// sum(10) == 55
func sum(x: Int) -> Int {
    var result = 0
    for i in 1...x {
        result += i
    }
    return result
}

// 6. Write a function that takes a number as an argument and returns the sum of all even numbers from 1 to that number.
// sumOfEvenNumbers(5) == 6
// sumOfEvenNumbers(10) == 30
func sumOfEvenNumbers(x: Int) -> Int {
    var result = 0
    for i in 1...x {
        if i % 2 == 0 {
            result += i
        }
    }
    return result
}

// 7. Write a function that takes a number as an argument and returns the sum of all odd numbers from 1 to that number.
// sumOfOddNumbers(5) == 9
// sumOfOddNumbers(10) == 30
func sumOfOddNumbers(x: Int) -> Int {
    var result = 0
    for i in 1...x {
        if i % 2 != 0 {
            result += i
        }
    }
    return result
}

// 8. Write a function that takes a number as an argument and returns the sum of all numbers from 1 to that number that are multiples of 3 or 5.
// sumOfMultiplesOf3And5(10) == 33
// sumOfMultiplesOf3And5(20) == 78
func sumOfMultiplesOf3And5(x: Int) -> Int {
    var result = 0
    for i in 1...x {
        if i % 3 == 0 || i % 5 == 0 {
            result += i
        }
    }
    return result
}

// 9. Write a function that takes a number as an argument and returns the sum of all numbers from 1 to that number that are multiples of both 3 and 5.
// sumOfMultiplesOf3And5(10) == 33
// sumOfMultiplesOf3And5(20) == 78
func sumOfMultiplesOf3And5(x: Int) -> Int {
    var result = 0
    for i in 1...x {
        if i % 3 == 0 && i % 5 == 0 {
            result += i
        }
    }
    return result
}

// 10. Write a function that takes a number as an argument and returns the sum of all numbers from 1 to that number that are multiples of both 3 and 7.
// sumOfMultiplesOf3And7(10) == 42
// sumOfMultiplesOf3And7(20) == 168
func sumOfMultiplesOf3And7(x: Int) -> Int {
    var result = 0
    for i in 1...x {
        if i % 3 == 0 && i % 7 == 0 {
            result += i
        }
    }
    return result
func sumOfMultiplesOf3And5(x: Int) -> Int { // invalid redeclaration of 'sumOfMultiplesOf3And5(x:)'

func add(x: Int, y: Int) -> Int {
    return x + y
}

func lengthOfString(string: String) -> Int {
    return string.count
}

func lengthOfString(string: String) {
    print(string.count)
}
```swift
// Add two numbers x and y
// add(x: 2, y: 3) == 5
// add(x: 5, y: 7) == 12
func add(x: Int, y: Int) -> Int {
    return x + y
}

// 3. Write a function that takes a string and returns its length.
// lengthOfString("hello") == 5
func lengthOfString(string: String) -> Int {
    return string.count
}

// 4. Write a function that takes a string and returns its length.
// lengthOfString("hello") == 5
func lengthOfString(string: String) {
    print(string.count)
}

// 5. Write a function that takes a string and returns its length.
// lengthOfString("hello") == 5
func lengthOfString(string: String) {
    print(string.count)
}

// 6. Write a function that takes a string and returns its length.
// lengthOfString("hello") == 5
func lengthOfString(string: String) {
    print(string.count)
}

// 7. Write a function that takes a string and returns its length.
// lengthOfString("hello") == 5
func lengthOfString(string: String) {
    print(string.count)
}

// 8. Write a function that takes a string and returns its length.
// lengthOfString("hello") == 5
func lengthOfString(string: String) {
    print(string.count)
}

// 9. Write a function that takes a string and returns its length.
// lengthOfString("hello") == 5
func lengthOfString(string: String) {
    print(string.count)
}

// 10. Write a function that takes a string and returns its length.
// lengthOfString("hello") == 5
func lengthOfString(string: String) {
    print(string.count)
}

// 11. Write a function that takes a string and returns its length.
// lengthOfString("hello") == 5
func lengthOfString(string: String) {
    print(string.count)
}

// 12. Write a function that takes a string and returns its length.
// lengthOfString("hello") == 5
func lengthOfString(string: String) {
    print(string.count)
}

// 13. Write a function that takes a string and returns its length.
// lengthOfString("hello") == 5
func lengthOfString(string: String) {
    print(string.count)
}

// 14. Write a function that takes a string and returns its length.
// lengthOfString("hello") == 5
func lengthOfString(string: String) {
    print(string.count)
}

// 15. Write a function that takes a string and returns its length.
// lengthOfString("hello") == 5
func lengthOfString(string: String) {
    print(string.count)
}

// 16. Write a function that takes a string and returns its length.
// lengthOfString("hello") == 5
func lengthOfString(string: String) {
    print(string.count)
}

// 17. Write a function that takes a string and returns its length.
// lengthOfString("hello") == 5
func lengthOfString(string: String) {
    print(string.count)
}

// 18. Write a function that takes a string and returns its length.
// lengthOfString("hello") == 5
func lengthOfString(string: String) {
    print(string.count)
}

// 19. Write a function that takes a string and returns its length.
// lengthOfString("hello") == 5
func lengthOfString(string: String) {
    print(string.count)
}

// 20. Write a function that takes a string and returns its length.
// lengthOfString("hello") == 5
func lengthOfString(string: String) {
    print(string.count)
}

// 21. Write a function that takes a string and returns its length.
// lengthOfString("hello") == 5
func lengthOfString(string: String) {
    print(string.count)
}

// 22. Write a function that takes a string and returns

func add(x: Int, y: Int) -> Int {
    return x + y
}
```swift
// Add two numbers x and y
// add(x: 2, y: 3) == 5
// add(x: 5, y: 7) == 12
func add(x: Int, y: Int) -> Int {
    return x + y
}

// 2.
// 1.
// 2.
// 3.
// 4.
// 5.
// 6.
// 7.
// 8.
// 9.
// 10.
// 11.
// 12.
// 13.
// 14.
// 15.
// 16.
// 17.
// 18.
// 19.
// 20.
// 21.
// 22.
// 23.
// 24.
// 25.
// 26.
// 27.
// 28.
// 29.
// 30.
// 31.
// 32.
// 33.
// 34.
// 35.
// 36.
// 37.
// 38.
// 39.
// 40.
// 41.
// 42.
// 43.
// 44.
// 45.
// 46.
// 47.
// 48.
// 49.
// 50.
// 51.
// 52.
// 53.
// 54.
// 55.
// 56.
// 57.
// 58.
// 59.
// 60.
// 61.
// 62.
// 63.
// 64.
// 65.
// 66.
// 67.
// 68.
// 69.
// 70.
// 71.
// 72.
// 73.
// 74.
// 75.
// 76.
// 77.
// 78.
// 79.
// 80.
// 81.
// 82.
// 83.
// 84.
// 85.
// 86.
// 87.
// 88.
// 89.
// 90.
// 91.
// 92.
// 93.
// 94.
// 95.
// 96.
// 97.
// 98.
// 99.
// 100.
// 101.
// 102.
// 103.
// 104.
// 105.
// 106.
// 107.
// 108.
// 109.
// 110.
// 111.
// 112.
// 113.
// 114.
// 115.
// 116.
// 117.
// 118.
// 119.
// 120.
// 121.
// 122.
// 123.
// 124.
// 125.
// 126.
// 127.
// 128.
// 129.
// 130.
// 131.
// 132.
// 133.
// 134.
// 135.
// 136.
// 137.
// 138.
// 139.
// 140.
// 141.
// 142.
// 143.
// 144.
// 145.
// 146.
// 147.
// 148.
// 149.
// 150.
// 151.
// 152.
// 153.
// 154.
// 155.
// 156.
// 157.
// 158.
// 159.
// 16

func add(x: Int, y: Int) -> Int {
    return x + y
}
```swift
// Add two numbers x and y
// add(x: 2, y: 3) == 5
// add(x: 5, y: 7) == 12
func add(x: Int, y: Int) -> Int {
    return x + y
}

// -----------------------------------------------------------------------------
// 2. Write a function that takes a string and returns the length of the string.
// length("hello") == 5
// length("") == 0
// length("a") == 1
// length("aa") == 2
// length("aaa") == 3
// length("aaaa") == 4
// length("aaaaa") == 5
// length("aaaaaa") == 6
// length("aaaaaaa") == 7
// length("aaaaaaaa") == 8
// length("aaaaaaaaa") == 9
// length("aaaaaaaaaa") == 10
// length("aaaaaaaaaaa") == 11
// length("aaaaaaaaaaaa") == 12
// length("aaaaaaaaaaaaa") == 13
// length("aaaaaaaaaaaaaa") == 14
// length("aaaaaaaaaaaaaaa") == 15
// length("aaaaaaaaaaaaaaaa") == 16
// length("aaaaaaaaaaaaaaaaa") == 17
// length("aaaaaaaaaaaaaaaaaa") == 18
// length("aaaaaaaaaaaaaaaaaaa") == 19
// length("aaaaaaaaaaaaaaaaaaaa") == 20
// length("aaaaaaaaaaaaaaaaaaaaa") == 21
// length("aaaaaaaaaaaaaaaaaaaaaa") == 22
// length("aaaaaaaaaaaaaaaaaaaaaaa") == 23
// length("aaaaaaaaaaaaaaaaaaaaaaaa") == 24
// length("aaaaaaaaaaaaaaaaaaaaaaaaa") == 25
// length("aaaaaaaaaaaaaaaaaaaaaaaaaa") == 26
// length("aaaaaaaaaaaaaaaaaaaaaaaaaaa") == 27
// length("aaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 28
// length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 29
// length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 30
// length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 31
// length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 32
// length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 33
// length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 34
// length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 35
// length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 36
// length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 37
// length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 38
// length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 39
// length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 40
// length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 41
// length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 42
// length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 43
// length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 44
// length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 45
// length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 46
// length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 47
// length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 48
// length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 49
// length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 50
// length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 51
// length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 52
// length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

func add(x: Int, y: Int) -> Int {
    return x + y
}
```swift
// Add two numbers x and y
// add(x: 2, y: 3) == 5
// add(x: 5, y: 7) == 12
func add(x: Int, y: Int) -> Int {
    return x + y
}

// 2. 使用函数名作为参数
// 使用函数名作为参数,可以避免使用多余的括号
// add(x: 2, y: 3) == 5
// add(x: 5, y: 7) == 12
func add(x: Int, y: Int) -> Int {
    return x + y
}

// 3. 使用函数名作为返回值
// 使用函数名作为返回值,可以避免使用多余的括号
// let result = add(x: 2, y: 3)
// result == 5
// let result = add(x: 5, y: 7)
// result == 12
func add(x: Int, y: Int) -> Int {
    return x + y
}

// 4. 使用函数名作为参数和返回值
// 使用函数名作为参数和返回值,可以避免使用多余的括号
// let result = add(x: 2, y: 3)
// result == 5
// let result = add(x: 5, y: 7)
// result == 12
func add(x: Int, y: Int) -> Int {
    return x + y
}

// 5. 使用函数名作为参数和返回值,并使用类型推断
// 使用函数名作为参数和返回值,并使用类型推断,可以避免使用多余的括号
// let result = add(2, 3)
// result == 5
// let result = add(5, 7)
// result == 12
func add(x: Int, y: Int) -> Int {
    return x + y
}

// 6. 使用函数名作为参数和返回值,并使用类型推断,并使用类型推断
// 使用函数名作为参数和返回值,并使用类型推断,并使用类型推断,可以避免使用多余的括号
// let result = add(2, 3)
// result == 5
// let result = add(5, 7)
// result == 12
func add(x: Int, y: Int) -> Int {
    return x + y
}

// 7. 使用函数名作为参数和返回值,并使用类型推断,并使用类型推断,并使用类型推断
// 使用函数名作为参数和返回值,并使用类型推断,并使用类型推断,并使用类型推断,可以避免使用多余的括号
// let result = add(2, 3)
// result == 5
// let result = add(5, 7)
// result == 12
func add(x: Int, y: Int) -> Int {
    return x + y
}

// 8. 使用函数名作为参数和返回值,并使用类型推断,并使用类型推断,并使用类型推断,并使用类型推断
// 使用函数名作为参数和返回值,并使用类型推断,并使用类型推断,并使用类型推断,并使用类型推断,可以避免使用多余的括号
// let result = add(2, 3)
// result == 5
// let result = add(5, 7)
// result == 12
func add(x: Int, y: Int) -> Int {
    return x + y
}

// 9. 使用函数名作为参数和返回值,并使用类型推断,并使用类型推断,并使用类型推断,并使用类型推断,并使用类型推断
// 使用函数名作为参数和返回值,并使用类型推断,并使用类型推断,并使用类型推断,并使用类型推断,并使用类型推断,可以避免使用多余的括号
// let result = add(2, 3)
// result == 5
// let result = add(5, 7)
// result == 12
func add(x: Int, y: Int) -> Int {
    return x + y
}

// 10. 使用函数名作为参数和返回值,并使用类型推断,并使用类型推断,并使用类型推断,并使用类型推断,并使用类型推断,并使用类型推断
// 使用函数名作为参数和返回值,并使用类型推断,并使用类型推断,

func add(x: Int, y: Int) -> Int {
    return x + y
}
```swift
// Add two numbers x and y
// add(x: 2, y: 3) == 5
// add(x: 5, y: 7) == 12
func add(x: Int, y: Int) -> Int {
    return x + y
}

// 2.
// 아래 함수는 인자로 받은 문자열을 반대로 뒤집어 반환하는 함수입니다.
// 예를 들어 "hello"를 입력하면 "olleh"를 반환합니다.
// 아래 함수를 완성해 보세요.
// 문자열을 반대로 뒤집는 함수 reverseString(s: String) -> String

// 1.
// 아래 함수는 인자로 받은 문자열을 반대로 뒤집어 반환하는 함수입니다.
// 예를 들어 "hello"를 입력하면 "olleh"를 반환합니다.
// 아래 함수를 완성해 보세요.
// 문자열을 반대로 뒤집는 함수 reverseString(s: String) -> String

// 2.
// 아래 함수는 인자로 받은 문자열을 반대로 뒤집어 반환하는 함수입니다.
// 예를 들어 "hello"를 입력하면 "olleh"를 반환합니다.
// 아래 함수를 완성해 보세요.
// 문자열을 반대로 뒤집는 함수 reverseString(s: String) -> String

// 3.
// 아래 함수는 인자로 받은 문자열을 반대로 뒤집어 반환하는 함수입니다.
// 예를 들어 "hello"를 입력하면 "olleh"를 반환합니다.
// 아래 함수를 완성해 보세요.
// 문자열을 반대로 뒤집는 함수 reverseString(s: String) -> String

// 4.
// 아래 함수는 인자로 받은 문자열을 반대로 뒤집어 반환하는 함수입니다.
// 예를 들어 "hello"를 입력하면 "olleh"를 반환합니다.
// 아래 함수를 완성해 보세요.
// 문자열을 반대로 뒤집는 함수 reverseString(s: String) -> String

// 5.
// 아래 

func add(x: Int, y: Int) -> Int {
    return x + y
}
```swift
// Add two numbers x and y
// add(x: 2, y: 3) == 5
// add(x: 5, y: 7) == 12
func add(x: Int, y: Int) -> Int {
    return x + y
}

// 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.63.64.65.66.67.68.69.70.71.72.73.74.75.76.77.78.79.80.81.82.83.84.85.86.87.88.89.90.91.92.93.94.95.96.97.98.99.100.101.102.103.104.105.106.107.108.109.110.111.112.113.114.115.116.117.118.119.120.121.122.123.124.125.126.127.128.129.130.131.132.133.134.135.136.137.138.139.140.141.142.143.144.145.146.147.148.149.150.151.152.153.154.155.156.157.158.159.160.161.162.163.164.165.166.167.168.169.170.171.172.173.174.175.176.177.178.179.180.181.182.183.184.185.186.187.188.189.190.191.192.193.194.195.196.197.198.199.200.201.202.203.204.205.206.207.208.209.210.211.212.213.214.215.216.217.218.219.220.221.222.223.224.225.226.227.228.229.230.231.232.233.234.235.236.237.238.239.240.241.242.243.244.245.246.247.248.249.250.251.252.253.254.255.256.257.258.259.260.261.262.263.264.265.266.267.268.269.270.271.272.273.274.275.276.277.278.279.280.

func add(x: Int, y: Int) -> Int {
    return x + y
}
```swift
// Add two numbers x and y
// add(x: 2, y: 3) == 5
// add(x: 5, y: 7) == 12
func add(x: Int, y: Int) -> Int {
    return x + y
}

// 2.1.2.2.1
// 함수 표현식
// 함수 표현식은 함수를 생성하는 것과 동일하다.
// 함수 표현식을 사용하면 함수를 생성하는 대신 함수를 바로 실행할 수 있다.
// 함수 표현식은 함수를 생성하는 대신 함수를 바로 실행할 수 있다.
// 함수 표현식은 함수를 생성하는 대신 함수를 바로 실행할 수 있다.
// 함수 표현식은 함수를 생성하는 대신 함수를 바로 실행할 수 있다.
// 함수 표현식은 함수를 생성하는 대신 함수를 바로 실행할 수 있다.
// 함수 표현식은 함수를 생성하는 대신 함수를 바로 실행할 수 있다.
// 함수 표현식은 함수를 생성하는 대신 함수를 바로 실행할 수 있다.
// 함수 표현식은 함수를 생성하는 대신 함수를 바로 실행할 수 있다.
// 함수 표현식은 함수를 생성하는 대신 함수를 바로 실행할 수 있다.
// 함수 표현식은 함수를 생성하는 대신 함수를 바로 실행할 수 있다.
// 함수 표현식은 함수를 생성하는 대신 함수를 바로 실행할 수 있다.
// 함수 표현식은 함수를 생성하는 대신 함수를 바로 실행할 수 있다.
// 함수 표현식은 함수를 생성하는 대신 함수를 바로 실행할 수 있다.
// 함수 표현식은 함수를 생성하는 대신 함수를 바로 실행할 수 있다.
// 

func add(x: Int, y: Int) -> Int {
    return x + y
}
```swift
// Add two numbers x and y
// add(x: 2, y: 3) == 5
// add(x: 5, y: 7) == 12
func add(x: Int, y: Int) -> Int {
    return x + y
}

// 1.1.2.2
// 1.1.2.3
// 1.1.2.4
// 1.1.2.5
// 1.1.2.6
// 1.1.2.7
// 1.1.2.8
// 1.1.2.9
// 1.1.2.10
// 1.1.2.11
// 1.1.2.12
// 1.1.2.13
// 1.1.2.14
// 1.1.2.15
// 1.1.2.16
// 1.1.2.17
// 1.1.2.18
// 1.1.2.19
// 1.1.2.20
// 1.1.2.21
// 1.1.2.22
// 1.1.2.23
// 1.1.2.24
// 1.1.2.25
// 1.1.2.26
// 1.1.2.27
// 1.1.2.28
// 1.1.2.29
// 1.1.2.30
// 1.1.2.31
// 1.1.2.32
// 1.1.2.33
// 1.1.2.34
// 1.1.2.35
// 1.1.2.36
// 1.1.2.37
// 1.1.2.38
// 1.1.2.39
// 1.1.2.40
// 1.1.2.41
// 1.1.2.42
// 1.1.2.43
// 1.1.2.44
// 1.1.2.45
// 1.1.2.46
// 1.1.2.47
// 1.1.2.48
// 1.1.2.49
// 1.1.2.50
// 1.1.2.51
// 1.1.2.52
// 1.1.2.53
// 1.1.2.54
// 1.1.2.55
// 1.1.2.56
// 1.1.2.57
// 1.1.2.58
// 1.1.2.59
// 1.1.2.60
// 1.1.2.61
// 1.1.2.62
// 1.1.2.63
// 1.1.2.64
// 1.1.2.65
// 1.1.2.66
// 1.1.2.67
// 1.1.2.68
// 1.1.2.69
// 1.1.2.70
// 1.1.2.71
// 1.1.2.72
// 1.1.2.73
// 1.1.2.74
// 1.1.2.75
// 1.1.2.76
// 1.1.2.77
// 1.1.2.78
// 1.1.2.79
// 1.1.2.80
// 1.1.2.81
// 1.1.2.82
// 1.1.2.83
// 1.1.2.84
// 1.1.2.85
// 1.1.2.86
// 1.1.2.87
// 1.1.2.88
// 1.1.2.89
// 1.1.2.90
// 1.1.2.91
// 1.1.2.92
// 1.1.2.93
// 1.1.2.94

func sameChars(s0: String, s1: String) -> Bool {
    if s0.count != s1.count {
        return false
    }
    for i in 0..<s0.count {
        if s0[i] != s1[i] {
            return false
        }
    }
    return true
}
```swift
// Check if two words have the same characters.
// sameChars(s0: "eabcdzzzz", s1: "dddzzzzzzzddeddabc") == true
// sameChars(s0: "abcd", s1: "dddddddabc") == true
// sameChars(s0: "dddddddabc", s1: "abcd") == true
// sameChars(s0: "eabcd", s1: "dddddddabc") == false
// sameChars(s0: "abcd", s1: "dddddddabce") == false
// sameChars(s0: "eabcdzzzz", s1: "dddzzzzzzzddddabc") == false
func sameChars(s0: String, s1: String) -> Bool {
    if s0.count != s1.count {
        return false
    }
    for i in 0..<s0.count {
        if s0[i] != s1[i] {
            return false
        }
    }
    return true
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// ------------------------------------------------------------
if s0[i] != s1[i] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s0[i] != s1[i] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.

func sameChars(s0: String, s1: String) -> Bool {
    var i = 0
    while i < s0.count {
        if s0[i] != s1[i] {
            return false
        }
        i += 1
    }
    return true
}
```swift
// Check if two words have the same characters.
// sameChars(s0: "eabcdzzzz", s1: "dddzzzzzzzddeddabc") == true
// sameChars(s0: "abcd", s1: "dddddddabc") == true
// sameChars(s0: "dddddddabc", s1: "abcd") == true
// sameChars(s0: "eabcd", s1: "dddddddabc") == false
// sameChars(s0: "abcd", s1: "dddddddabce") == false
// sameChars(s0: "eabcdzzzz", s1: "dddzzzzzzzddddabc") == false
func sameChars(s0: String, s1: String) -> Bool {
    var i = 0
    while i < s0.count {
        if s0[i] != s1[i] {
            return false
        }
        i += 1
    }
    return true
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// ---------------------------------------------------------------------------
if s0[i] != s1[i] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s0[i] != s1[i] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.

```swift
// Check if two words have the same characters.
// sameChars(s0: "eabcdzzzz", s1: "dddzzzzzzzddeddabc") == true
// sameChars(s0: "abcd", s1: "dddddddabc") == true
// sameChars(s0: "dddddddabc", s1: "abcd") == true
// sameChars(s0: "eabcd", s1: "dddddddabc") == false
// sameChars(s0: "abcd", s1: "dddddddabce") == false
// sameChars(s0: "eabcdzzzz", s1: "dddzzzzzzzddddabc") == false
func sameChars(s0: String, s1: String) -> Bool {
    return s0.count == s1.count && s0.count == 0 ? true : s0.count == 0 ? false : s0.count == 1 ? true : s0.count == 1 ? false : s0.count == 2 ? true : s0.count == 2 ? false : s0.count == 3 ? true : s0.count == 3 ? false : s0.count == 4 ? true : s0.count == 4 ? false : s0.count == 5 ? true : s0.count == 5 ? false : s0.count == 6 ? true : s0.count == 6 ? false : s0.count == 7 ? true : s0.count == 7 ? false : s0.count == 8 ? true : s0.count == 8 ? false : s0.count == 9 ? true : s0.count == 9 ? false : s0.count == 10 ? true : s0.count == 10 ? false : s0.count == 11 ? true : s0.count == 11 ? false : s0.count == 12 ? true : s0.count == 12 ? false : s0.count == 13 ? true : s0.count == 13 ? false : s0.count == 14 ? true : s0.count == 14 ? false : s0.count == 15 ? true : s0.count == 15 ? false : s0.count == 16 ? true : s0.count == 16 ? false : s0.count == 17 ? true : s0.count == 17 ? false : s0.count == 18 ? true : s0.count == 18 ? false : s0.count == 19 ? true : s0.count == 19 ? false : s0.count == 20 ? true : s0.count == 20 ? false : s0.count == 21 ? true : s0.count == 21 ? false : s0.count == 22 ? true : s0.count == 22 ? false : s0.count == 23 ? true : s0.count == 23 ? false : s0.count == 24 ? true : s0.count == 24 ? false : s0.count == 25 ? true : s0.count == 25 ? false : s0.count == 26 ? true : s0.count == 26 ? false : s0.count == 27 ? true : s0.count == 27 ? false : s0.count == 28 ? true : s0.count == 28 ? false : s0.count == 29 ? true : s0.count == 29 ? false : s0.count == 30 ? true : s0.count == 30 ? false : s0.count == 31 ? true : s0.count == 31 ? false : s0.count == 32 ? true : s0.count == 32 ? false : s0.count == 33 ? true : s0.count == 33 ? false : s0.count == 34 ? true : s0.count == 34 ? false : s0.count == 35 ? true : s0.count == 35 ? false : s0.count == 36 ? true : s0.count == 36 ? false : s0.count == 37 ? true : s0.count == 37 ? false : s0.count == 38 ? true : s0.count == 38 ? false : s0.count == 39 ? true : s0.count == 39 ? false : s0.count == 40 ? true : s0.count == 40 ? false : s0.count == 41 ? true : s0.count == 41 ? false : s0.count == 42 ? true : s0.count == 42 ? false
XCTAssertTrue(sameChars(s0: "eabcdzzzz", s1: "dddzzzzzzzddeddabc") == true) // cannot find 'sameChars' in scope
XCTAssertTrue(sameChars(s0: "abcd", s1: "dddddddabc") == true) // cannot find 'sameChars' in scope
XCTAssertTrue(sameChars(s0: "dddddddabc", s1: "abcd") == true) // cannot find 'sameChars' in scope
XCTAssertTrue(sameChars(s0: "eabcd", s1: "dddddddabc") == false) // cannot find 'sameChars' in scope
XCTAssertTrue(sameChars(s0: "abcd", s1: "dddddddabcf") == false) // cannot find 'sameChars' in scope
XCTAssertTrue(sameChars(s0: "eabcdzzzz", s1: "dddzzzzzzzddddabc") == false) // cannot find 'sameChars' in scope
XCTAssertTrue(sameChars(s0: "aabb", s1: "aaccc") == false) // cannot find 'sameChars' in scope

func sameChars(s0: String, s1: String) -> Bool {
    var s0Set = Set<Character>()
    var s1Set = Set<Character>()
    for c in s0 {
        s0Set.insert(c)
    }
    for c in s1 {
        s1Set.insert(c)
    }
    return s0Set == s1Set
}
```swift
// Check if two words have the same characters.
// sameChars(s0: "eabcdzzzz", s1: "dddzzzzzzzddeddabc") == true
// sameChars(s0: "abcd", s1: "dddddddabc") == true
// sameChars(s0: "dddddddabc", s1: "abcd") == true
// sameChars(s0: "eabcd", s1: "dddddddabc") == false
// sameChars(s0: "abcd", s1: "dddddddabce") == false
// sameChars(s0: "eabcdzzzz", s1: "dddzzzzzzzddddabc") == false
func sameChars(s0: String, s1: String) -> Bool {
    var s0Set = Set<Character>()
    var s1Set = Set<Character>()
    for c in s0 {
        s0Set.insert(c)
    }
    for c in s1 {
        s1Set.insert(c)
    }
    return s0Set == s1Set
}

// -----------------------------------------------------------------------------
// 1.1
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.2
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.3
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.4
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.5
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.6
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.7
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.8
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.9
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.10
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.11
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.12
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.13
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.14
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 

func sameChars(s0: String, s1: String) -> Bool {
    var s0Set = Set<Character>()
    var s1Set = Set<Character>()
    for c in s0 {
        s0Set.insert(c)
    }
    for c in s1 {
        s1Set.insert(c)
    }
    return s0Set == s1Set
}

struct Test {
    var input: String
    var expected: Bool
}
```swift
// Check if two words have the same characters.
// sameChars(s0: "eabcdzzzz", s1: "dddzzzzzzzddeddabc") == true
// sameChars(s0: "abcd", s1: "dddddddabc") == true
// sameChars(s0: "dddddddabc", s1: "abcd") == true
// sameChars(s0: "eabcd", s1: "dddddddabc") == false
// sameChars(s0: "abcd", s1: "dddddddabce") == false
// sameChars(s0: "eabcdzzzz", s1: "dddzzzzzzzddddabc") == false
func sameChars(s0: String, s1: String) -> Bool {
    var s0Set = Set<Character>()
    var s1Set = Set<Character>()
    for c in s0 {
        s0Set.insert(c)
    }
    for c in s1 {
        s1Set.insert(c)
    }
    return s0Set == s1Set
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

struct Test {
    var input: String
    var expected: Bool
}

var tests: [Test] = [
    Test(input: "eabcdzzzz", expected: true),
    Test(input: "dddzzzzzzzddeddabc", expected: true),
    Test(input: "dddddddabc", expected: true),
    Test(input: "eabcd", expected: false),
    Test(input: "abcd", expected: false),
    Test(input: "dddddddabc", expected: false),
    Test(input: "dddddddabc", expected: false),
    Test(input: "abcd", expected: false),
    Test(input: "eabcdzzzz", expected: false),
]

var testIndex = 0

while (testIndex < tests.count) {
    var test = tests[testIndex]
    var result = sameChars(s0: test.input, s1: test.input)
    if (result != test.expected) {
        print("\n\nERROR: test #" + testIndex.toString())
        print("  input: " + test.input)
        print("  expected: " + test.expected)
        print("  result: " + result)
    }
    testIndex += 1
}<|endoftext|>// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

func sameChars(s0: String, s1: String) -> Bool {
    var s0Set = Set<Character>()
    var s1Set = Set<Character>()
    for c in s0 {
        s0Set.insert(c)
    }
    for c in s1 {
        s1Set.insert(c)
    }
    return s0Set == s1Set
}
```swift
// Check if two words have the same characters.
// sameChars(s0: "eabcdzzzz", s1: "dddzzzzzzzddeddabc") == true
// sameChars(s0: "abcd", s1: "dddddddabc") == true
// sameChars(s0: "dddddddabc", s1: "abcd") == true
// sameChars(s0: "eabcd", s1: "dddddddabc") == false
// sameChars(s0: "abcd", s1: "dddddddabce") == false
// sameChars(s0: "eabcdzzzz", s1: "dddzzzzzzzddddabc") == false
func sameChars(s0: String, s1: String) -> Bool {
    var s0Set = Set<Character>()
    var s1Set = Set<Character>()
    for c in s0 {
        s0Set.insert(c)
    }
    for c in s1 {
        s1Set.insert(c)
    }
    return s0Set == s1Set
}

// -----------------------------------------------------------------------------
// 2. Write a function that takes a string and returns a string with the first
//    character of each word capitalized.
//
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    capitalizeFirst("hello world") == "Hello World"
//    

func sameChars(s0: String, s1: String) -> Bool {
    var s0Set = Set<Character>()
    var s1Set = Set<Character>()
    for c in s0 {
        s0Set.insert(c)
    }
    for c in s1 {
        s1Set.insert(c)
    }
    return s0Set == s1Set
}
```swift
// Check if two words have the same characters.
// sameChars(s0: "eabcdzzzz", s1: "dddzzzzzzzddeddabc") == true
// sameChars(s0: "abcd", s1: "dddddddabc") == true
// sameChars(s0: "dddddddabc", s1: "abcd") == true
// sameChars(s0: "eabcd", s1: "dddddddabc") == false
// sameChars(s0: "abcd", s1: "dddddddabce") == false
// sameChars(s0: "eabcdzzzz", s1: "dddzzzzzzzddddabc") == false
func sameChars(s0: String, s1: String) -> Bool {
    var s0Set = Set<Character>()
    var s1Set = Set<Character>()
    for c in s0 {
        s0Set.insert(c)
    }
    for c in s1 {
        s1Set.insert(c)
    }
    return s0Set == s1Set
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// ------------------------------------------

func sameChars(s0: String, s1: String) -> Bool {
    var s0Set = Set<Character>()
    var s1Set = Set<Character>()
    for c in s0 {
        s0Set.insert(c)
    }
    for c in s1 {
        s1Set.insert(c)
    }
    return s0Set == s1Set
}
```swift
// Check if two words have the same characters.
// sameChars(s0: "eabcdzzzz", s1: "dddzzzzzzzddeddabc") == true
// sameChars(s0: "abcd", s1: "dddddddabc") == true
// sameChars(s0: "dddddddabc", s1: "abcd") == true
// sameChars(s0: "eabcd", s1: "dddddddabc") == false
// sameChars(s0: "abcd", s1: "dddddddabce") == false
// sameChars(s0: "eabcdzzzz", s1: "dddzzzzzzzddddabc") == false
func sameChars(s0: String, s1: String) -> Bool {
    var s0Set = Set<Character>()
    var s1Set = Set<Character>()
    for c in s0 {
        s0Set.insert(c)
    }
    for c in s1 {
        s1Set.insert(c)
    }
    return s0Set == s1Set
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// ------------------------------------------

func sameChars(s0: String, s1: String) -> Bool {
    var s0Set = Set<Character>()
    var s1Set = Set<Character>()
    for c in s0 {
        s0Set.insert(c)
    }
    for c in s1 {
        s1Set.insert(c)
    }
    return s0Set == s1Set
}
```swift
// Check if two words have the same characters.
// sameChars(s0: "eabcdzzzz", s1: "dddzzzzzzzddeddabc") == true
// sameChars(s0: "abcd", s1: "dddddddabc") == true
// sameChars(s0: "dddddddabc", s1: "abcd") == true
// sameChars(s0: "eabcd", s1: "dddddddabc") == false
// sameChars(s0: "abcd", s1: "dddddddabce") == false
// sameChars(s0: "eabcdzzzz", s1: "dddzzzzzzzddddabc") == false
func sameChars(s0: String, s1: String) -> Bool {
    var s0Set = Set<Character>()
    var s1Set = Set<Character>()
    for c in s0 {
        s0Set.insert(c)
    }
    for c in s1 {
        s1Set.insert(c)
    }
    return s0Set == s1Set
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// ------------------------------------------

func sameChars(s0: String, s1: String) -> Bool {
    var s0 = s0
    var s1 = s1
    var count = 0
    for i in 0..<s0.count {
        if s0[i] == s1[i] {
            count += 1
        }
    }
    return count == s0.count
}
```swift
// Check if two words have the same characters.
// sameChars(s0: "eabcdzzzz", s1: "dddzzzzzzzddeddabc") == true
// sameChars(s0: "abcd", s1: "dddddddabc") == true
// sameChars(s0: "dddddddabc", s1: "abcd") == true
// sameChars(s0: "eabcd", s1: "dddddddabc") == false
// sameChars(s0: "abcd", s1: "dddddddabce") == false
// sameChars(s0: "eabcdzzzz", s1: "dddzzzzzzzddddabc") == false
func sameChars(s0: String, s1: String) -> Bool {
    var s0 = s0
    var s1 = s1
    var count = 0
    for i in 0..<s0.count {
        if s0[i] == s1[i] {
            count += 1
        }
    }
    return count == s0.count
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// ---------------
var s0 = s0 // variable 's0' was never mutated; consider changing to 'let' constant
var s1 = s1 // variable 's1' was never mutated; consider changing to 'let' constant
if s0[i] == s1[i] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s0[i] == s1[i] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.

func fib(n: Int) -> Int {
    if n == 1 {
        return 1
    } else if n == 2 {
        return 1
    } else {
        return fib(n - 1) + fib(n - 2)
    }
}
```swift
// Return n-th Fibonacci number.
// fib(n: 10) == 55
// fib(n: 1) == 1
// fib(n: 8) == 21
func fib(n: Int) -> Int {
    if n == 1 {
        return 1
    } else if n == 2 {
        return 1
    } else {
        return fib(n - 1) + fib(n - 2)
    }
}

// -----------------------------------------------------------------------------
// 2.1.1
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// 2.1.2
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// 2.1.3
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// 2.1.4
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// 2.1.5
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// 2.1.6
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// 2.1.7
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// 2.1.8
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// 2.1.9
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// 2.1.10
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// 2.1.11
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// 2.1.12
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// 2.1.13
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// 2.1.14
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// 2.1.15
return fib(n - 1) + fib(n - 2) // missing argument label 'n:' in call
return fib(n - 1) + fib(n - 2) // missing argument label 'n:' in call

func fib(n: Int) -> Int {
    if n == 1 {
        return 1
    }
    if n == 2 {
        return 1
    }
    return fib(n - 1) + fib(n - 2)
}
```swift
// Return n-th Fibonacci number.
// fib(n: 10) == 55
// fib(n: 1) == 1
// fib(n: 8) == 21
func fib(n: Int) -> Int {
    if n == 1 {
        return 1
    }
    if n == 2 {
        return 1
    }
    return fib(n - 1) + fib(n - 2)
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// ------------------------
return fib(n - 1) + fib(n - 2) // missing argument label 'n:' in call
return fib(n - 1) + fib(n - 2) // missing argument label 'n:' in call

func fib(n: Int) -> Int {
    if n == 1 {
        return 1
    }
    if n == 0 {
        return 0
    }
    return fib(n - 1) + fib(n - 2)
}
```swift
// Return n-th Fibonacci number.
// fib(n: 10) == 55
// fib(n: 1) == 1
// fib(n: 8) == 21
func fib(n: Int) -> Int {
    if n == 1 {
        return 1
    }
    if n == 0 {
        return 0
    }
    return fib(n - 1) + fib(n - 2)
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 
return fib(n - 1) + fib(n - 2) // missing argument label 'n:' in call
return fib(n - 1) + fib(n - 2) // missing argument label 'n:' in call

func fib(n: Int) -> Int {
    if n == 1 {
        return 1
    } else if n == 2 {
        return 1
    } else {
        return fib(n - 1) + fib(n - 2)
    }
}
```swift
// Return n-th Fibonacci number.
// fib(n: 10) == 55
// fib(n: 1) == 1
// fib(n: 8) == 21
func fib(n: Int) -> Int {
    if n == 1 {
        return 1
    } else if n == 2 {
        return 1
    } else {
        return fib(n - 1) + fib(n - 2)
    }
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ---------------------
return fib(n - 1) + fib(n - 2) // missing argument label 'n:' in call
return fib(n - 1) + fib(n - 2) // missing argument label 'n:' in call

func fib(n: Int) -> Int {
    if n < 2 {
        return n
    }
    return fib(n - 1) + fib(n - 2)
}
```swift
// Return n-th Fibonacci number.
// fib(n: 10) == 55
// fib(n: 1) == 1
// fib(n: 8) == 21
func fib(n: Int) -> Int {
    if n < 2 {
        return n
    }
    return fib(n - 1) + fib(n - 2)
}

// -----------------------------------------------------------------------------
// 1.1.2
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.3
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.4
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.5
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.6
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.7
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.8
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.9
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.10
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.11
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.12
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.13
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.14
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.15
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.16
// ---------
return fib(n - 1) + fib(n - 2) // missing argument label 'n:' in call
return fib(n - 1) + fib(n - 2) // missing argument label 'n:' in call

func fib(n: Int) -> Int {
    if n == 1 || n == 2 {
        return 1
    }
    return fib(n - 1) + fib(n - 2)
}
```swift
// Return n-th Fibonacci number.
// fib(n: 10) == 55
// fib(n: 1) == 1
// fib(n: 8) == 21
func fib(n: Int) -> Int {
    if n == 1 || n == 2 {
        return 1
    }
    return fib(n - 1) + fib(n - 2)
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ---------------------------------
return fib(n - 1) + fib(n - 2) // missing argument label 'n:' in call
return fib(n - 1) + fib(n - 2) // missing argument label 'n:' in call

func fib(n: Int) -> Int {
    if n == 1 {
        return 1
    }
    if n == 2 {
        return 1
    }
    return fib(n - 1) + fib(n - 2)
}
```swift
// Return n-th Fibonacci number.
// fib(n: 10) == 55
// fib(n: 1) == 1
// fib(n: 8) == 21
func fib(n: Int) -> Int {
    if n == 1 {
        return 1
    }
    if n == 2 {
        return 1
    }
    return fib(n - 1) + fib(n - 2)
}

print(fib(10))
print(fib(1))
print(fib(8))

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
return fib(n - 1) + fib(n - 2) // missing argument label 'n:' in call
return fib(n - 1) + fib(n - 2) // missing argument label 'n:' in call

func fib(n: Int) -> Int {
    if n == 1 || n == 2 {
        return 1
    }
    return fib(n - 1) + fib(n - 2)
}
```swift
// Return n-th Fibonacci number.
// fib(n: 10) == 55
// fib(n: 1) == 1
// fib(n: 8) == 21
func fib(n: Int) -> Int {
    if n == 1 || n == 2 {
        return 1
    }
    return fib(n - 1) + fib(n - 2)
}

// -----------------------------------------------------------------------------
// 1.2.1.2.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.
return fib(n - 1) + fib(n - 2) // missing argument label 'n:' in call
return fib(n - 1) + fib(n - 2) // missing argument label 'n:' in call

func fib(n: Int) -> Int {
    if n == 1 {
        return 1
    }
    if n == 2 {
        return 1
    }
    return fib(n - 1) + fib(n - 2)
}
```swift
// Return n-th Fibonacci number.
// fib(n: 10) == 55
// fib(n: 1) == 1
// fib(n: 8) == 21
func fib(n: Int) -> Int {
    if n == 1 {
        return 1
    }
    if n == 2 {
        return 1
    }
    return fib(n - 1) + fib(n - 2)
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// 
return fib(n - 1) + fib(n - 2) // missing argument label 'n:' in call
return fib(n - 1) + fib(n - 2) // missing argument label 'n:' in call

func fib(n: Int) -> Int {
    if n == 0 {
        return 0
    } else if n == 1 {
        return 1
    } else {
        return fib(n - 1) + fib(n - 2)
    }
}
```swift
// Return n-th Fibonacci number.
// fib(n: 10) == 55
// fib(n: 1) == 1
// fib(n: 8) == 21
func fib(n: Int) -> Int {
    if n == 0 {
        return 0
    } else if n == 1 {
        return 1
    } else {
        return fib(n - 1) + fib(n - 2)
    }
}

// -----------------------------------------------------------------------------
// 2. Write a function that takes a string and returns a new string with all
//    characters in reverse order.
//    reverseString("hello") == "olleh"
//    reverseString("") == ""
//    reverseString("h") == "h"
//    reverseString("a") == "a"
//    reverseString("a b c") == "c b a"
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 3. Write a function that takes a string and returns a new string with all
//    characters in reverse order.
//    reverseString("hello") == "olleh"
//    reverseString("") == ""
//    reverseString("h") == "h"
//    reverseString("a") == "a"
//    reverseString("a b c") == "c b a"
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 4. Write a function that takes a string and returns a new string with all
//    characters in reverse order.
//    reverseString("hello") == "olleh"
//    reverseString("") == ""
//    reverseString("h") == "h"
//    reverseString("a") == "a"
//    reverseString("a b c") == "c b a"
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 5. Write a function that takes a string and returns a new string with all
//    characters in reverse order.
//    reverseString("hello") == "olleh"
//    reverseString("") == ""
//    reverseString("h") == "h"
//    reverseString("a") == "a"
//    reverseString("a b c") == "c b a"
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 6. Write a function that takes a string and returns a new string with all
//    characters in reverse order.
//    reverseString("hello") == "olleh"
//    reverseString("") == ""
//    reverseString("h") == "h"
//    reverseString("a") == "a"
//    reverseString("a b c") == "c b a"
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 7. Write a function that takes a string and returns a new string with all
//    characters in reverse order.
//    reverseString("hello") == "olleh"
//    reverseString("") == ""
//    reverseString("h") == "h"
//    reverseString("a") == "a"
//    reverseString("a b c") == "c b a"
// -----------------------------------------------------------------------------

return fib(n - 1) + fib(n - 2) // missing argument label 'n:' in call
return fib(n - 1) + fib(n - 2) // missing argument label 'n:' in call

func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "<" {
            stack.append(bracket)
        } else if bracket == ">" {
            if stack.isEmpty() {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty()
}

func countVowels(s: String) -> Int {
    var count = 0
    for char in s {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}

func countWords(s: String) -> Int {
    var count = 0
    for char in s {
        if char == " " {
            count += 1
        }
    }
    return count + 1
}

func countUppercase(s: String) -> Int {
    var count = 0
    for char in s {
        if char == char.uppercase {
            count += 1
        }
    }
    return count
}

func countLowercase(s: String) -> Int {
    var count = 0
    for char in s {
        if char == char.lowercase {
            count += 1
        }
    }
    return count
}

func countDigits(s: String) -> Int {
    var count = 0
    for char in s {
        if char.isDigit {
            count += 1
        }
    }
    return count
}

func countAlphabetic(s: String) -> Int {
    var count = 0
    for char in s {
        if char.isAlphabetic {
            count += 1
        }
    }
    return count
}
```swift
// brackets is a string of "<" and ">".
// return true if every opening bracket has a corresponding closing bracket.
// correctBracketing(brackets: "<") == false
// correctBracketing(brackets: "<>") == true
// correctBracketing(brackets: "<<><>>") == true
// correctBracketing(brackets: "><<>") == false
func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "<" {
            stack.append(bracket)
        } else if bracket == ">" {
            if stack.isEmpty() {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty()
}

// 11. Write a function that takes a string as input and returns the number of vowels in the string.
// countVowels("Hello world") == 3
// countVowels("aeiou") == 5
// countVowels("") == 0
// countVowels("Aa") == 2
func countVowels(s: String) -> Int {
    var count = 0
    for char in s {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}

// 12. Write a function that takes a string as input and returns the number of words in the string.
// countWords("Hello world") == 2
// countWords("Hello world!") == 2
// countWords("") == 0
// countWords("Hello world!!!") == 3
func countWords(s: String) -> Int {
    var count = 0
    for char in s {
        if char == " " {
            count += 1
        }
    }
    return count + 1
}

// 13. Write a function that takes a string as input and returns the number of uppercase letters in the string.
// countUppercase("Hello world") == 2
// countUppercase("Hello World") == 2
// countUppercase("") == 0
// countUppercase("Hello World!") == 2
func countUppercase(s: String) -> Int {
    var count = 0
    for char in s {
        if char == char.uppercase {
            count += 1
        }
    }
    return count
}

// 14. Write a function that takes a string as input and returns the number of lowercase letters in the string.
// countLowercase("Hello world") == 5
// countLowercase("Hello World") == 5
// countLowercase("") == 0
// countLowercase("Hello World!") == 5
func countLowercase(s: String) -> Int {
    var count = 0
    for char in s {
        if char == char.lowercase {
            count += 1
        }
    }
    return count
}

// 15. Write a function that takes a string as input and returns the number of digits in the string.
// countDigits("Hello world") == 0
// countDigits("Hello World") == 0
// countDigits("") == 0
// countDigits("Hello World!") == 1
// countDigits("12345") == 5
func countDigits(s: String) -> Int {
    var count = 0
    for char in s {
        if char.isDigit {
            count += 1
        }
    }
    return count
}

// 16. Write a function that takes a string as input and returns the number of alphabetic characters in the string.
// countAlphabetic("Hello world") == 5
// countAlphabetic("Hello World") == 5
// countAlphabetic("") == 0
// countAlphabetic("Hello World!") == 5
// countAlphabetic("12345") == 0
// countAlphabetic("abcdefg") == 7
func countAlphabetic(s: String) -> Int {
    var count = 0
    for char in s {
        if char.isAlphabetic {
            count += 1
        }
    }
    return count
}

// 17. Write a function that takes a string as input and returns the number of consonants in the string.
if stack.isEmpty() { // cannot call value of non-function type 'Bool'
stack.pop() // value of type '[Character]' has no member 'pop'
return stack.isEmpty() // cannot call value of non-function type 'Bool'
if char == char.uppercase { // value of type 'Character' has no member 'uppercase'
if char == char.lowercase { // value of type 'Character' has no member 'lowercase'
if char.isDigit { // value of type 'Character' has no member 'isDigit'
if char.isAlphabetic { // value of type 'Character' has no member 'isAlphabetic'

func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "<" {
            stack.append(bracket)
        } else if bracket == ">" {
            if stack.isEmpty {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty
}
```swift
// brackets is a string of "<" and ">".
// return true if every opening bracket has a corresponding closing bracket.
// correctBracketing(brackets: "<") == false
// correctBracketing(brackets: "<>") == true
// correctBracketing(brackets: "<<><>>") == true
// correctBracketing(brackets: "><<>") == false
func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "<" {
            stack.append(bracket)
        } else if bracket == ">" {
            if stack.isEmpty {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty
}

// -----------------------------------------------------------------------------
// 2. Write a function that takes a string and returns the number of times
//    the letter "a" appears in it.
//    countAs("apple") == 1
//    countAs("apple apple") == 2
//    countAs("apple apple apple") == 3
//    countAs("apple apple apple a") == 4
//    countAs("apple apple apple a apple") == 5
//    countAs("apple apple apple a apple apple") == 6
//    countAs("apple apple apple a apple apple apple") == 7
//    countAs("apple apple apple a apple apple apple a") == 8
//    countAs("apple apple apple a apple apple apple a apple") == 9
//    countAs("apple apple apple a apple apple apple a apple apple") == 10
//    countAs("apple apple apple a apple apple apple a apple apple a") == 11
//    countAs("apple apple apple a apple apple apple a apple apple a apple") == 12
//    countAs("apple apple apple a apple apple apple a apple apple a apple apple") == 13
//    countAs("apple apple apple a apple apple apple a apple apple a apple apple a") == 14
//    countAs("apple apple apple a apple apple apple a apple apple a apple apple a apple") == 15
//    countAs("apple apple apple a apple apple apple a apple apple a apple apple a apple apple") == 16
//    countAs("apple apple apple a apple apple apple a apple apple a apple apple a apple apple apple") == 17
//    countAs("apple apple apple a apple apple apple a apple apple a apple apple a apple apple apple apple") == 18
//    countAs("apple apple apple a apple apple apple a apple apple a apple apple a apple apple apple apple apple") == 19
//    countAs("apple apple apple a apple apple apple a apple apple a apple apple a apple apple apple apple apple apple") == 20
//    countAs("apple apple apple a apple apple apple a apple apple a apple apple a apple apple apple apple apple apple apple") == 21
//    countAs("apple apple apple a apple apple apple a apple apple a apple apple a apple apple apple apple apple apple apple apple") == 22
//    countAs("apple apple apple a apple apple apple a apple apple a apple apple a apple apple apple apple apple apple apple apple apple") == 23
//    countAs("apple apple apple a apple apple apple a apple apple a apple apple a apple apple apple apple apple apple apple apple apple apple") == 24
//    countAs("apple apple apple a apple apple apple a apple apple a apple apple a apple apple apple apple apple apple apple apple apple apple apple") == 25
//    countAs("apple apple apple a apple apple apple a apple apple a apple apple a apple apple apple apple apple apple apple apple apple apple apple apple") == 26
//    countAs("apple apple apple a apple apple apple a apple apple a apple apple a apple apple apple apple apple apple apple apple apple apple apple apple apple") == 27
//    countAs("apple apple apple a apple apple apple a apple apple a apple apple a apple apple apple apple apple apple apple apple apple apple apple apple apple apple") == 28
//    countAs("apple apple apple a apple apple apple a apple apple a apple apple a apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple") == 29
//    countAs("apple apple apple a apple apple apple a apple apple a apple apple a apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple apple
stack.pop() // value of type '[Character]' has no member 'pop'

func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "<" {
            stack.append(bracket)
        } else {
            if stack.isEmpty {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty
}
```swift
// brackets is a string of "<" and ">".
// return true if every opening bracket has a corresponding closing bracket.
// correctBracketing(brackets: "<") == false
// correctBracketing(brackets: "<>") == true
// correctBracketing(brackets: "<<><>>") == true
// correctBracketing(brackets: "><<>") == false
func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "<" {
            stack.append(bracket)
        } else {
            if stack.isEmpty {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty
}

// -----------------------------------------------------------------------------

// 1.1.1
// Given a string, return the number of times that a substring appears as a
// contiguous substring.
// countSubstring("apple", "ple") == 1
// countSubstring("apple", "plep") == 0
// countSubstring("apple", "plepp") == 0
// countSubstring("apple", "pleppple") == 1
// countSubstring("apple", "plepppleple") == 2
// countSubstring("apple", "pleppplepleple") == 2
// countSubstring("apple", "plepppleplepleple") == 2
// countSubstring("apple", "pleppplepleplepleple") == 2
// countSubstring("apple", "plepppleplepleplepleple") == 2
// countSubstring("apple", "pleppplepleplepleplepleple") == 2
// countSubstring("apple", "plepppleplepleplepleplepleple") == 2
// countSubstring("apple", "pleppplepleplepleplepleplepleple") == 2
// countSubstring("apple", "plepppleplepleplepleplepleplepleple") == 2
// countSubstring("apple", "pleppplepleplepleplepleplepleplepleple") == 2
// countSubstring("apple", "plepppleplepleplepleplepleplepleplepleple") == 2
// countSubstring("apple", "pleppplepleplepleplepleplepleplepleplepleple") == 2
// countSubstring("apple", "plepppleplepleplepleplepleplepleplepleplepleple") == 2
// countSubstring("apple", "pleppplepleplepleplepleplepleplepleplepleplepleple") == 2
// countSubstring("apple", "plepppleplepleplepleplepleplepleplepleplepleplepleple") == 2
// countSubstring("apple", "pleppplepleplepleplepleplepleplepleplepleplepleplepleple") == 2
// countSubstring("apple", "plepppleplepleplepleplepleplepleplepleplepleplepleplepleple") == 2
// countSubstring("apple", "pleppplepleplepleplepleplepleplepleplepleplepleplepleplepleple") == 2
// countSubstring("apple", "plepppleplepleplepleplepleplepleplepleplepleplepleplepleplepleple") == 2
// countSubstring("apple", "pleppplepleplepleplepleplepleplepleplepleplepleplepleplepleplepleple") == 2
// countSubstring("apple", "plepppleplepleplepleplepleplepleplepleplepleplepleplepleplepleplepleple") == 2
// countSubstring("apple", "pleppplepleplepleplepleplepleplepleplepleplepleplepleplepleplepleplepleple") == 2
// countSubstring("apple", "plepppleplepleplepleplepleplepleplepleplepleplepleplepleplepleplepleplepleple") == 2
// countSubstring("apple", "pleppplepleplepleplepleplepleplepleplepleplepleplepleplepleplepleplepleplepleple") == 2
// countSubstring("apple", "plepppleplepleplepleplepleplepleplepleplepleplepleplepleplepleplepleplepleplepleple") == 2
// countSubstring("apple", "pleppplepleple
stack.pop() // value of type '[Character]' has no member 'pop'

func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "<" {
            stack.append(bracket)
        } else {
            if stack.isEmpty {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty
}
```swift
// brackets is a string of "<" and ">".
// return true if every opening bracket has a corresponding closing bracket.
// correctBracketing(brackets: "<") == false
// correctBracketing(brackets: "<>") == true
// correctBracketing(brackets: "<<><>>") == true
// correctBracketing(brackets: "><<>") == false
func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "<" {
            stack.append(bracket)
        } else {
            if stack.isEmpty {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty
}

// -----------------------------------------------------------------------------
// 1.1
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.2
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.3
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.4
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.5
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.6
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.7
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.8
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.9
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.10
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.11
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.12
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.13
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.14
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.15
stack.pop() // value of type '[Character]' has no member 'pop'

func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        switch bracket {
        case "<":
            stack.append(bracket)
        case ">":
            if stack.isEmpty {
                return false
            }
            stack.pop()
        default:
            return false
        }
    }
    return stack.isEmpty
}

func firstRecurringCharacter(input: String) -> String? {
    var seen = [Character]()
    for character in input {
        if seen.contains(character) {
            return String(character)
        }
        seen.append(character)
    }
    return nil
}

func mostCommonCharacter(input: String) -> String {
    var counts = [Int]()
    for character in input {
        counts[Int(character)] = counts[Int(character)] + 1
    }
    var max = 0
    var maxCharacter = ""
    for i in 0..<counts.count {
        if counts[i] > max {
            max = counts[i]
            maxCharacter = String(character: i)
        }
    }
    return maxCharacter
}

func firstNonRepeatingCharacter(input: String) -> Int {
    var seen = [Character]()
    var counts = [Int]()
    for character in input {
        if seen.contains(character) {
            counts[Int(character)] = counts[Int(character)] + 1
        } else {
            seen.append(character)
            counts.append(1)
        }
    }
    var min = Int.max
    var index = -1
    for i in 0..<counts.count {
        if counts[i] == 1 && i < min {
            min = counts[i]
            index = i
        }
    }
    return index
}
```swift
// brackets is a string of "<" and ">".
// return true if every opening bracket has a corresponding closing bracket.
// correctBracketing(brackets: "<") == false
// correctBracketing(brackets: "<>") == true
// correctBracketing(brackets: "<<><>>") == true
// correctBracketing(brackets: "><<>") == false
func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        switch bracket {
        case "<":
            stack.append(bracket)
        case ">":
            if stack.isEmpty {
                return false
            }
            stack.pop()
        default:
            return false
        }
    }
    return stack.isEmpty
}

// 2.
// Given a string, return the first recurring character in it, or null if there are no recurring characters.
// firstRecurringCharacter("abcd") == null
// firstRecurringCharacter("abcdabcd") == "d"
// firstRecurringCharacter("abcdabcde") == "d"
// firstRecurringCharacter("abcde") == null
func firstRecurringCharacter(input: String) -> String? {
    var seen = [Character]()
    for character in input {
        if seen.contains(character) {
            return String(character)
        }
        seen.append(character)
    }
    return nil
}

// 3.
// Given a string, return the character that is most commonly used in the string.
// mostCommonCharacter("abcccccccd") == "c"
// mostCommonCharacter("apple") == "p"
func mostCommonCharacter(input: String) -> String {
    var counts = [Int]()
    for character in input {
        counts[Int(character)] = counts[Int(character)] + 1
    }
    var max = 0
    var maxCharacter = ""
    for i in 0..<counts.count {
        if counts[i] > max {
            max = counts[i]
            maxCharacter = String(character: i)
        }
    }
    return maxCharacter
}

// 4.
// Given a string, find the index of the first non-repeating character.
// firstNonRepeatingCharacter("abcd") == 0
// firstNonRepeatingCharacter("abcdcd") == 2
// firstNonRepeatingCharacter("abcdcdx") == 4
// firstNonRepeatingCharacter("abcdcdxzz") == 6
func firstNonRepeatingCharacter(input: String) -> Int {
    var seen = [Character]()
    var counts = [Int]()
    for character in input {
        if seen.contains(character) {
            counts[Int(character)] = counts[Int(character)] + 1
        } else {
            seen.append(character)
            counts.append(1)
        }
    }
    var min = Int.max
    var index = -1
    for i in 0..<counts.count {
        if counts[i] == 1 && i < min {
            min = counts[i]
            index = i
        }
    }
    return index
}

// 5.
// Given a string, find the index of the first non-repeating character.
// firstNonRepeatingCharacter("abcd") == 0
// firstNonRepeatingCharacter("abcdcd") == 2
// firstNonRepeatingCharacter("abcdcdx") == 4
// firstNonRepeatingCharacter("abcdcdxzz") == 6
func firstNonRepeatingCharacter(input: String) -> Int {
    var seen = [Character]()
    var counts = [Int]()
    for character in input {
        if seen.contains(character) {
            counts[Int(character)] = counts[Int(character)] + 1
        } else {
            seen.append(character)
            counts.append(1)
        }
    }
    var min = Int.max
    var index = -1
    for i in 0..<counts.count {
        if counts[i] == 1 && i < min {
            min = counts[i]
            index = i
        }
    }
    return index
}

// 6.
// Given a string, find the index of the first non-repeating character.
// firstNonRepeatingCharacter("abcd") == 0
// firstNonRepeatingCharacter("abcdcd") == 2
// firstNonRepeatingCharacter("abcdcdx") == 4
// firstNonRepeatingCharacter("abcdcd
stack.pop() // value of type '[Character]' has no member 'pop'
counts[Int(character)] = counts[Int(character)] + 1 // no exact matches in call to initializer
counts[Int(character)] = counts[Int(character)] + 1 // no exact matches in call to initializer
maxCharacter = String(character: i) // no exact matches in call to initializer
counts[Int(character)] = counts[Int(character)] + 1 // no exact matches in call to initializer
counts[Int(character)] = counts[Int(character)] + 1 // no exact matches in call to initializer

func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "<" {
            stack.append(bracket)
        } else {
            if stack.isEmpty {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty
}

func reverseString(s: String) -> String {
    var reversed = ""
    for char in s {
        reversed = char + reversed
    }
    return reversed
}

func removeSpaces(s: String) -> String {
    var result = ""
    for char in s {
        if char != " " {
            result += char
        }
    }
    return result
}

func removeVowels(s: String) -> String {
    var result = ""
    for char in s {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

func removeVowelsAndY(s: String) -> String {
    var result = ""
    for char in s {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" && char != "y" {
            result += char
        }
    }
    return result
}
```swift
// brackets is a string of "<" and ">".
// return true if every opening bracket has a corresponding closing bracket.
// correctBracketing(brackets: "<") == false
// correctBracketing(brackets: "<>") == true
// correctBracketing(brackets: "<<><>>") == true
// correctBracketing(brackets: "><<>") == false
func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "<" {
            stack.append(bracket)
        } else {
            if stack.isEmpty {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty
}

// 10. Write a function that takes a string as input and returns the string reversed.
// reverseString("hello") == "olleh"
// reverseString("") == ""
// reverseString("h") == "h"
// reverseString("a") == "a"
// reverseString("a b") == "b a"
// reverseString("a b c") == "c b a"
// reverseString("a b c d e f g h i j k l m n o p q r s t u v w x y z") == "z y x w v u t s r q p o n m l k j i h g f e d c b a"
func reverseString(s: String) -> String {
    var reversed = ""
    for char in s {
        reversed = char + reversed
    }
    return reversed
}

// 11. Write a function that takes a string as input and returns the string with all the spaces removed.
// removeSpaces("hello world") == "helloworld"
// removeSpaces("") == ""
// removeSpaces("a") == "a"
// removeSpaces("a b") == "ab"
// removeSpaces("a b c") == "abc"
// removeSpaces("a b c d e f g h i j k l m n o p q r s t u v w x y z") == "abcdefghijklmnopqrstuvwxyz"
func removeSpaces(s: String) -> String {
    var result = ""
    for char in s {
        if char != " " {
            result += char
        }
    }
    return result
}

// 12. Write a function that takes a string as input and returns the string with all the vowels removed.
// removeVowels("hello world") == "hll wrld"
// removeVowels("") == ""
// removeVowels("a") == ""
// removeVowels("a b") == "b"
// removeVowels("a b c") == "c"
// removeVowels("a b c d e f g h i j k l m n o p q r s t u v w x y z") == "c d f g h j k l m n r s t v w x z"
func removeVowels(s: String) -> String {
    var result = ""
    for char in s {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// 13. Write a function that takes a string as input and returns the string with all the vowels removed, but with the letter "y" replaced by "i".
// removeVowelsAndY("hello world") == "hll wrld"
// removeVowelsAndY("") == ""
// removeVowelsAndY("a") == ""
// removeVowelsAndY("a b") == "b"
// removeVowelsAndY("a b c") == "c"
// removeVowelsAndY("a b c d e f g h i j k l m n o p q r s t u v w x y z") == "c d f g h j k l m n r s t v w x z"
func removeVowelsAndY(s: String) -> String {
    var result = ""
    for char in s {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" && char != "y" {
            result += char
        }
    }
    return result
}
stack.pop() // value of type '[Character]' has no member 'pop'
reversed = char + reversed // cannot convert value of type 'Character' to expected argument type 'String'
result += char // cannot convert value of type 'Character' to expected argument type 'String'
result += char // cannot convert value of type 'Character' to expected argument type 'String'
result += char // cannot convert value of type 'Character' to expected argument type 'String'

func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "<" {
            stack.append(bracket)
        } else if bracket == ">" {
            if stack.isEmpty() {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty()
}

func countVowels(s: String) -> Int {
    var count = 0
    for char in s {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}

func countWords(s: String) -> Int {
    var count = 0
    var word = ""
    for char in s {
        if char == " " {
            count += 1
            word = ""
        } else {
            word += char
        }
    }
    return count + 1
}

func countConsonants(s: String) -> Int {
    var count = 0
    for char in s {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            continue
        } else if char == " " {
            continue
        } else {
            count += 1
        }
    }
    return count
}

func countUppercase(s: String) -> Int {
    var count = 0
    for char in s {
        if char == "A" || char == "B" || char == "C" || char == "D" || char == "E" || char == "F" || char == "G" || char == "H" || char == "I" || char == "J" || char == "K" || char == "L" || char == "M" || char == "N" || char == "O" || char == "P" || char == "Q" || char == "R" || char == "S" || char == "T" || char == "U" || char == "V" || char == "W" || char == "X" || char == "Y" || char == "Z" {
            count += 1
        }
    }
    return count
}
```swift
// brackets is a string of "<" and ">".
// return true if every opening bracket has a corresponding closing bracket.
// correctBracketing(brackets: "<") == false
// correctBracketing(brackets: "<>") == true
// correctBracketing(brackets: "<<><>>") == true
// correctBracketing(brackets: "><<>") == false
func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "<" {
            stack.append(bracket)
        } else if bracket == ">" {
            if stack.isEmpty() {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty()
}

// 12. Write a function that takes a string as input and returns the number of vowels in the string.
// countVowels("Hello world") == 3
// countVowels("aeiou") == 5
// countVowels("") == 0
// countVowels("bcdfghjklmnpqrstvwxyz") == 0
func countVowels(s: String) -> Int {
    var count = 0
    for char in s {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}

// 13. Write a function that takes a string as input and returns the number of words in the string.
// countWords("Hello world") == 2
// countWords("") == 0
// countWords("a b c") == 3
// countWords("a b c d e f g h i j k l m n o p q r s t u v w x y z") == 26
func countWords(s: String) -> Int {
    var count = 0
    var word = ""
    for char in s {
        if char == " " {
            count += 1
            word = ""
        } else {
            word += char
        }
    }
    return count + 1
}

// 14. Write a function that takes a string as input and returns the number of consonants in the string.
// countConsonants("Hello world") == 5
// countConsonants("") == 0
// countConsonants("a b c") == 0
// countConsonants("a b c d e f g h i j k l m n o p q r s t u v w x y z") == 26
func countConsonants(s: String) -> Int {
    var count = 0
    for char in s {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            continue
        } else if char == " " {
            continue
        } else {
            count += 1
        }
    }
    return count
}

// 15. Write a function that takes a string as input and returns the number of uppercase letters in the string.
// countUppercase("Hello world") == 2
// countUppercase("") == 0
// countUppercase("a b c") == 0
// countUppercase("A B C") == 3
func countUppercase(s: String) -> Int {
    var count = 0
    for char in s {
        if char == "A" || char == "B" || char == "C" || char == "D" || char == "E" || char == "F" || char == "G" || char == "H" || char == "I" || char == "J" || char == "K" || char == "L" || char == "M" || char == "N" || char == "O" || char == "P" || char == "Q" || char == "R" || char == "S" || char == "T" || char == "U" || char == "V" || char == "W" || char == "X" || char == "Y" || char == "Z" {
            count += 1
        }
    }
    return count
}

// 16. Write a function that takes a string as input and returns the number of lowercase letters in the string.
// countLowercase("Hello world") == 5
// countLowercase("") == 0
// countLowercase("a b c") == 0
// countLowercase("a B c")
if stack.isEmpty() { // cannot call value of non-function type 'Bool'
stack.pop() // value of type '[Character]' has no member 'pop'
return stack.isEmpty() // cannot call value of non-function type 'Bool'
word += char // cannot convert value of type 'Character' to expected argument type 'String'

func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "<" {
            stack.append(bracket)
        } else {
            if stack.isEmpty {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty
}

func sumNumbers(input: String) -> Int {
    var sum = 0
    var i = 0
    while i < input.count {
        if Character(input[i]).isDigit {
            var num = 0
            while i < input.count && Character(input[i]).isDigit {
                num = num * 10 + Character(input[i]).asInt!
                i += 1
            }
            sum += num
        } else {
            i += 1
        }
    }
    return sum
}

func firstTwo(input: String) -> String {
    if input.count < 2 {
        return input
    }
    return input[0..<2]
}

func withouEnd2(input: String) -> String {
    return input[1..<input.count-1]
}

func equalIsNot(input: String) -> Bool {
    var isCount = 0
    var notCount = 0
    for i in 0..<input.count {
        if input[i] == "i" && input[i+1] == "s" {
            isCount += 1
        } else if input[i] == "n" && input[i+1] == "o" {
            notCount += 1
        }
    }
    return isCount == notCount
}

func atFirst(input: String) -> String {
    if input.count < 2 {
        return input + "@"
    }
    return input[0..<2]
}
```swift
// brackets is a string of "<" and ">".
// return true if every opening bracket has a corresponding closing bracket.
// correctBracketing(brackets: "<") == false
// correctBracketing(brackets: "<>") == true
// correctBracketing(brackets: "<<><>>") == true
// correctBracketing(brackets: "><<>") == false
func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "<" {
            stack.append(bracket)
        } else {
            if stack.isEmpty {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty
}

// 2. Given a string, return the sum of the numbers appearing in the string, ignoring all other characters. A number is a series of 1 or more digit chars in a row. (Note: Character.isDigit(char) tests if a char is one of the chars '0', '1', .. '9'. Integer.parseInt(string) converts a string to an int.)
// sumNumbers("abc123xyz") == 123
// sumNumbers("aa11b33") == 44
// sumNumbers("7 11") == 18
func sumNumbers(input: String) -> Int {
    var sum = 0
    var i = 0
    while i < input.count {
        if Character(input[i]).isDigit {
            var num = 0
            while i < input.count && Character(input[i]).isDigit {
                num = num * 10 + Character(input[i]).asInt!
                i += 1
            }
            sum += num
        } else {
            i += 1
        }
    }
    return sum
}

// 3. Given a string, return the string made of its first two chars, so the String "Hello" yields "He". If the string is shorter than length 2, return whatever there is, so "X" yields "X", and the empty string "" yields the empty string "".
// firstTwo("Hello") == "He"
// firstTwo("abcdefg") == "ab"
// firstTwo("ab") == "ab"
func firstTwo(input: String) -> String {
    if input.count < 2 {
        return input
    }
    return input[0..<2]
}

// 4. Given a string, return a version without the first and last char, so "Hello" yields "ell". The string length will be at least 2.
// withouEnd2("Hello") == "ell"
// withouEnd2("java") == "av"
// withouEnd2("coding") == "odin"
func withouEnd2(input: String) -> String {
    return input[1..<input.count-1]
}

// 5. Given a string, return true if the number of appearances of "is" anywhere in the string is equal to the number of appearances of "not" anywhere in the string (case sensitive).
// equalIsNot("This is not") == true
// equalIsNot("This is notnot") == false
// equalIsNot("noisxxnotyynotxisi") == true
func equalIsNot(input: String) -> Bool {
    var isCount = 0
    var notCount = 0
    for i in 0..<input.count {
        if input[i] == "i" && input[i+1] == "s" {
            isCount += 1
        } else if input[i] == "n" && input[i+1] == "o" {
            notCount += 1
        }
    }
    return isCount == notCount
}

// 6. Given a string, return a string length 2 made of its first 2 chars. If the string length is less than 2, use '@' for the missing chars.
// atFirst("hello") == "he"
// atFirst("hi") == "hi"
// atFirst("h") == "h@"
func atFirst(input: String) -> String {
    if input.count < 2 {
        return input + "@"
    }
    return input[0..<2]
}

// 7. Given 2 strings, a and b, return a string of the form short+long+short, with the shorter string on the outside and the longer string on the inside. The strings will not be the same length, but they may be
stack.pop() // value of type '[Character]' has no member 'pop'
if Character(input[i]).isDigit { // missing argument label 'extendedGraphemeClusterLiteral:' in call
if Character(input[i]).isDigit { // value of type 'Character' has no member 'isDigit'
while i < input.count && Character(input[i]).isDigit { // missing argument label 'extendedGraphemeClusterLiteral:' in call
while i < input.count && Character(input[i]).isDigit { // value of type 'Character' has no member 'isDigit'
num = num * 10 + Character(input[i]).asInt! // missing argument label 'extendedGraphemeClusterLiteral:' in call
num = num * 10 + Character(input[i]).asInt! // value of type 'Character' has no member 'asInt'
return input[0..<2] // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.
return input[1..<input.count-1] // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.
if input[i] == "i" && input[i+1] == "s" { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if input[i] == "i" && input[i+1] == "s" { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
} else if input[i] == "n" && input[i+1] == "o" { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
} else if input[i] == "n" && input[i+1] == "o" { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
return input[0..<2] // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.

func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "<" {
            stack.append(bracket)
        } else if bracket == ">" {
            if stack.isEmpty {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty
}
```swift
// brackets is a string of "<" and ">".
// return true if every opening bracket has a corresponding closing bracket.
// correctBracketing(brackets: "<") == false
// correctBracketing(brackets: "<>") == true
// correctBracketing(brackets: "<<><>>") == true
// correctBracketing(brackets: "><<>") == false
func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "<" {
            stack.append(bracket)
        } else if bracket == ">" {
            if stack.isEmpty {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ---------------
stack.pop() // value of type '[Character]' has no member 'pop'

func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "<" {
            stack.append(bracket)
        } else if bracket == ">" {
            if stack.isEmpty() {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty()
}

func palindrome(string: String) -> Bool {
    return string == string.reversed()
}
```swift
// brackets is a string of "<" and ">".
// return true if every opening bracket has a corresponding closing bracket.
// correctBracketing(brackets: "<") == false
// correctBracketing(brackets: "<>") == true
// correctBracketing(brackets: "<<><>>") == true
// correctBracketing(brackets: "><<>") == false
func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "<" {
            stack.append(bracket)
        } else if bracket == ">" {
            if stack.isEmpty() {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty()
}

// -----------------------------------------------------------------------------
// 10. Write a function that takes a string and returns true if the string is a
// palindrome.
// palindrome("racecar") == true
// palindrome("hello") == false
// palindrome("") == true
func palindrome(string: String) -> Bool {
    return string == string.reversed()
}

// -----------------------------------------------------------------------------
// 11. Write a function that takes a string and returns true if the string is a
// palindrome.
// palindrome("racecar") == true
// palindrome("hello") == false
// palindrome("") == true
func palindrome(string: String) -> Bool {
    return string == string.reversed()
}

// -----------------------------------------------------------------------------
// 12. Write a function that takes a string and returns true if the string is a
// palindrome.
// palindrome("racecar") == true
// palindrome("hello") == false
// palindrome("") == true
func palindrome(string: String) -> Bool {
    return string == string.reversed()
}

// -----------------------------------------------------------------------------
// 13. Write a function that takes a string and returns true if the string is a
// palindrome.
// palindrome("racecar") == true
// palindrome("hello") == false
// palindrome("") == true
func palindrome(string: String) -> Bool {
    return string == string.reversed()
}

// -----------------------------------------------------------------------------
// 14. Write a function that takes a string and returns true if the string is a
// palindrome.
// palindrome("racecar") == true
// palindrome("hello") == false
// palindrome("") == true
func palindrome(string: String) -> Bool {
    return string == string.reversed()
}

// -----------------------------------------------------------------------------
// 15. Write a function that takes a string and returns true if the string is a
// palindrome.
// palindrome("racecar") == true
// palindrome("hello") == false
// palindrome("") == true
func palindrome(string: String) -> Bool {
    return string == string.reversed()
}

// -----------------------------------------------------------------------------
// 16. Write a function that takes a string and returns true if the string is a
// palindrome.
// palindrome("racecar") == true
// palindrome("hello") == false
// palindrome("") == true
func palindrome(string: String) -> Bool {
    return string == string.reversed()
}

// -----------------------------------------------------------------------------
// 17. Write a function that takes a string and returns true if the string is a
// palindrome.
// palindrome("racecar") == true
// palindrome("hello") == false
// palindrome("") == true
func palindrome(string: String) -> Bool {
    return string ==
if stack.isEmpty() { // cannot call value of non-function type 'Bool'
stack.pop() // value of type '[Character]' has no member 'pop'
return stack.isEmpty() // cannot call value of non-function type 'Bool'
return string == string.reversed() // binary operator '==' cannot be applied to operands of type 'String' and '[String.Element]' (aka 'Array<Character>')

func monotonic(l: [Int]) -> Bool {
    var increasing = true
    var decreasing = true
    for i in 1..<l.count {
        if l[i] < l[i-1] {
            increasing = false
        }
        if l[i] > l[i-1] {
            decreasing = false
        }
    }
    return increasing || decreasing
}

func reverseString(s: String) -> String {
    var reversed = ""
    for i in s.reversed() {
        reversed += i
    }
    return reversed
}

func goodPairs(nums: [Int]) -> Int {
    var count = 0
    for i in 0..<nums.count {
        for j in 0..<nums.count {
            if i < j && nums[i] == nums[j] {
                count += 1
            }
        }
    }
    return count
}
```swift
// Return true is array elements are monotonically increasing or decreasing.
// monotonic(l: [1, 2, 4, 20]) == true
// monotonic(l: [1, 20, 4, 10]) == false
// monotonic(l: [4, 1, 0, -10]) == true
func monotonic(l: [Int]) -> Bool {
    var increasing = true
    var decreasing = true
    for i in 1..<l.count {
        if l[i] < l[i-1] {
            increasing = false
        }
        if l[i] > l[i-1] {
            decreasing = false
        }
    }
    return increasing || decreasing
}

// -----------------------------------------------------------------------------
// 12. Write a function that takes a string as input and returns the string reversed.
// reverseString("hello") == "olleh"
// reverseString("Greetings from Earth") == "htraE morf sgniteerG"
func reverseString(s: String) -> String {
    var reversed = ""
    for i in s.reversed() {
        reversed += i
    }
    return reversed
}

// -----------------------------------------------------------------------------
// 13. Given an array of integers nums, return the number of good pairs.
// A pair (i, j) is called good if nums[i] == nums[j] and i < j.
// nums = [1, 2, 3, 1, 1, 3]
// goodPairs(nums) == 4
// Explanation: There are 4 good pairs (0, 1), (0, 2), (2, 3), (4, 5) 0-indexed.
func goodPairs(nums: [Int]) -> Int {
    var count = 0
    for i in 0..<nums.count {
        for j in 0..<nums.count {
            if i < j && nums[i] == nums[j] {
                count += 1
            }
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// 14. Given an array of integers nums, return the number of good pairs.
// A pair (i, j) is called good if nums[i] == nums[j] and i < j.
// nums = [1, 2, 3, 1, 1, 3]
// goodPairs(nums) == 4
// Explanation: There are 4 good pairs (0, 1), (0, 2), (2, 3), (4, 5) 0-indexed.
func goodPairs(nums: [Int]) -> Int {
    var count = 0
    for i in 0..<nums.count {
        for j in 0..<nums.count {
            if i < j && nums[i] == nums[j] {
                count += 1
            }
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// 15. Given an array of integers nums, return the number of good pairs.
// A pair (i, j) is called good if nums[i] == nums[j] and i < j.
// nums = [1, 2, 3, 1, 1, 3]
// goodPairs(nums) == 4
// Explanation: There are 4 good pairs (0, 1), (0, 2), (2, 3), (4, 5) 0-indexed.
func goodPairs(nums: [Int]) -> Int {
    var count = 0
    for i in 0..<nums.count {
        for j in 0..<nums.count {
            if i < j && nums[i] == nums[j] {
                count += 1
            }
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// 16. Given an array of integers nums, return the number of good pairs.
reversed += i // cannot convert value of type 'String.Element' (aka 'Character') to expected argument type 'String'

func monotonic(l: [Int]) -> Bool {
    var increasing = true
    var decreasing = true
    for i in 1..<l.count {
        if l[i] < l[i - 1] {
            increasing = false
        }
        if l[i] > l[i - 1] {
            decreasing = false
        }
    }
    return increasing || decreasing
}

public func test_monotonic() {
    print("\n--------------------------------------------------------------------------------")
    print("monotonic")
    print("--------------------------------------------------------------------------------")

    print("monotonic([1, 2, 4, 20]) == true")
    print(monotonic([1, 2, 4, 20]))

    print("monotonic([1, 20, 4, 10]) == false")
    print(monotonic([1, 20, 4, 10]))

    print("monotonic([4, 1, 0, -10]) == true")
    print(monotonic([4, 1, 0, -10]))
}

public func run() {
    test_monotonic()
}

import Foundation

public class Solution {
    public func reverseWords(s: String) -> String {
        var words = s.split(separator: " ")
        var result = ""
        for word in words {
            result += String(word.reversed()) + " "
        }
        return result.trim()
    }
}

public func test_reverseWords() {
    print("--------------------------------------------------------------------------------")
    print("reverseWords")
    print("--------------------------------------------------------------------------------")

    print("reverseWords(\"the sky is blue\") == \"blue is sky the\"")
    print(Solution().reverseWords("the sky is blue"))

    print("reverseWords(\"  hello world!  \") == \"world! hello\"")
    print(Solution().reverseWords("  hello world!  "))

    print("reverseWords(\"a good   example\") == \"example good a\"")
    print(Solution().reverseWords("a good   example"))
}

public func run() {
    test_reverseWords()
}
```swift
// Return true is array elements are monotonically increasing or decreasing.
// monotonic(l: [1, 2, 4, 20]) == true
// monotonic(l: [1, 20, 4, 10]) == false
// monotonic(l: [4, 1, 0, -10]) == true
func monotonic(l: [Int]) -> Bool {
    var increasing = true
    var decreasing = true
    for i in 1..<l.count {
        if l[i] < l[i - 1] {
            increasing = false
        }
        if l[i] > l[i - 1] {
            decreasing = false
        }
    }
    return increasing || decreasing
}

// -----------------------------------------------------------------------------

public func test_monotonic() {
    print("\n--------------------------------------------------------------------------------")
    print("monotonic")
    print("--------------------------------------------------------------------------------")

    print("monotonic([1, 2, 4, 20]) == true")
    print(monotonic([1, 2, 4, 20]))

    print("monotonic([1, 20, 4, 10]) == false")
    print(monotonic([1, 20, 4, 10]))

    print("monotonic([4, 1, 0, -10]) == true")
    print(monotonic([4, 1, 0, -10]))
}

// -----------------------------------------------------------------------------

public func run() {
    test_monotonic()
}

// -----------------------------------------------------------------------------<|endoftext|>//
//  main.swift
//  SwiftPlayground
//
//  Created by 임성민 on 2021/02/21.
//

import Foundation

public class Solution {
    public func reverseWords(s: String) -> String {
        var words = s.split(separator: " ")
        var result = ""
        for word in words {
            result += String(word.reversed()) + " "
        }
        return result.trim()
    }
}

public func test_reverseWords() {
    print("--------------------------------------------------------------------------------")
    print("reverseWords")
    print("--------------------------------------------------------------------------------")

    print("reverseWords(\"the sky is blue\") == \"blue is sky the\"")
    print(Solution().reverseWords("the sky is blue"))

    print("reverseWords(\"  hello world!  \") == \"world! hello\"")
    print(Solution().reverseWords("  hello world!  "))

    print("reverseWords(\"a good   example\") == \"example good a\"")
    print(Solution().reverseWords("a good   example"))
}

public func run() {
    test_reverseWords()
}

// -----------------------------------------------------------------------------<|endoftext|>//
//  main.swift
//  SwiftPlayground
//
//  Created by 임성민 on 2021/02/21.
//

import Foundation

public class Solution {
    public func reverseWords(s: String) -> String {
        var words = s.split(separator: " ")
        var result = ""
        for word in words {
            result += String(word.reversed()) + " "
        }
        return result.trim()
    }
}

public func test_reverseWords() {
    print("--------------------------------------------------------------------------------")
    print("reverseWords")
    print("------------------------------------------------------------
print(monotonic([1, 2, 4, 20])) // missing argument label 'l:' in call
print(monotonic([1, 20, 4, 10])) // missing argument label 'l:' in call
print(monotonic([4, 1, 0, -10])) // missing argument label 'l:' in call
return result.trim() // value of type 'String' has no member 'trim'
print(Solution().reverseWords("the sky is blue")) // missing argument label 's:' in call
print(Solution().reverseWords("  hello world!  ")) // missing argument label 's:' in call
print(Solution().reverseWords("a good   example")) // missing argument label 's:' in call
public func run() { // invalid redeclaration of 'run()'

func monotonic(l: [Int]) -> Bool {
    var increasing = true
    var decreasing = true
    for i in 1..<l.count {
        if l[i] < l[i-1] {
            increasing = false
        }
        if l[i] > l[i-1] {
            decreasing = false
        }
    }
    return increasing || decreasing
}

func reverseString(s: String) -> String {
    return String(s.reversed())
}

func countBits(n: Int) -> Int {
    var count = 0
    while n > 0 {
        if n & 1 == 1 {
            count += 1
        }
        n >>= 1
    }
    return count
}

func findPair(l: [Int], target: Int) -> [Int] {
    var result = [Int]()
    for i in 0..<l.count {
        for j in i+1..<l.count {
            if l[i] + l[j] == target {
                result = [l[i], l[j]]
            }
        }
    }
    return result
}

func evenNumbers(l: [Int]) -> [Int] {
    var result = [Int]()
    for i in l {
        if i % 2 == 0 {
            result.append(i)
        }
    }
    return result
}

func oddNumbers(l: [Int]) -> [Int] {
    var result = [Int]()
    for i in l {
        if i % 2 != 0 {
            result.append(i)
        }
    }
    return result
}
```swift
// Return true is array elements are monotonically increasing or decreasing.
// monotonic(l: [1, 2, 4, 20]) == true
// monotonic(l: [1, 20, 4, 10]) == false
// monotonic(l: [4, 1, 0, -10]) == true
func monotonic(l: [Int]) -> Bool {
    var increasing = true
    var decreasing = true
    for i in 1..<l.count {
        if l[i] < l[i-1] {
            increasing = false
        }
        if l[i] > l[i-1] {
            decreasing = false
        }
    }
    return increasing || decreasing
}

// -----------------------------------------------------------------------------
// 10. Write a function that takes a string as input and returns the string reversed.
//     reverseString("hello") == "olleh"
//     reverseString("Greetings from Earth") == "htraE morf sgniteerG"
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// -----------------------------------------------------------------------------
// 11. Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number.
//     Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case
func countBits(n: Int) -> Int {
    var count = 0
    while n > 0 {
        if n & 1 == 1 {
            count += 1
        }
        n >>= 1
    }
    return count
}

// -----------------------------------------------------------------------------
// 12. Write a function that takes a non-empty array of distinct integers and an integer representing a target.
//     If any two numbers in the input array sum to the target, return them in an array.
//     Example: findPair([1, 2, 3, 4], 5) == [1, 4]
func findPair(l: [Int], target: Int) -> [Int] {
    var result = [Int]()
    for i in 0..<l.count {
        for j in i+1..<l.count {
            if l[i] + l[j] == target {
                result = [l[i], l[j]]
            }
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 13. Write a function that takes an array of integers and returns a new array containing all the even numbers from the original array.
//     Example: evenNumbers([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 4, 6, 8, 10]
func evenNumbers(l: [Int]) -> [Int] {
    var result = [Int]()
    for i in l {
        if i % 2 == 0 {
            result.append(i)
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 14. Write a function that takes an array of integers and returns a new array containing all the odd numbers from the original array.
//     Example: oddNumbers([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 3, 5, 7, 9]
func oddNumbers(l: [Int]) -> [Int] {
    var result = [Int]()
    for i in l {
        if i % 2 != 0 {
            result.append(i)
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 15. Write a function that takes an array of integers and returns a new array containing all the even numbers from the original array, and all the odd numbers from the original array.
//     Example: evenOdd([1, 2, 3, 
n >>= 1 // left side of mutating operator isn't mutable: 'n' is a 'let' constant

func monotonic(l: [Int]) -> Bool {
    var increasing = true
    var decreasing = true
    for i in 1..<l.count {
        if l[i] < l[i-1] {
            increasing = false
        }
        if l[i] > l[i-1] {
            decreasing = false
        }
    }
    return increasing || decreasing
}
```swift
// Return true is array elements are monotonically increasing or decreasing.
// monotonic(l: [1, 2, 4, 20]) == true
// monotonic(l: [1, 20, 4, 10]) == false
// monotonic(l: [4, 1, 0, -10]) == true
func monotonic(l: [Int]) -> Bool {
    var increasing = true
    var decreasing = true
    for i in 1..<l.count {
        if l[i] < l[i-1] {
            increasing = false
        }
        if l[i] > l[i-1] {
            decreasing = false
        }
    }
    return increasing || decreasing
}

// -----------------------------------------------------------------------------

// 10. Write a function that takes a string as input and returns the string reversed.
//     reverseString("hello") == "olleh"
//     reverseString("") == ""
//     reverseString("h") == "h"
//     reverseString("a") == "a"
//     reverseString("a b") == "b a"
//     reverseString("a b c") == "c b a"
//     reverseString("a b c d") == "d c b a"
//     reverseString("a b c d e") == "e d c b a"
//     reverseString("a b c d e f") == "f e d c b a"
//     reverseString("a b c d e f g") == "g f e d c b a"
//     reverseString("a b c d e f g h") == "h g f e d c b a"
//     reverseString("a b c d e f g h i") == "i h g f e d c b a"
//     reverseString("a b c d e f g h i j") == "j i h g f e d c b a"
//     reverseString("a b c d e f g h i j k") == "k j i h g f e d c b a"
//     reverseString("a b c d e f g h i j k l") == "l k j i h g f e d c b a"
//     reverseString("a b c d e f g h i j k l m") == "m l k j i h g f e d c b a"
//     reverseString("a b c d e f g h i j k l m n") == "n m l k j i h g f e d c b a"
//     reverseString("a b c d e f g h i j k l m n o") == "o n m l k j i h g f e d c b a"
//     reverseString("a b c d e f g h i j k l m n o p") == "p o n m l k j i h g f e d c b a"
//     reverseString("a b c d e f g h i j k l m n o p q") == "q p o n m l k j i h g f e d c b a"
//     reverseString("a b c d e f g h i j k l m n o p q r") == "r q p o n m l k j i h g f e d c b a"
//     reverseString("a b c d e f g h i j k l m n o p q r s") == "s r q p o n m l k j i h g f e d c b a"
//     reverseString("a b c d e f g h i j k l m n o p q r s t") == "t s r q p o n m l k j i h g f e d c b a"
//     reverseString("a b c d e f g h i j k l m n o p q r s t u") == "u t s r q p o n m l k j i h g f e d c b a"
//     reverseString("a b c d e f g h i j k l m n o p q r s t u v") == "v w u t s r q p o n m l k j i h g f e d c b a"
//     reverseString("a b c d e f g h i j k l m n o p q r s t u v w") == "w x v t s r q p o n m l k j i h g f e d c b a"
//     reverseString("a b c d e f g h i j

func monotonic(l: [Int]) -> Bool {
    var increasing = true
    var decreasing = true
    for i in 1..<l.count {
        if l[i] < l[i-1] {
            increasing = false
        }
        if l[i] > l[i-1] {
            decreasing = false
        }
    }
    return increasing || decreasing
}
```swift
// Return true is array elements are monotonically increasing or decreasing.
// monotonic(l: [1, 2, 4, 20]) == true
// monotonic(l: [1, 20, 4, 10]) == false
// monotonic(l: [4, 1, 0, -10]) == true
func monotonic(l: [Int]) -> Bool {
    var increasing = true
    var decreasing = true
    for i in 1..<l.count {
        if l[i] < l[i-1] {
            increasing = false
        }
        if l[i] > l[i-1] {
            decreasing = false
        }
    }
    return increasing || decreasing
}

// -----------------------------------------------------------------------------
// 1.1.1
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.2
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.3
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.4
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.5
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.6
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.7
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.8
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.9
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.10
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.11
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.12
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.13
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 1.1.14
// ---------------------------------------------------------------------

func monotonic(l: [Int]) -> Bool {
    var increasing = true
    var decreasing = true
    for i in 1..<l.count {
        if l[i] < l[i-1] {
            increasing = false
        }
        if l[i] > l[i-1] {
            decreasing = false
        }
    }
    return increasing || decreasing
}
```swift
// Return true is array elements are monotonically increasing or decreasing.
// monotonic(l: [1, 2, 4, 20]) == true
// monotonic(l: [1, 20, 4, 10]) == false
// monotonic(l: [4, 1, 0, -10]) == true
func monotonic(l: [Int]) -> Bool {
    var increasing = true
    var decreasing = true
    for i in 1..<l.count {
        if l[i] < l[i-1] {
            increasing = false
        }
        if l[i] > l[i-1] {
            decreasing = false
        }
    }
    return increasing || decreasing
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// ------------------

func monotonic(l: [Int]) -> Bool {
    var increasing = true
    var decreasing = true
    for i in 1..<l.count {
        if l[i] < l[i-1] {
            increasing = false
        }
        if l[i] > l[i-1] {
            decreasing = false
        }
    }
    return increasing || decreasing
}
```swift
// Return true is array elements are monotonically increasing or decreasing.
// monotonic(l: [1, 2, 4, 20]) == true
// monotonic(l: [1, 20, 4, 10]) == false
// monotonic(l: [4, 1, 0, -10]) == true
func monotonic(l: [Int]) -> Bool {
    var increasing = true
    var decreasing = true
    for i in 1..<l.count {
        if l[i] < l[i-1] {
            increasing = false
        }
        if l[i] > l[i-1] {
            decreasing = false
        }
    }
    return increasing || decreasing
}

print(monotonic([1, 2, 4, 20]))
print(monotonic([1, 20, 4, 10]))
print(monotonic([4, 1, 0, -10]))

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

func monotonic(l: [Int]) -> Bool {
    var increasing = true
    var decreasing = true
    for i in 1..<l.count {
        if l[i] < l[i-1] {
            increasing = false
        }
        if l[i] > l[i-1] {
            decreasing = false
        }
    }
    return increasing || decreasing
}

func reverseString(s: String) -> String {
    var reversed = ""
    for i in s.reversed() {
        reversed += i
    }
    return reversed
}

func pivotIndex(nums: [Int]) -> Int {
    var leftSum = 0
    var rightSum = 0
    for i in nums {
        rightSum += i
    }
    for i in 0..<nums.count {
        if leftSum == rightSum {
            return i
        }
        leftSum += nums[i]
        rightSum -= nums[i]
    }
    return -1
}

func pivotIndex(nums: [Int]) -> Int {
    var leftSum = 0
    var rightSum = 0
    for i in 0..<nums.count {
        rightSum += nums[i]
    }
    for i in 0..<nums.count {
        if leftSum == rightSum {
            return i
        }
        leftSum += nums[i]
        rightSum -= nums[i]
    }
    return -1
}
```swift
// Return true is array elements are monotonically increasing or decreasing.
// monotonic(l: [1, 2, 4, 20]) == true
// monotonic(l: [1, 20, 4, 10]) == false
// monotonic(l: [4, 1, 0, -10]) == true
func monotonic(l: [Int]) -> Bool {
    var increasing = true
    var decreasing = true
    for i in 1..<l.count {
        if l[i] < l[i-1] {
            increasing = false
        }
        if l[i] > l[i-1] {
            decreasing = false
        }
    }
    return increasing || decreasing
}

// -----------------------------------------------------------------------------
// 14. Write a function that takes a string as input and returns the string reversed.
// reverseString("hello") == "olleh"
// reverseString("Greetings from Earth") == "htraE morf sgniteerG"
func reverseString(s: String) -> String {
    var reversed = ""
    for i in s.reversed() {
        reversed += i
    }
    return reversed
}

// -----------------------------------------------------------------------------
// 15. Given an array of integers nums, write a method that returns the "pivot" index of this array.
// We define the pivot index as the index where the sum of the numbers to the left of the index is equal to the sum of the numbers to the right of the index.
// If no such index exists, we should return -1. If there are multiple pivot indexes, you should return the left-most pivot index.
// pivotIndex([1, 7, 3, 6, 5, 6]) == 3
// pivotIndex([1, 2, 3]) == -1
// pivotIndex([2, 1, -1]) == 0
func pivotIndex(nums: [Int]) -> Int {
    var leftSum = 0
    var rightSum = 0
    for i in nums {
        rightSum += i
    }
    for i in 0..<nums.count {
        if leftSum == rightSum {
            return i
        }
        leftSum += nums[i]
        rightSum -= nums[i]
    }
    return -1
}

// -----------------------------------------------------------------------------
// 16. Given an array of integers nums, write a method that returns the "pivot" index of this array.
// We define the pivot index as the index where the sum of the numbers to the left of the index is equal to the sum of the numbers to the right of the index.
// If no such index exists, we should return -1. If there are multiple pivot indexes, you should return the left-most pivot index.
// pivotIndex([1, 7, 3, 6, 5, 6]) == 3
// pivotIndex([1, 2, 3]) == -1
// pivotIndex([2, 1, -1]) == 0
func pivotIndex(nums: [Int]) -> Int {
    var leftSum = 0
    var rightSum = 0
    for i in 0..<nums.count {
        rightSum += nums[i]
    }
    for i in 0..<nums.count {
        if leftSum == rightSum {
            return i
        }
        leftSum += nums[i]
        rightSum -= nums[i]
    }
    return -1
}

// -----------------------------------------------------------------------------
// 17. Given an array of integers nums, write a method that returns the "pivot" index of this array.
// We define the pivot index as the index where the sum of the numbers to the left of the index is equal to the sum of the numbers to the right of the index.
// If no such index exists, we should return -1. If there are multiple pivot indexes, you should return the left-most pivot index.
// pivotIndex([1, 7, 3, 6, 5, 6]) == 3
// pivotIndex([1, 2, 3]) == -1
// pivotIndex([2, 1, -1]) == 0
func pivotIndex(nums: [Int]) -> Int {
    var leftSum = 0
reversed += i // cannot convert value of type 'String.Element' (aka 'Character') to expected argument type 'String'
func pivotIndex(nums: [Int]) -> Int { // invalid redeclaration of 'pivotIndex(nums:)'

func monotonic(l: [Int]) -> Bool {
    if l.count == 0 {
        return true
    }
    var increasing = true
    var decreasing = true
    for i in 1..<l.count {
        if l[i] < l[i-1] {
            increasing = false
        }
        if l[i] > l[i-1] {
            decreasing = false
        }
    }
    return increasing || decreasing
}
```swift
// Return true is array elements are monotonically increasing or decreasing.
// monotonic(l: [1, 2, 4, 20]) == true
// monotonic(l: [1, 20, 4, 10]) == false
// monotonic(l: [4, 1, 0, -10]) == true
func monotonic(l: [Int]) -> Bool {
    if l.count == 0 {
        return true
    }
    var increasing = true
    var decreasing = true
    for i in 1..<l.count {
        if l[i] < l[i-1] {
            increasing = false
        }
        if l[i] > l[i-1] {
            decreasing = false
        }
    }
    return increasing || decreasing
}

// -----------------------------------------------------------------------------

public func test_monotonic() {
    print("\n\n")
    print("monotonic")
    print("=========")

    print("monotonic([1, 2, 4, 20]) == true")
    print(monotonic([1, 2, 4, 20]))

    print("monotonic([1, 20, 4, 10]) == false")
    print(monotonic([1, 20, 4, 10]))

    print("monotonic([4, 1, 0, -10]) == true")
    print(monotonic([4, 1, 0, -10]))

    print("monotonic([]) == true")
    print(monotonic([]))

    print("monotonic([1]) == true")
    print(monotonic([1]))

    print("monotonic([1, 1]) == true")
    print(monotonic([1, 1]))

    print("monotonic([1, 1, 1]) == true")
    print(monotonic([1, 1, 1]))

    print("monotonic([1, 1, 1, 1]) == true")
    print(monotonic([1, 1, 1, 1]))

    print("monotonic([1, 1, 1, 1, 1]) == true")
    print(monotonic([1, 1, 1, 1, 1]))

    print("monotonic([1, 1, 1, 1, 1, 1]) == true")
    print(monotonic([1, 1, 1, 1, 1, 1]))

    print("monotonic([1, 1, 1, 1, 1, 1, 1]) == true")
    print(monotonic([1, 1, 1, 1, 1, 1, 1]))

    print("monotonic([1, 1, 1, 1, 1, 1, 1, 1]) == true")
    print(monotonic([1, 1, 1, 1, 1, 1, 1, 1]))

    print("monotonic([1, 1, 1, 1, 1, 1, 1, 1, 1]) == true")
    print(monotonic([1, 1, 1, 1, 1, 1, 1, 1, 1]))

    print("monotonic([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == true")
    print(monotonic([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))

    print("monotonic([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == true")
    print(monotonic([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))

    print("monotonic([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == true")
    print(monotonic([1, 1, 1, 1, 1, 

func monotonic(l: [Int]) -> Bool {
    var increasing = true
    var decreasing = true
    for i in 1..<l.count {
        if l[i] < l[i-1] {
            increasing = false
        }
        if l[i] > l[i-1] {
            decreasing = false
        }
    }
    return increasing || decreasing
}
```swift
// Return true is array elements are monotonically increasing or decreasing.
// monotonic(l: [1, 2, 4, 20]) == true
// monotonic(l: [1, 20, 4, 10]) == false
// monotonic(l: [4, 1, 0, -10]) == true
func monotonic(l: [Int]) -> Bool {
    var increasing = true
    var decreasing = true
    for i in 1..<l.count {
        if l[i] < l[i-1] {
            increasing = false
        }
        if l[i] > l[i-1] {
            decreasing = false
        }
    }
    return increasing || decreasing
}

// -----------------------------------------------------------------------------

// 1.1.2
// Given two strings, write a method to decide if one is a permutation of the
// other.
//
// Example:
//
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPermutation("abcd", "dabc") == true
// isPerm

func common(l1: [Int], l2: [Int]) -> [Int] {
    return l1.filter { l2.contains($0) }
}

func reverseString(s: String) -> String {
    return String(s.reversed())
}

func countBits(n: Int) -> Int {
    return String(n, radix: 2).filter { $0 == "1" }.count
}

func swapCase(s: String) -> String {
    return String(s.map { $0.isUpperCase() ? $0.lowerCase() : $0.upperCase() })
}
```swift
// Return sorted unique common elements for two arrays.
// common(l1: [1, 4, 3, 34, 653, 2, 5], l2: [5, 7, 1, 5, 9, 653, 121]) == [1, 5, 653]
// common(l1: [5, 3, 2, 8], l2: [3, 2]) == [2, 3]
func common(l1: [Int], l2: [Int]) -> [Int] {
    return l1.filter { l2.contains($0) }
}

// 2. Write a function that takes a string as input and returns the string reversed.
// reverseString("hello") == "olleh"
// reverseString("Greetings!") == "!sgniteerG"
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// 3. Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number.
// Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case
// countBits(1234) == 5
func countBits(n: Int) -> Int {
    return String(n, radix: 2).filter { $0 == "1" }.count
}

// 4. Write a function that takes a string as input and returns the string with all lowercase characters changed to uppercase and vice versa.
// swapCase("Hello, World!") == "hELLO, wORLD!"
// swapCase("HELLO, WORLD!") == "hello, world!"
func swapCase(s: String) -> String {
    return String(s.map { $0.isUpperCase() ? $0.lowerCase() : $0.upperCase() })
}

// 5. Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number.
// Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case
// countBits(1234) == 5
func countBits(n: Int) -> Int {
    return String(n, radix: 2).filter { $0 == "1" }.count
}

// 6. Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number.
// Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case
// countBits(1234) == 5
func countBits(n: Int) -> Int {
    return String(n, radix: 2).filter { $0 == "1" }.count
}

// 7. Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number.
// Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case
// countBits(1234) == 5
func countBits(n: Int) -> Int {
    return String(n, radix: 2).filter { $0 == "1" }.count
}

// 8. Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number.
// Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case
// countBits(1234) == 5
func countBits(n: Int) -> Int {
    return String(n, radix: 2).filter { $0 == "1" }.count
}

// 9. Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number.
// Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case
// countBits(1234) == 5
func countBits(n: Int) -> Int {
    return String(n, radix: 2).filter { $0 == "1" }.count
}

// 10. Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number.
// Example: The binary representation of 1234 is 100110100
return String(s.map { $0.isUpperCase() ? $0.lowerCase() : $0.upperCase() }) // value of type 'String.Element' (aka 'Character') has no member 'lowerCase'
return String(s.map { $0.isUpperCase() ? $0.lowerCase() : $0.upperCase() }) // value of type 'String.Element' (aka 'Character') has no member 'isUpperCase'
return String(s.map { $0.isUpperCase() ? $0.lowerCase() : $0.upperCase() }) // value of type 'String.Element' (aka 'Character') has no member 'upperCase'

func common(l1: [Int], l2: [Int]) -> [Int] {
    var result = []
    for i in l1 {
        if l2.contains(i) {
            result.append(i)
        }
    }
    return result
}

func reverseString(s: String) -> String {
    return String(s.reversed())
}
```swift
// Return sorted unique common elements for two arrays.
// common(l1: [1, 4, 3, 34, 653, 2, 5], l2: [5, 7, 1, 5, 9, 653, 121]) == [1, 5, 653]
// common(l1: [5, 3, 2, 8], l2: [3, 2]) == [2, 3]
func common(l1: [Int], l2: [Int]) -> [Int] {
    var result = []
    for i in l1 {
        if l2.contains(i) {
            result.append(i)
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.1.1
// -----------------------------------------------------------------------------
// Write a function that takes a string as input and returns the string reversed.
// Example:
// Given s = "hello", return "olleh".
// -----------------------------------------------------------------------------
// reverseString("hello") == "olleh"
// reverseString("hello world") == "dlrow olleh"
// reverseString("") == ""
// reverseString("a") == "a"
// reverseString("abc") == "cba"
// reverseString("abcdef") == "fedcba"
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// -----------------------------------------------------------------------------
// 1.1.2
// -----------------------------------------------------------------------------
// Given an array of integers, return indices of the two numbers such that they add up to a specific target.
// You may assume that each input would have exactly one solution, and you may not use the same element twice.
// Example:
// Given nums = [2, 7, 11, 15], target = 9,
// Because nums[0] + nums[1] = 2 + 7 = 9,
// return [0, 1].
// -----------------------------------------------------------------------------
// twoSum([2, 7, 11, 15], 9) == [0, 1]
// twoSum([2, 7, 11, 15], 18) == [1, 2]
// twoSum([2, 7, 11, 15], 17) == [0, 2]
// twoSum([2, 7, 11, 15], 16) == [1, 3]
// twoSum([2, 7, 11, 15], 15) == [0, 3]
// twoSum([2, 7, 11, 15], 14) == [1, 3]
// twoSum([2, 7, 11, 15], 13) == [0, 3]
// twoSum([2, 7, 11, 15], 12) == [1, 3]
// twoSum([2, 7, 11, 15], 11) == [0, 3]
// twoSum([2, 7, 11, 15], 10) == [1, 3]
// twoSum([2, 7, 11, 15], 9) == [0, 3]
// twoSum([2, 7, 11, 15], 8) == [1, 3]
// twoSum([2, 7, 11, 15], 7) == [0, 3]
// twoSum([2, 7, 11, 15], 6) == [1, 3]
// twoSum([2, 7, 11, 15], 5) == [0, 3]
// twoSum([2, 7, 11, 15], 4) == [1, 3]
// twoSum([2, 7, 11, 15], 3) == [0, 3]
// twoSum([2, 7, 11, 15], 2) == [0
var result = [] // empty collection literal requires an explicit type
return result // cannot convert return expression of type '[Any]' to return type '[Int]'

func common(l1: [Int], l2: [Int]) -> [Int] {
    var result = []
    for i in l1 {
        if l2.contains(i) {
            result.append(i)
        }
    }
    return result
}
```swift
// Return sorted unique common elements for two arrays.
// common(l1: [1, 4, 3, 34, 653, 2, 5], l2: [5, 7, 1, 5, 9, 653, 121]) == [1, 5, 653]
// common(l1: [5, 3, 2, 8], l2: [3, 2]) == [2, 3]
func common(l1: [Int], l2: [Int]) -> [Int] {
    var result = []
    for i in l1 {
        if l2.contains(i) {
            result.append(i)
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ------------------------------------------------------
var result = [] // empty collection literal requires an explicit type
return result // cannot convert return expression of type '[Any]' to return type '[Int]'

func common(l1: [Int], l2: [Int]) -> [Int] {
    var result = [Int]()
    var i = 0
    var j = 0
    while i < l1.count && j < l2.count {
        if l1[i] == l2[j] {
            result.append(l1[i])
            i += 1
            j += 1
        } else if l1[i] < l2[j] {
            i += 1
        } else {
            j += 1
        }
    }
    return result
}
```swift
// Return sorted unique common elements for two arrays.
// common(l1: [1, 4, 3, 34, 653, 2, 5], l2: [5, 7, 1, 5, 9, 653, 121]) == [1, 5, 653]
// common(l1: [5, 3, 2, 8], l2: [3, 2]) == [2, 3]
func common(l1: [Int], l2: [Int]) -> [Int] {
    var result = [Int]()
    var i = 0
    var j = 0
    while i < l1.count && j < l2.count {
        if l1[i] == l2[j] {
            result.append(l1[i])
            i += 1
            j += 1
        } else if l1[i] < l2[j] {
            i += 1
        } else {
            j += 1
        }
    }
    return result
}

// -----------------------------------------------------------------------------

// 1. Write a function that takes a string as an argument and returns a new string that contains the same letters in the same order, but with each duplicate removed.
// removeDuplicates("abcde") == "abcde"
// removeDuplicates("abcabc") == "abc"
// removeDuplicates("abbbc") == "ab"
// removeDuplicates("") == ""
// removeDuplicates("aabbcc") == "abc"
// removeDuplicates("aabbccddeff") == "abcdef"
// removeDuplicates("abcabcabc") == "abc"
// removeDuplicates("abcabcabcabc") == "abc"
// removeDuplicates("abcabcabcabcdefghijklmno") == "abcdefghijklmno"
// removeDuplicates("abcabcabcabcdefghijklmnoabc") == "abcdefghijklmnoabc"
// removeDuplicates("abcabcabcabcdefghijklmnoabcabc") == "abcdefghijklmnoabc"
// removeDuplicates("abcabcabcabcdefghijklmnoabcabcabc") == "abcdefghijklmnoabc"
// removeDuplicates("abcabcabcabcdefghijklmnoabcabcabcabc") == "abcdefghijklmnoabc"
// removeDuplicates("abcabcabcabcdefghijklmnoabcabcabcabcabc") == "abcdefghijklmnoabc"
// removeDuplicates("abcabcabcabcdefghijklmnoabcabcabcabcabcabc") == "abcdefghijklmnoabc"
// removeDuplicates("abcabcabcabcdefghijklmnoabcabcabcabcabcabcabc") == "abcdefghijklmnoabc"
// removeDuplicates("abcabcabcabcdefghijklmnoabcabcabcabcabcabcabcabc") == "abcdefghijklmnoabc"
// removeDuplicates("abcabcabcabcdefghijklmnoabcabcabcabcabcabcabcabcabc") == "abcdefghijklmnoabc"
// removeDuplicates("abcabcabcabcdefghijklmnoabcabcabcabcabcabcabcabcabcabc") == "abcdefghijklmnoabc"
// removeDuplicates("abcabcabcabcdefghijklmnoabcabcabcabcabcabcabcabcabcabcabc") == "abcdefghijklmnoabc"
// removeDuplicates("abcabcabcabcdefghijklmnoabcabcabcabcabcabcabcabcabcabcabcabc") == "abcdefghijklmnoabc"
// removeDuplicates("abcabcabcabcdefghijklmnoabcabcabcabcabcabcabcabcabcabcabcabcabc") == "abcdefghijklmnoabc"
// removeDuplicates("abcabcabcabcdefghijklmnoabcabcabcabcabcabcabcabcabcabcabcabcabcabc") == "abcdefghijklmnoabc"
// removeDuplicates("abcabcabcabcdefghijklmnoabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc") == "abcdefghijklmnoabc"
// removeDuplicates("abcabcabcabcdefghijklmnoabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc") == "abcdefghijklmnoabc"
// removeDuplicates("abcabcabcabcdefghijklmnoabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc"
 // XCTAssertTrue failed

func common(l1: [Int], l2: [Int]) -> [Int] {
    var result = []
    var l1Set = Set(l1)
    for i in l2 {
        if l1Set.contains(i) {
            result.append(i)
        }
    }
    return result
}

func removeVowels(str: String) -> String {
    var result = ""
    for char in str {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}
```swift
// Return sorted unique common elements for two arrays.
// common(l1: [1, 4, 3, 34, 653, 2, 5], l2: [5, 7, 1, 5, 9, 653, 121]) == [1, 5, 653]
// common(l1: [5, 3, 2, 8], l2: [3, 2]) == [2, 3]
func common(l1: [Int], l2: [Int]) -> [Int] {
    var result = []
    var l1Set = Set(l1)
    for i in l2 {
        if l1Set.contains(i) {
            result.append(i)
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// 1. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I love learning Swift") == " lv lrnng Swtft"
// removeVowels("I love learning Swift") == " lv lrnng Swtft"
func removeVowels(str: String) -> String {
    var result = ""
    for char in str {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// 2. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I love learning Swift") == " lv lrnng Swtft"
// removeVowels("I love learning Swift") == " lv lrnng Swtft"
func removeVowels(str: String) -> String {
    var result = ""
    for char in str {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// 3. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I love learning Swift") == " lv lrnng Swtft"
// removeVowels("I love learning Swift") == " lv lrnng Swtft"
func removeVowels(str: String) -> String {
    var result = ""
    for char in str {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// 4. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I love learning Swift") == " lv lrnng Swtft"
// removeVowels("I love learning Swift") == " lv lrnng Swtft"
func removeVowels(str: String) -> String {
    var result = ""
    for char in str {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// 5. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I love learning Swift") == " lv lrnng Swtft"
// removeVowels("I love learning Swift") == " lv lrnng Swtft"
func removeVowels(str: String) -> String {
    var result = ""
    for char in str {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// 6. Write a function that takes a string and returns a new string with all vowels removed.
// removeVowels("I love learning Swift") == " lv
var result = [] // empty collection literal requires an explicit type
return result // cannot convert return expression of type '[Any]' to return type '[Int]'
if !isVowel(char) { // cannot find 'isVowel' in scope
result += char // cannot convert value of type 'Character' to expected argument type 'String'

func common(l1: [Int], l2: [Int]) -> [Int] {
    var result = [Int]()
    var i = 0
    var j = 0
    while i < l1.count && j < l2.count {
        if l1[i] == l2[j] {
            result.append(l1[i])
            i += 1
            j += 1
        } else if l1[i] < l2[j] {
            i += 1
        } else {
            j += 1
        }
    }
    return result
}
```swift
// Return sorted unique common elements for two arrays.
// common(l1: [1, 4, 3, 34, 653, 2, 5], l2: [5, 7, 1, 5, 9, 653, 121]) == [1, 5, 653]
// common(l1: [5, 3, 2, 8], l2: [3, 2]) == [2, 3]
func common(l1: [Int], l2: [Int]) -> [Int] {
    var result = [Int]()
    var i = 0
    var j = 0
    while i < l1.count && j < l2.count {
        if l1[i] == l2[j] {
            result.append(l1[i])
            i += 1
            j += 1
        } else if l1[i] < l2[j] {
            i += 1
        } else {
            j += 1
        }
    }
    return result
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ---------------------------------
 // XCTAssertTrue failed

func common(l1: [Int], l2: [Int]) -> [Int] {
    return l1.filter { l2.contains($0) }
}

func removeVowels(str: String) -> String {
    return str.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "")
}
```swift
// Return sorted unique common elements for two arrays.
// common(l1: [1, 4, 3, 34, 653, 2, 5], l2: [5, 7, 1, 5, 9, 653, 121]) == [1, 5, 653]
// common(l1: [5, 3, 2, 8], l2: [3, 2]) == [2, 3]
func common(l1: [Int], l2: [Int]) -> [Int] {
    return l1.filter { l2.contains($0) }
}

// -----------------------------------------------------------------------------
// 1.2. Write a function that takes a string and returns a new string with all
// the vowels removed.
// removeVowels("I am awesome") == "m  wsm"
// removeVowels("Hello world") == "Hll wrld"
// removeVowels("") == ""
func removeVowels(str: String) -> String {
    return str.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "")
}

// -----------------------------------------------------------------------------
// 1.3. Write a function that takes a string and returns a new string with all
// the vowels removed.
// removeVowels("I am awesome") == "m  wsm"
// removeVowels("Hello world") == "Hll wrld"
// removeVowels("") == ""
func removeVowels(str: String) -> String {
    return str.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "")
}

// -----------------------------------------------------------------------------
// 1.4. Write a function that takes a string and returns a new string with all
// the vowels removed.
// removeVowels("I am awesome") == "m  wsm"
// removeVowels("Hello world") == "Hll wrld"
// removeVowels("") == ""
func removeVowels(str: String) -> String {
    return str.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "")
}

// -----------------------------------------------------------------------------
// 1.5. Write a function that takes a string and returns a new string with all
// the vowels removed.
// removeVowels("I am awesome") == "m  wsm"
// removeVowels("Hello world") == "Hll wrld"
// removeVowels("") == ""
func removeVowels(str: String) -> String {
    return str.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "")
}

// -----------------------------------------------------------------------------
// 1.6. Write a function that takes a string and returns a new string with all
// the vowels removed.
// removeVowels("I am awesome") == "m  wsm"
// removeVowels("Hello world") == "Hll wrld"
// removeVowels("") == ""
func removeVowels(str: String) -> String {
    return str.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "")
}

// -----------------------------------------------------------------------------
// 1.7. Write a function that takes a string and returns a new string with all
// the vowels removed.
// removeVowels("I am awesome") == "m  wsm"
// removeVowels("Hello world") == "Hll wrld"
// removeVowels(""
return str.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "") // cannot use mutating member on immutable value: 'str' is a 'let' constant
return str.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "") // missing argument label 'with:' in call
return str.replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "") // value of tuple type '()' has no member 'replace'

func common(l1: [Int], l2: [Int]) -> [Int] {
    var result = [Int]()
    var i = 0
    var j = 0
    while i < l1.count && j < l2.count {
        if l1[i] == l2[j] {
            result.append(l1[i])
            i += 1
            j += 1
        } else if l1[i] < l2[j] {
            i += 1
        } else {
            j += 1
        }
    }
    return result
}
```swift
// Return sorted unique common elements for two arrays.
// common(l1: [1, 4, 3, 34, 653, 2, 5], l2: [5, 7, 1, 5, 9, 653, 121]) == [1, 5, 653]
// common(l1: [5, 3, 2, 8], l2: [3, 2]) == [2, 3]
func common(l1: [Int], l2: [Int]) -> [Int] {
    var result = [Int]()
    var i = 0
    var j = 0
    while i < l1.count && j < l2.count {
        if l1[i] == l2[j] {
            result.append(l1[i])
            i += 1
            j += 1
        } else if l1[i] < l2[j] {
            i += 1
        } else {
            j += 1
        }
    }
    return result
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
 // XCTAssertTrue failed

func common(l1: [Int], l2: [Int]) -> [Int] {
    return l1.filter { l2.contains($0) }.sorted()
}

func reverse(s: String) -> String {
    return String(s.reversed())
}
```swift
// Return sorted unique common elements for two arrays.
// common(l1: [1, 4, 3, 34, 653, 2, 5], l2: [5, 7, 1, 5, 9, 653, 121]) == [1, 5, 653]
// common(l1: [5, 3, 2, 8], l2: [3, 2]) == [2, 3]
func common(l1: [Int], l2: [Int]) -> [Int] {
    return l1.filter { l2.contains($0) }.sorted()
}

// -----------------------------------------------------------------------------
// 2. Write a function that takes a string and returns a new string with all
//    characters in reverse order.
//    reverse("hello") == "olleh"
//    reverse("") == ""
//    reverse("h") == "h"
//    reverse("a") == "a"
//    reverse("a b c") == "c b a"
//    reverse("a b c d e f g h i j k l m n o p q r s t u v w x y z") == "zyxwvutsrqponmlkjihgfedcba"
// -----------------------------------------------------------------------------
// 2. Write a function that takes a string and returns a new string with all
//    characters in reverse order.
//    reverse("hello") == "olleh"
//    reverse("") == ""
//    reverse("h") == "h"
//    reverse("a") == "a"
//    reverse("a b c") == "c b a"
//    reverse("a b c d e f g h i j k l m n o p q r s t u v w x y z") == "zyxwvutsrqponmlkjihgfedcba"
func reverse(s: String) -> String {
    return String(s.reversed())
}

// -----------------------------------------------------------------------------
// 3. Write a function that takes a string and returns a new string with all
//    characters in reverse order.
//    reverse("hello") == "olleh"
//    reverse("") == ""
//    reverse("h") == "h"
//    reverse("a") == "a"
//    reverse("a b c") == "c b a"
//    reverse("a b c d e f g h i j k l m n o p q r s t u v w x y z") == "zyxwvutsrqponmlkjihgfedcba"
// -----------------------------------------------------------------------------
// 3. Write a function that takes a string and returns a new string with all
//    characters in reverse order.
//    reverse("hello") == "olleh"
//    reverse("") == ""
//    reverse("h") == "h"
//    reverse("a") == "a"
//    reverse("a b c") == "c b a"
//    reverse("a b c d e f g h i j k l m n o p q r s t u v w x y z") == "zyxwvutsrqponmlkjihgfedcba"
func reverse(s: String) -> String {
    return String(s.reversed())
}

// -----------------------------------------------------------------------------
// 4. Write a function that takes a string and returns a new string with all
//    characters in reverse order.
//    reverse("hello") == "olleh"
//    reverse("") == ""
//    reverse("h") == "h"
//    reverse("a") == "a"
//    reverse("a b c") == "c b a"
//    reverse("a b c d e f g h i j k l m n o p q r s t u v w x y z") == "zyxwvutsrqponmlkjihgfedcba"
// -----------------------------------------------------------------------------
// 4. Write a function that takes a string and returns a new string with all
//    characters in reverse order.
//    reverse("hello") == "

func common(l1: [Int], l2: [Int]) -> [Int] {
    var result = [Int]()
    var i = 0
    var j = 0
    while i < l1.count && j < l2.count {
        if l1[i] == l2[j] {
            result.append(l1[i])
            i += 1
            j += 1
        } else if l1[i] < l2[j] {
            i += 1
        } else {
            j += 1
        }
    }
    return result
}

import Foundation
```swift
// Return sorted unique common elements for two arrays.
// common(l1: [1, 4, 3, 34, 653, 2, 5], l2: [5, 7, 1, 5, 9, 653, 121]) == [1, 5, 653]
// common(l1: [5, 3, 2, 8], l2: [3, 2]) == [2, 3]
func common(l1: [Int], l2: [Int]) -> [Int] {
    var result = [Int]()
    var i = 0
    var j = 0
    while i < l1.count && j < l2.count {
        if l1[i] == l2[j] {
            result.append(l1[i])
            i += 1
            j += 1
        } else if l1[i] < l2[j] {
            i += 1
        } else {
            j += 1
        }
    }
    return result
}

print(common(l1: [1, 4, 3, 34, 653, 2, 5], l2: [5, 7, 1, 5, 9, 653, 121]))
print(common(l1: [5, 3, 2, 8], l2: [3, 2]))<|endoftext|>//
//  main.swift
//  100DaysOfSwift
//
//  Created by 임성민 on 2022/07/15.
//

import Foundation

var a = 10
var b = 20

var c = a + b

print(c)

var d = a - b

print(d)

var e = a * b

print(e)

var f = a / b

print(f)

var g = a % b

print(g)

var h = a ** b

print(h)

var i = a++

print(i)

var j = ++a

print(j)

var k = a--

print(k)

var l = --a

print(l)

var m = a == b

print(m)

var n = a != b

print(n)

var o = a > b

print(o)

var p = a < b

print(p)

var q = a >= b

print(q)

var r = a <= b

print(r)

var s = a && b

print(s)

var t = a || b

print(t)

var u = !a

print(u)

var v = a ?? b

print(v)

var w = a ?? 100

print(w)

var x = a ?? 100 ?? 200

print(x)

var y = a ?? 100 ?? 200 ?? 300

print(y)

var z = a ?? 100 ?? 200 ?? 300 ?? 400

print(z)

var aa = a ?? 100 ?? 200 ?? 300 ?? 400 ?? 500

print(aa)

var bb = a ?? 100 ?? 200 ?? 300 ?? 400 ?? 500 ?? 600

print(bb)

var cc = a ?? 100 ?? 200 ?? 300 ?? 400 ?? 500 ?? 600 ?? 700

print(cc)

var dd = a ?? 100 ?? 200 ?? 300 ?? 400 ?? 500 ?? 600 ?? 700 ?? 800

print(dd)

var ee = a ?? 100 ?? 200 ?? 300 ?? 400 ?? 500 ?? 600 ?? 700 ?? 800 ?? 900

print(ee)

var ff = a ?? 100 ?? 200 ?? 300
 // XCTAssertTrue failed

func largestPrimeFactor(n: Int) -> Int {
    var largest = 1
    for i in 2...n {
        if n % i == 0 {
            largest = i
            while n % i == 0 {
                n /= i
            }
        }
    }
    return largest
}
```swift
// Return the largest prime factor of n. Assume n > 1 and is not a prime.
// largestPrimeFactor(n: 13195) == 29
// largestPrimeFactor(n: 2048) == 2
func largestPrimeFactor(n: Int) -> Int {
    var largest = 1
    for i in 2...n {
        if n % i == 0 {
            largest = i
            while n % i == 0 {
                n /= i
            }
        }
    }
    return largest
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// ---------------------------------------------------------------------------
n /= i // left side of mutating operator isn't mutable: 'n' is a 'let' constant

func largestPrimeFactor(n: Int) -> Int {
    var i = 2
    while i * i <= n {
        if n % i == 0 {
            n /= i
        } else {
            i += 1
        }
    }
    return n
}
```swift
// Return the largest prime factor of n. Assume n > 1 and is not a prime.
// largestPrimeFactor(n: 13195) == 29
// largestPrimeFactor(n: 2048) == 2
func largestPrimeFactor(n: Int) -> Int {
    var i = 2
    while i * i <= n {
        if n % i == 0 {
            n /= i
        } else {
            i += 1
        }
    }
    return n
}

// 2. 소수 판별
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
n /= i // left side of mutating operator isn't mutable: 'n' is a 'let' constant

func largestPrimeFactor(n: Int) -> Int {
    var largest = 1
    var i = 2
    while i * i <= n {
        if n % i == 0 {
            n /= i
            largest = i
        } else {
            i += 1
        }
    }
    return n == 1 ? largest : n
}
```swift
// Return the largest prime factor of n. Assume n > 1 and is not a prime.
// largestPrimeFactor(n: 13195) == 29
// largestPrimeFactor(n: 2048) == 2
func largestPrimeFactor(n: Int) -> Int {
    var largest = 1
    var i = 2
    while i * i <= n {
        if n % i == 0 {
            n /= i
            largest = i
        } else {
            i += 1
        }
    }
    return n == 1 ? largest : n
}

// -----------------------------------------------------------------------------
// 14. Longest Collatz sequence
// -----------------------------------------------------------------------------
//
// The following iterative sequence is defined for the set of positive integers:
//
// n → n/2 (n is even)
// n → 3n + 1 (n is odd)
//
// Using the rule above and starting with 13, we generate the following sequence:
//
// 13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1
//
// It can be seen that this sequence (starting at 13 and finishing at 1) contains
// 10 terms. Although it has not been proved yet (Collatz Problem), it is thought
// that all starting numbers finish at 1.
//
// Which starting number, under one million, produces the longest chain?
//
// NOTE: Once the chain starts the terms are allowed to go above one million.
//
// -----------------------------------------------------------------------------
//
// 14. Longest Collatz sequence
// -----------------------------------------------------------------------------
//
// The following iterative sequence is defined for the set of positive integers:
//
// n → n/2 (n is even)
// n → 3n + 1 (n is odd)
//
// Using the rule above and starting with 13, we generate the following sequence:
//
// 13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1
//
// It can be seen that this sequence (starting at 13 and finishing at 1) contains
// 10 terms. Although it has not been proved yet (Collatz Problem), it is thought
// that all starting numbers finish at 1.
//
// Which starting number, under one million, produces the longest chain?
//
// NOTE: Once the chain starts the terms are allowed to go above one million.
//
// -----------------------------------------------------------------------------
//
// 14. Longest Collatz sequence
// -----------------------------------------------------------------------------
//
// The following iterative sequence is defined for the set of positive integers:
//
// n → n/2 (n is even)
// n → 3n + 1 (n is odd)
//
// Using the rule above and starting with 13, we generate the following sequence:
//
// 13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1
//
// It can be seen that this sequence (starting at 13 and finishing at 1) contains
// 10 terms. Although it has not been proved yet (Collatz Problem), it is thought
// that all starting numbers finish at 1.
//
// Which starting number, under one million, produces the longest chain?
//
// NOTE: Once the chain starts the terms are allowed to go above one million.
//
// -----------------------------------------------------------------------------
//
// 14. Longest Collatz sequence
// -----------------------------------------------------------------------------
//
// The following iterative sequence is defined for the set of positive integers:
//
// n → n/2 (n is even)
// n → 3n + 1 (n is odd)
//
// Using the rule above and starting
n /= i // left side of mutating operator isn't mutable: 'n' is a 'let' constant

func largestPrimeFactor(n: Int) -> Int {
    var largest = 1
    var i = 2
    while i * i <= n {
        if n % i == 0 {
            largest = i
            n /= i
        } else {
            i += 1
        }
    }
    return n == 1 ? largest : n
}
```swift
// Return the largest prime factor of n. Assume n > 1 and is not a prime.
// largestPrimeFactor(n: 13195) == 29
// largestPrimeFactor(n: 2048) == 2
func largestPrimeFactor(n: Int) -> Int {
    var largest = 1
    var i = 2
    while i * i <= n {
        if n % i == 0 {
            largest = i
            n /= i
        } else {
            i += 1
        }
    }
    return n == 1 ? largest : n
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// ---------------------------------------------
n /= i // left side of mutating operator isn't mutable: 'n' is a 'let' constant

func largestPrimeFactor(n: Int) -> Int {
    var largestPrime = 1
    var i = 2
    while i * i <= n {
        if n % i == 0 {
            largestPrime = i
            n /= i
        } else {
            i += 1
        }
    }
    return largestPrime
}
```swift
// Return the largest prime factor of n. Assume n > 1 and is not a prime.
// largestPrimeFactor(n: 13195) == 29
// largestPrimeFactor(n: 2048) == 2
func largestPrimeFactor(n: Int) -> Int {
    var largestPrime = 1
    var i = 2
    while i * i <= n {
        if n % i == 0 {
            largestPrime = i
            n /= i
        } else {
            i += 1
        }
    }
    return largestPrime
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// ---------------------------------------------------
n /= i // left side of mutating operator isn't mutable: 'n' is a 'let' constant

func largestPrimeFactor(n: Int) -> Int {
    var largest = 1
    for i in 2...n {
        if n % i == 0 {
            largest = i
            while n % i == 0 {
                n /= i
            }
        }
    }
    return largest
}

func reverseString(s: String) -> String {
    var reversed = ""
    for i in s.reversed() {
        reversed += i
    }
    return reversed
}

func countBits(n: Int) -> Int {
    var count = 0
    while n > 0 {
        if n & 1 == 1 {
            count += 1
        }
        n >>= 1
    }
    return count
}

func countSetBits(n: Int) -> Int {
    var count = 0
    while n > 0 {
        count += n & 1
        n >>= 1
    }
    return count
}
```swift
// Return the largest prime factor of n. Assume n > 1 and is not a prime.
// largestPrimeFactor(n: 13195) == 29
// largestPrimeFactor(n: 2048) == 2
func largestPrimeFactor(n: Int) -> Int {
    var largest = 1
    for i in 2...n {
        if n % i == 0 {
            largest = i
            while n % i == 0 {
                n /= i
            }
        }
    }
    return largest
}

// 2.10
// Write a function that takes a string as input and returns the string reversed.
// reverseString("hello") == "olleh"
func reverseString(s: String) -> String {
    var reversed = ""
    for i in s.reversed() {
        reversed += i
    }
    return reversed
}

// 2.11
// Write a function that takes an integer as input and returns the number of bits that are equal to one in the binary representation of that number.
// The returned value should be between 0 and 32 (inclusive).
// Example:
// countBits(5) == 2
// countBits(0) == 0
func countBits(n: Int) -> Int {
    var count = 0
    while n > 0 {
        if n & 1 == 1 {
            count += 1
        }
        n >>= 1
    }
    return count
}

// 2.12
// Write a function that takes an integer as input and returns the number of bits that are equal to one in the binary representation of that number, ignoring the leading zeros.
// Example:
// Example:
// countSetBits(0b00000000000000000000000000001011) == 3
// countSetBits(0b11111111111111111111111111111101) == 31
func countSetBits(n: Int) -> Int {
    var count = 0
    while n > 0 {
        count += n & 1
        n >>= 1
    }
    return count
}

// 2.13
// Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number,
// ignoring the leading zeros.
// Example:
// Example:
// countSetBits(0b00000000000000000000000000001011) == 3
// countSetBits(0b11111111111111111111111111111101) == 31
// countSetBits(0b00000000000000000000000010000000) == 1
func countSetBits(n: Int) -> Int {
    var count = 0
    while n > 0 {
        count += n & 1
        n >>= 1
    }
    return count
}

// 2.14
// Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number,
// ignoring the leading zeros.
// Example:
// Example:
// countSetBits(0b00000000000000000000000000001011) == 3
// countSetBits(0b11111111111111111111111111111101) == 31
// countSetBits(0b00000000000000000000000010000000) == 1
// countSetBits(0b00000000000000000000000000000000) == 0
func countSetBits(n: Int) -> Int {
    var count = 0
    while n > 0 {
        count += n & 1
        n >>= 1
    }
    return count
}

// 2.15
// Write a function that takes an
n /= i // left side of mutating operator isn't mutable: 'n' is a 'let' constant
reversed += i // cannot convert value of type 'String.Element' (aka 'Character') to expected argument type 'String'
n >>= 1 // left side of mutating operator isn't mutable: 'n' is a 'let' constant
n >>= 1 // left side of mutating operator isn't mutable: 'n' is a 'let' constant

func largestPrimeFactor(n: Int) -> Int {
    var largestPrimeFactor = 1
    var i = 2
    while i * i <= n {
        if n % i == 0 {
            largestPrimeFactor = i
            n /= i
        } else {
            i += 1
        }
    }
    return largestPrimeFactor
}
```swift
// Return the largest prime factor of n. Assume n > 1 and is not a prime.
// largestPrimeFactor(n: 13195) == 29
// largestPrimeFactor(n: 2048) == 2
func largestPrimeFactor(n: Int) -> Int {
    var largestPrimeFactor = 1
    var i = 2
    while i * i <= n {
        if n % i == 0 {
            largestPrimeFactor = i
            n /= i
        } else {
            i += 1
        }
    }
    return largestPrimeFactor
}

// 2. 소수 판별
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함수
// 소수 판별 함
n /= i // left side of mutating operator isn't mutable: 'n' is a 'let' constant

func largestPrimeFactor(n: Int) -> Int {
    var largest = 1
    var i = 2
    while i * i <= n {
        if n % i == 0 {
            largest = i
            n /= i
        } else {
            i += 1
        }
    }
    return largest
}
```swift
// Return the largest prime factor of n. Assume n > 1 and is not a prime.
// largestPrimeFactor(n: 13195) == 29
// largestPrimeFactor(n: 2048) == 2
func largestPrimeFactor(n: Int) -> Int {
    var largest = 1
    var i = 2
    while i * i <= n {
        if n % i == 0 {
            largest = i
            n /= i
        } else {
            i += 1
        }
    }
    return largest
}

// -----------------------------------------------------------------------------
// 10. Write a function that takes a string and returns the number of consonants
//     in the string.
//     A consonant is a letter that is not a, e, i, o, u, or y.
//     For example, countConsonants("This is a test") == 4
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 11. Write a function that takes a string and returns the number of vowels
//     in the string.
//     A vowel is an a, e, i, o, u, or y.
//     For example, countVowels("This is a test") == 4
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 12. Write a function that takes a string and returns the number of words in
//     the string.
//     A word is a sequence of non-space characters.
//     For example, countWords("This is a test") == 3
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 13. Write a function that takes a string and returns the number of uppercase
//     letters in the string.
//     For example, countUppercase("This is a test") == 2
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 14. Write a function that takes a string and returns the number of lowercase
//     letters in the string.
//     For example, countLowercase("This is a test") == 5
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 15. Write a function that takes a string and returns the number of digits in
//     the string.
//     For example, countDigits("This is a test") == 0
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 16. Write a function that takes a string and returns the number of words that
//     contain the letter "e".
//     For example, countEWords("This is a test") == 1
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 17. Write a function that takes a string and returns the number of words that
//     contain the letter "t".
//     For example, countTWords("This is a test") == 2
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 18. Write a
n /= i // left side of mutating operator isn't mutable: 'n' is a 'let' constant

func largestPrimeFactor(n: Int) -> Int {
    var largest = 1
    for i in 2...n {
        if n % i == 0 {
            largest = i
            while n % i == 0 {
                n /= i
            }
        }
    }
    return largest
}
```swift
// Return the largest prime factor of n. Assume n > 1 and is not a prime.
// largestPrimeFactor(n: 13195) == 29
// largestPrimeFactor(n: 2048) == 2
func largestPrimeFactor(n: Int) -> Int {
    var largest = 1
    for i in 2...n {
        if n % i == 0 {
            largest = i
            while n % i == 0 {
                n /= i
            }
        }
    }
    return largest
}

// 2.1
// 2.2
// 2.3
// 2.4
// 2.5
// 2.6
// 2.7
// 2.8
// 2.9
// 2.10
// 2.11
// 2.12
// 2.13
// 2.14
// 2.15
// 2.16
// 2.17
// 2.18
// 2.19
// 2.20
// 2.21
// 2.22
// 2.23
// 2.24
// 2.25
// 2.26
// 2.27
// 2.28
// 2.29
// 2.30
// 2.31
// 2.32
// 2.33
// 2.34
// 2.35
// 2.36
// 2.37
// 2.38
// 2.39
// 2.40
// 2.41
// 2.42
// 2.43
// 2.44
// 2.45
// 2.46
// 2.47
// 2.48
// 2.49
// 2.50
// 2.51
// 2.52
// 2.53
// 2.54
// 2.55
// 2.56
// 2.57
// 2.58
// 2.59
// 2.60
// 2.61
// 2.62
// 2.63
// 2.64
// 2.65
// 2.66
// 2.67
// 2.68
// 2.69
// 2.70
// 2.71
// 2.72
// 2.73
// 2.74
// 2.75
// 2.76
// 2.77
// 2.78
// 2.79
// 2.80
// 2.81
// 2.82
// 2.83
// 2.84
// 2.85
// 2.86
// 2.87
// 2.88
// 2.89
// 2.90
// 2.91
// 2.92
// 2.93
// 2.94
// 2.95
// 2.96
// 2.97
// 2.98
// 2.99
// 3.00
// 3.01
// 3.02
// 3.03
// 3.04
// 3.05
// 3.06
// 3.07
// 3.08
// 3.09
// 3.10
// 3.11
// 3.12
// 3.13
// 3.14
// 3.15
// 3.16
// 3.17
// 3.18
// 3.19
// 3.20
// 3.21
// 3.22
// 3.23
// 3.24
// 3.25
// 3.26
// 3.27
// 3.28
// 3.29
// 3.30
// 3.31
// 3.32
// 3.33
// 3.34
// 3.35
// 3.36
// 3.37
// 3.38
n /= i // left side of mutating operator isn't mutable: 'n' is a 'let' constant

func largestPrimeFactor(n: Int) -> Int {
    var largest = 1
    var i = 2
    while i * i <= n {
        if n % i == 0 {
            largest = i
            n /= i
        } else {
            i += 1
        }
    }
    return largest
}

func reverseString(s: String) -> String {
    return String(s.reversed())
}

func factorial5(n: Int) -> Int {
    var count = 0
    var i = 5
    while i <= n {
        count += n / i
        i *= 5
    }
    return count
}

func squareDigits(n: Int) -> Int {
    var s = String(n)
    var i = 0
    while i < s.count {
        s[i] = String(Int(s[i]!) * Int(s[i]!))[0]
        i += 1
    }
    return Int(s)
}

func palindrome(s: String) -> Bool {
    return s == String(s.reversed())
}

func vowelCount(s: String) -> Int {
    var count = 0
    var i = 0
    while i < s.count {
        if s[i] == "a" || s[i] == "e" || s[i] == "i" || s[i] == "o" || s[i] == "u" {
            count += 1
        }
        i += 1
    }
    return count
}

func letterCount(s: String) -> [String: Int] {
    var dict = [String: Int]()
    var i = 0
    while i < s.count {
        if dict[s[i]] == nil {
            dict[s[i]] = 1
        } else {
            dict[s[i]]! += 1
        }
        i += 1
    }
    return dict
}

func letterCounts(s: String) -> [String: Int] {
    var dict = [String: Int]()
    var i = 0
    while i < s.count {
        if dict[s[i]] == nil {
            dict[s[i]] = 1
        } else {
            dict[s[i]]! += 1
        }
        i += 1
    }
    return dict
}
```swift
// Return the largest prime factor of n. Assume n > 1 and is not a prime.
// largestPrimeFactor(n: 13195) == 29
// largestPrimeFactor(n: 2048) == 2
func largestPrimeFactor(n: Int) -> Int {
    var largest = 1
    var i = 2
    while i * i <= n {
        if n % i == 0 {
            largest = i
            n /= i
        } else {
            i += 1
        }
    }
    return largest
}

// 10. Write a function that takes a string as input and returns the string reversed.
// reverseString("hello") == "olleh"
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// 11. Write a function that takes an integer and returns the number of 5s that appear in its factorial.
// factorial5(5) == 1
// factorial5(10) == 2
// factorial5(20) == 4
func factorial5(n: Int) -> Int {
    var count = 0
    var i = 5
    while i <= n {
        count += n / i
        i *= 5
    }
    return count
}

// 12. Write a function that takes an integer and returns the number of digits in its square.
// squareDigits(9119) == 811181
func squareDigits(n: Int) -> Int {
    var s = String(n)
    var i = 0
    while i < s.count {
        s[i] = String(Int(s[i]!) * Int(s[i]!))[0]
        i += 1
    }
    return Int(s)
}

// 13. Write a function that takes a string and returns true if the string is a palindrome, and false otherwise.
// palindrome("radar") == true
// palindrome("hello") == false
func palindrome(s: String) -> Bool {
    return s == String(s.reversed())
}

// 14. Write a function that takes a string and returns the number of vowels in the string.
// vowelCount("apple") == 2
// vowelCount("hello") == 1
func vowelCount(s: String) -> Int {
    var count = 0
    var i = 0
    while i < s.count {
        if s[i] == "a" || s[i] == "e" || s[i] == "i" || s[i] == "o" || s[i] == "u" {
            count += 1
        }
        i += 1
    }
    return count
}

// 15. Write a function that takes a string and returns the number of times a letter appears in the string.
// letterCount("apple") == {"a": 2, "p": 2, "l": 1, "e": 1}
// letterCount("hello") == {"h": 1, "e": 1, "l": 2, "o": 1}
func letterCount(s: String) -> [String: Int] {
    var dict = [String: Int]()
    var i = 0
    while i < s.count {
        if dict[s[i]] == nil {
            dict[s[i]] = 1
        } else {
            dict[s[i]]! += 1
        }
        i += 1
    }
    return dict
}

// 16. Write a function that takes a string and returns the number of times each letter appears in the string.
// letterCounts("apple") == {"a": 2, "p": 2, "l": 1, "e": 1}
// letterCounts("hello") == {"h": 1, "e": 1, "l": 2, "o": 1}
func letterCounts(s: String) -> [String: Int] {
    var dict = [String: Int]()
    var i = 0
    while i < s.count {
        if dict[s[i]] == nil {
            dict[s[i]] = 1
        } else {
            dict[s[i]]! += 1
        }
        i += 1
    }
    return dict
}

// 17

func sumToN(n: Int) -> Int {
    if n == 1 {
        return 1
    } else {
        return n + sumToN(n - 1)
    }
}
```swift
// sum_to_n is a function that sums numbers from 1 to n.
// sumToN(n: 30) == 465
// sumToN(n: 100) == 5050
// sumToN(n: 5) == 15
// sumToN(n: 10) == 55
// sumToN(n: 1) == 1
func sumToN(n: Int) -> Int {
    if n == 1 {
        return 1
    } else {
        return n + sumToN(n - 1)
    }
}

// 1. Write a function that takes a string and returns the number of vowels in the string.
// 2. Write a function that takes a string and returns the number of consonants in the string.
// 3. Write a function that takes a string and returns the number of words in the string.
// 4. Write a function that takes a string and returns the number of sentences in the string.
// 5. Write a function that takes a string and returns the number of uppercase letters in the string.
// 6. Write a function that takes a string and returns the number of lowercase letters in the string.
// 7. Write a function that takes a string and returns the number of digits in the string.
// 8. Write a function that takes a string and returns the number of whitespace characters in the string.
// 9. Write a function that takes a string and returns the number of words that start with a vowel in the string.
// 10. Write a function that takes a string and returns the number of words that end with a consonant in the string.
// 11. Write a function that takes a string and returns the number of words that start with a vowel or end with a consonant in the string.
// 12. Write a function that takes a string and returns the number of words that start with a vowel or end with a consonant in the string.
// 13. Write a function that takes a string and returns the number of words that start with a vowel or end with a consonant in the string.
// 14. Write a function that takes a string and returns the number of words that start with a vowel or end with a consonant in the string.
// 15. Write a function that takes a string and returns the number of words that start with a vowel or end with a consonant in the string.
// 16. Write a function that takes a string and returns the number of words that start with a vowel or end with a consonant in the string.
// 17. Write a function that takes a string and returns the number of words that start with a vowel or end with a consonant in the string.
// 18. Write a function that takes a string and returns the number of words that start with a vowel or end with a consonant in the string.
// 19. Write a function that takes a string and returns the number of words that start with a vowel or end with a consonant in the string.
// 20. Write a function that takes a string and returns the number of words that start with a vowel or end with a consonant in the string.
// 21. Write a function that takes a string and returns the number of words that start with a vowel or end with a consonant in the string.
// 22. Write a function that takes a string and returns the number of words that start with a vowel or end with a consonant in the string.
// 23. Write a function that takes a string and returns the number of words that start with a vowel or end with a consonant in the string.
// 24. Write a function that takes a string and returns the number of words that start with a vowel or end with a consonant in the string.
// 25. Write a function that takes a string and returns the number of words that start with a vowel or end with a consonant in the string.
// 26. Write a function that takes a string and returns the number of words that start with a vowel or end with a consonant in the string.
// 27. Write a function that takes a string and returns the number of words that start with a vowel or end with a consonant in the string.
// 28. Write a function that takes a string and returns the number of words that start with a vowel or end with a consonant in the string.
// 29. Write a function that takes a string and returns the number of words that start with a vowel or end with a consonant in the string.
// 30. Write a function that takes a string and returns the number of words that start with a vowel or end with a consonant in the string.
// 31. Write a function that takes a string and returns the number of words that start with a
return n + sumToN(n - 1) // missing argument label 'n:' in call

func sumToN(n: Int) -> Int {
    if n == 1 {
        return 1
    }
    return n + sumToN(n - 1)
}
```swift
// sum_to_n is a function that sums numbers from 1 to n.
// sumToN(n: 30) == 465
// sumToN(n: 100) == 5050
// sumToN(n: 5) == 15
// sumToN(n: 10) == 55
// sumToN(n: 1) == 1
func sumToN(n: Int) -> Int {
    if n == 1 {
        return 1
    }
    return n + sumToN(n - 1)
}

// 2. Write a function that takes a string and returns the number of vowels in the string.
// vowelCount is a function that counts the number of vowels in a string.
// vowelCount("hello") == 2
// vowelCount("apple") == 2
// vowelCount("banana") == 3
// vowelCount("orange") == 2
// vowelCount("grape") == 1
// vowelCount("watermelon") == 3
// vowelCount("kiwi") == 1
// vowelCount("strawberry") == 4
// vowelCount("blueberry") == 4
// vowelCount("melon") == 2
// vowelCount("peach") == 2
// vowelCount("cherry") == 2
// vowelCount("pear") == 1
// vowelCount("plum") == 2
// vowelCount("pineapple") == 5
// vowelCount("melon") == 2
// vowelCount("peach") == 2
// vowelCount("cherry") == 2
// vowelCount("pear") == 1
// vowelCount("plum") == 2
// vowelCount("pineapple") == 5
// vowelCount("melon") == 2
// vowelCount("peach") == 2
// vowelCount("cherry") == 2
// vowelCount("pear") == 1
// vowelCount("plum") == 2
// vowelCount("pineapple") == 5
// vowelCount("melon") == 2
// vowelCount("peach") == 2
// vowelCount("cherry") == 2
// vowelCount("pear") == 1
// vowelCount("plum") == 2
// vowelCount("pineapple") == 5
// vowelCount("melon") == 2
// vowelCount("peach") == 2
// vowelCount("cherry") == 2
// vowelCount("pear") == 1
// vowelCount("plum") == 2
// vowelCount("pineapple") == 5
// vowelCount("melon") == 2
// vowelCount("peach") == 2
// vowelCount("cherry") == 2
// vowelCount("pear") == 1
// vowelCount("plum") == 2
// vowelCount("pineapple") == 5
// vowelCount("melon") == 2
// vowelCount("peach") == 2
// vowelCount("cherry") == 2
// vowelCount("pear") == 1
// vowelCount("plum") == 2
// vowelCount("pineapple") == 5
// vowelCount("melon") == 2
// vowelCount("peach") == 2
// vowelCount("cherry") == 2
// vowelCount("pear") == 1
// vowelCount("plum") == 2
// vowelCount("pineapple") == 5
// vowelCount("melon") == 2
// vowelCount("peach") == 2
// vowelCount("cherry") == 2
// vowelCount("pear") == 1
// vowelCount("plum") == 2
// vowelCount("pineapple") == 5
// vowelCount("melon") == 2
// vowelCount("peach") == 2
// vowelCount("cherry") == 2
// vowelCount("pear") == 1
// vowelCount("plum") ==
return n + sumToN(n - 1) // missing argument label 'n:' in call

func sumToN(n: Int) -> Int {
    if n == 1 {
        return 1
    } else {
        return n + sumToN(n: n - 1)
    }
}
```swift
// sum_to_n is a function that sums numbers from 1 to n.
// sumToN(n: 30) == 465
// sumToN(n: 100) == 5050
// sumToN(n: 5) == 15
// sumToN(n: 10) == 55
// sumToN(n: 1) == 1
func sumToN(n: Int) -> Int {
    if n == 1 {
        return 1
    } else {
        return n + sumToN(n: n - 1)
    }
}

// 1. Write a function that takes a string and returns the number of vowels in the string.
// 2. Write a function that takes a string and returns the number of consonants in the string.
// 3. Write a function that takes a string and returns the number of words in the string.
// 4. Write a function that takes a string and returns the number of sentences in the string.
// 5. Write a function that takes a string and returns the number of uppercase letters in the string.
// 6. Write a function that takes a string and returns the number of lowercase letters in the string.
// 7. Write a function that takes a string and returns the number of digits in the string.
// 8. Write a function that takes a string and returns the number of whitespace characters in the string.
// 9. Write a function that takes a string and returns the number of non-whitespace characters in the string.
// 10. Write a function that takes a string and returns the number of words in the string.
// 11. Write a function that takes a string and returns the number of sentences in the string.
// 12. Write a function that takes a string and returns the number of uppercase letters in the string.
// 13. Write a function that takes a string and returns the number of lowercase letters in the string.
// 14. Write a function that takes a string and returns the number of digits in the string.
// 15. Write a function that takes a string and returns the number of whitespace characters in the string.
// 16. Write a function that takes a string and returns the number of non-whitespace characters in the string.
// 17. Write a function that takes a string and returns the number of words in the string.
// 18. Write a function that takes a string and returns the number of sentences in the string.
// 19. Write a function that takes a string and returns the number of uppercase letters in the string.
// 20. Write a function that takes a string and returns the number of lowercase letters in the string.
// 21. Write a function that takes a string and returns the number of digits in the string.
// 22. Write a function that takes a string and returns the number of whitespace characters in the string.
// 23. Write a function that takes a string and returns the number of non-whitespace characters in the string.
// 24. Write a function that takes a string and returns the number of words in the string.
// 25. Write a function that takes a string and returns the number of sentences in the string.
// 26. Write a function that takes a string and returns the number of uppercase letters in the string.
// 27. Write a function that takes a string and returns the number of lowercase letters in the string.
// 28. Write a function that takes a string and returns the number of digits in the string.
// 29. Write a function that takes a string and returns the number of whitespace characters in the string.
// 30. Write a function that takes a string and returns the number of non-whitespace characters in the string.
// 31. Write a function that takes a string and returns the number of words in the string.
// 32. Write a function that takes a string and returns the number of sentences in the string.
// 33. Write a function that takes a string and returns the number of uppercase letters in the string.
// 34. Write a function that takes a string and returns the number of lowercase letters in the string.
// 35. Write a function that takes a string and returns the number of digits in the string.
// 36. Write a function that takes a string and returns the number of whitespace characters in the string.
// 37. Write a function that takes a string and returns the number of non-whitespace characters in the string.
// 38. Write a function that takes a string and returns the number of words in the string.
// 39. Write a function that takes a string and returns the number of sentences in the string.
// 40. Write a function that takes a string and returns the number of uppercase letters in the string.
// 41. Write a function that takes a string

func sumToN(n: Int) -> Int {
    if n == 1 {
        return 1
    }
    return n + sumToN(n - 1)
}

func countVowels(string: String) -> Int {
    var count = 0
    for char in string {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}

func countWords(string: String) -> Int {
    var count = 0
    for char in string {
        if char == " " {
            count += 1
        }
    }
    return count + 1
}

func countConsonants(string: String) -> Int {
    var count = 0
    for char in string {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" && char != " " {
            count += 1
        }
    }
    return count
}

func countUppercase(string: String) -> Int {
    var count = 0
    for char in string {
        if char == char.uppercase {
            count += 1
        }
    }
    return count
}

func countLowercase(string: String) -> Int {
    var count = 0
    for char in string {
        if char == char.lowercase {
            count += 1
        }
    }
    return count
}

func countDigits(string: String) -> Int {
    var count = 0
    for char in string {
        if char.isDigit {
            count += 1
        }
    }
    return count
}
```swift
// sum_to_n is a function that sums numbers from 1 to n.
// sumToN(n: 30) == 465
// sumToN(n: 100) == 5050
// sumToN(n: 5) == 15
// sumToN(n: 10) == 55
// sumToN(n: 1) == 1
func sumToN(n: Int) -> Int {
    if n == 1 {
        return 1
    }
    return n + sumToN(n - 1)
}

// 2. Write a function that takes a string as input and returns the number of vowels in the string.
// countVowels("Hello world") == 3
// countVowels("apple") == 2
// countVowels("a") == 1
// countVowels("") == 0
func countVowels(string: String) -> Int {
    var count = 0
    for char in string {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}

// 3. Write a function that takes a string as input and returns the number of words in the string.
// countWords("Hello world") == 2
// countWords("apple") == 1
// countWords("a") == 1
// countWords("") == 0
func countWords(string: String) -> Int {
    var count = 0
    for char in string {
        if char == " " {
            count += 1
        }
    }
    return count + 1
}

// 4. Write a function that takes a string as input and returns the number of consonants in the string.
// countConsonants("Hello world") == 7
// countConsonants("apple") == 4
// countConsonants("a") == 0
// countConsonants("") == 0
func countConsonants(string: String) -> Int {
    var count = 0
    for char in string {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" && char != " " {
            count += 1
        }
    }
    return count
}

// 5. Write a function that takes a string as input and returns the number of uppercase letters in the string.
// countUppercase("Hello world") == 2
// countUppercase("apple") == 1
// countUppercase("a") == 0
// countUppercase("") == 0
func countUppercase(string: String) -> Int {
    var count = 0
    for char in string {
        if char == char.uppercase {
            count += 1
        }
    }
    return count
}

// 6. Write a function that takes a string as input and returns the number of lowercase letters in the string.
// countLowercase("Hello world") == 5
// countLowercase("apple") == 4
// countLowercase("a") == 1
// countLowercase("") == 0
func countLowercase(string: String) -> Int {
    var count = 0
    for char in string {
        if char == char.lowercase {
            count += 1
        }
    }
    return count
}

// 7. Write a function that takes a string as input and returns the number of digits in the string.
// countDigits("Hello world") == 0
// countDigits("apple") == 1
// countDigits("a") == 0
// countDigits("") == 0
func countDigits(string: String) -> Int {
    var count = 0
    for char in string {
        if char.isDigit {
            count += 1
        }
    }
    return count
}

// 8. Write a function that takes a string as input and returns the number of words that start with a vowel.
// countWordsStartingWithVowel("Hello world") == 1
// countWordsStartingWithVowel("apple") == 1
// countWordsStartingWithVowel("a") == 1
// countWordsStartingWithVowel("") == 0
func countWordsStartingWithVowel(string: String
return n + sumToN(n - 1) // missing argument label 'n:' in call
if char == char.uppercase { // value of type 'Character' has no member 'uppercase'
if char == char.lowercase { // value of type 'Character' has no member 'lowercase'
if char.isDigit { // value of type 'Character' has no member 'isDigit'

func sumToN(n: Int) -> Int {
    if n == 1 {
        return 1
    }
    return n + sumToN(n: n - 1)
}
```swift
// sum_to_n is a function that sums numbers from 1 to n.
// sumToN(n: 30) == 465
// sumToN(n: 100) == 5050
// sumToN(n: 5) == 15
// sumToN(n: 10) == 55
// sumToN(n: 1) == 1
func sumToN(n: Int) -> Int {
    if n == 1 {
        return 1
    }
    return n + sumToN(n: n - 1)
}

// 1. Write a function that takes a string and returns the number of vowels in the string.
// 2. Write a function that takes a string and returns the number of consonants in the string.
// 3. Write a function that takes a string and returns the number of words in the string.
// 4. Write a function that takes a string and returns the number of sentences in the string.
// 5. Write a function that takes a string and returns the number of uppercase letters in the string.
// 6. Write a function that takes a string and returns the number of lowercase letters in the string.
// 7. Write a function that takes a string and returns the number of digits in the string.
// 8. Write a function that takes a string and returns the number of whitespace characters in the string.
// 9. Write a function that takes a string and returns the number of non-whitespace characters in the string.
// 10. Write a function that takes a string and returns the number of characters in the string.
// 11. Write a function that takes a string and returns the number of words in the string.
// 12. Write a function that takes a string and returns the number of sentences in the string.
// 13. Write a function that takes a string and returns the number of uppercase letters in the string.
// 14. Write a function that takes a string and returns the number of lowercase letters in the string.
// 15. Write a function that takes a string and returns the number of digits in the string.
// 16. Write a function that takes a string and returns the number of whitespace characters in the string.
// 17. Write a function that takes a string and returns the number of non-whitespace characters in the string.
// 18. Write a function that takes a string and returns the number of characters in the string.
// 19. Write a function that takes a string and returns the number of words in the string.
// 20. Write a function that takes a string and returns the number of sentences in the string.
// 21. Write a function that takes a string and returns the number of uppercase letters in the string.
// 22. Write a function that takes a string and returns the number of lowercase letters in the string.
// 23. Write a function that takes a string and returns the number of digits in the string.
// 24. Write a function that takes a string and returns the number of whitespace characters in the string.
// 25. Write a function that takes a string and returns the number of non-whitespace characters in the string.
// 26. Write a function that takes a string and returns the number of characters in the string.
// 27. Write a function that takes a string and returns the number of words in the string.
// 28. Write a function that takes a string and returns the number of sentences in the string.
// 29. Write a function that takes a string and returns the number of uppercase letters in the string.
// 30. Write a function that takes a string and returns the number of lowercase letters in the string.
// 31. Write a function that takes a string and returns the number of digits in the string.
// 32. Write a function that takes a string and returns the number of whitespace characters in the string.
// 33. Write a function that takes a string and returns the number of non-whitespace characters in the string.
// 34. Write a function that takes a string and returns the number of characters in the string.
// 35. Write a function that takes a string and returns the number of words in the string.
// 36. Write a function that takes a string and returns the number of sentences in the string.
// 37. Write a function that takes a string and returns the number of uppercase letters in the string.
// 38. Write a function that takes a string and returns the number of lowercase letters in the string.
// 39. Write a function that takes a string and returns the number of digits in the string.
// 40. Write a function that takes a string and returns the number of whitespace characters in the string.
// 41. Write a function that takes a string and returns the number of non-whitespace characters in

func sumToN(n: Int) -> Int {
    var sum = 0
    for i in 1...n {
        sum += i
    }
    return sum
}
```swift
// sum_to_n is a function that sums numbers from 1 to n.
// sumToN(n: 30) == 465
// sumToN(n: 100) == 5050
// sumToN(n: 5) == 15
// sumToN(n: 10) == 55
// sumToN(n: 1) == 1
func sumToN(n: Int) -> Int {
    var sum = 0
    for i in 1...n {
        sum += i
    }
    return sum
}

// 2. Write a function that takes a string and returns the number of vowels in the string.
// vowelCount is a function that counts the number of vowels in a string.
// vowelCount("hello") == 2
// vowelCount("apple") == 2
// vowelCount("banana") == 3
// vowelCount("orange") == 4
// vowelCount("grape") == 2
// vowelCount("watermelon") == 5
// vowelCount("kiwi") == 2
// vowelCount("strawberry") == 5
// vowelCount("blueberry") == 5
// vowelCount("peach") == 2
// vowelCount("cherry") == 3
// vowelCount("mango") == 3
// vowelCount("pear") == 2
// vowelCount("melon") == 3
// vowelCount("pineapple") == 5
// vowelCount("cranberry") == 5
// vowelCount("raspberry") == 5
// vowelCount("lemon") == 2
// vowelCount("kiwi") == 2
// vowelCount("strawberry") == 5
// vowelCount("blueberry") == 5
// vowelCount("peach") == 2
// vowelCount("cherry") == 3
// vowelCount("mango") == 3
// vowelCount("pear") == 2
// vowelCount("melon") == 3
// vowelCount("pineapple") == 5
// vowelCount("cranberry") == 5
// vowelCount("raspberry") == 5
// vowelCount("lemon") == 2
// vowelCount("kiwi") == 2
// vowelCount("strawberry") == 5
// vowelCount("blueberry") == 5
// vowelCount("peach") == 2
// vowelCount("cherry") == 3
// vowelCount("mango") == 3
// vowelCount("pear") == 2
// vowelCount("melon") == 3
// vowelCount("pineapple") == 5
// vowelCount("cranberry") == 5
// vowelCount("raspberry") == 5
// vowelCount("lemon") == 2
// vowelCount("kiwi") == 2
// vowelCount("strawberry") == 5
// vowelCount("blueberry") == 5
// vowelCount("peach") == 2
// vowelCount("cherry") == 3
// vowelCount("mango") == 3
// vowelCount("pear") == 2
// vowelCount("melon") == 3
// vowelCount("pineapple") == 5
// vowelCount("cranberry") == 5
// vowelCount("raspberry") == 5
// vowelCount("lemon") == 2
// vowelCount("kiwi") == 2
// vowelCount("strawberry") == 5
// vowelCount("blueberry") == 5
// vowelCount("peach") == 2
// vowelCount("cherry") == 3
// vowelCount("mango") == 3
// vowelCount("pear") == 2
// vowelCount("melon") == 3
// vowelCount("pineapple") == 5
// vowelCount("cranberry") == 5
// vowelCount("raspberry") == 5
// vowelCount("lemon") == 2
// vowelCount("kiwi") == 2
//

func sumToN(n: Int) -> Int {
    if n == 1 {
        return 1
    } else {
        return n + sumToN(n: n - 1)
    }
}
```swift
// sum_to_n is a function that sums numbers from 1 to n.
// sumToN(n: 30) == 465
// sumToN(n: 100) == 5050
// sumToN(n: 5) == 15
// sumToN(n: 10) == 55
// sumToN(n: 1) == 1
func sumToN(n: Int) -> Int {
    if n == 1 {
        return 1
    } else {
        return n + sumToN(n: n - 1)
    }
}

// 2. Write a function that takes a string and returns a string with the first letter capitalized.
// capitalize("hello") == "Hello"
// capitalize("cat") == "Cat"
// capitalize("") == ""
// capitalize("123") == "123"
// capitalize("12345") == "12345"
// capitalize("123456789") == "123456789"
// capitalize("1234567890") == "1234567890"
// capitalize("12345678901") == "12345678901"
// capitalize("123456789012") == "123456789012"
// capitalize("1234567890123") == "1234567890123"
// capitalize("12345678901234") == "12345678901234"
// capitalize("123456789012345") == "123456789012345"
// capitalize("1234567890123456") == "1234567890123456"
// capitalize("12345678901234567") == "12345678901234567"
// capitalize("123456789012345678") == "123456789012345678"
// capitalize("1234567890123456789") == "1234567890123456789"
// capitalize("12345678901234567890") == "12345678901234567890"
// capitalize("123456789012345678901") == "123456789012345678901"
// capitalize("1234567890123456789012" == "1234567890123456789012"
// capitalize("12345678901234567890123" == "12345678901234567890123"
// capitalize("123456789012345678901234" == "123456789012345678901234"
// capitalize("1234567890123456789012345" == "1234567890123456789012345"
// capitalize("12345678901234567890123456" == "12345678901234567890123456"
// capitalize("123456789012345678901234567" == "123456789012345678901234567"
// capitalize("123456789012345678

func sumToN(n: Int) -> Int {
    if n == 1 {
        return 1
    } else {
        return n + sumToN(n: n - 1)
    }
}

func factorial(n: Int) -> Int {
    if n == 0 {
        return 1
    } else {
        return n * factorial(n: n - 1)
    }
}

func sumOfNumbers(n: Int) -> Int {
    if n == 0 {
        return 0
    } else {
        return n + sumOfNumbers(n: n - 1)
    }
}

func sumOfEvenNumbers(n: Int) -> Int {
    if n == 0 {
        return 0
    } else {
        if n % 2 == 0 {
            return n + sumOfEvenNumbers(n: n - 1)
        } else {
            return sumOfEvenNumbers(n: n - 1)
        }
    }
}

func sumOfOddNumbers(n: Int) -> Int {
    if n == 0 {
        return 0
    } else {
        if n % 2 == 1 {
            return n + sumOfOddNumbers(n: n - 1)
        } else {
            return sumOfOddNumbers(n: n - 1)
        }
    }
}

func sumOfDivisibleNumbers(n: Int) -> Int {
    if n == 0 {
        return 0
    } else {
        if n % 3 == 0 || n % 5 == 0 {
            return n + sumOfDivisibleNumbers(n: n - 1)
        } else {
            return sumOfDivisibleNumbers(n: n - 1)
        }
    }
}
```swift
// sum_to_n is a function that sums numbers from 1 to n.
// sumToN(n: 30) == 465
// sumToN(n: 100) == 5050
// sumToN(n: 5) == 15
// sumToN(n: 10) == 55
// sumToN(n: 1) == 1
func sumToN(n: Int) -> Int {
    if n == 1 {
        return 1
    } else {
        return n + sumToN(n: n - 1)
    }
}

// 2. Write a function that takes a number as input and returns the factorial of that number.
// factorial(n: 5) == 120
// factorial(n: 10) == 3628800
// factorial(n: 1) == 1
// factorial(n: 0) == 1
func factorial(n: Int) -> Int {
    if n == 0 {
        return 1
    } else {
        return n * factorial(n: n - 1)
    }
}

// 3. Write a function that takes a number as input and returns the sum of all numbers from 1 to that number.
// sumOfNumbers(n: 5) == 15
// sumOfNumbers(n: 10) == 55
// sumOfNumbers(n: 1) == 1
// sumOfNumbers(n: 0) == 0
func sumOfNumbers(n: Int) -> Int {
    if n == 0 {
        return 0
    } else {
        return n + sumOfNumbers(n: n - 1)
    }
}

// 4. Write a function that takes a number as input and returns the sum of all even numbers from 1 to that number.
// sumOfEvenNumbers(n: 5) == 10
// sumOfEvenNumbers(n: 10) == 30
// sumOfEvenNumbers(n: 1) == 2
// sumOfEvenNumbers(n: 0) == 0
func sumOfEvenNumbers(n: Int) -> Int {
    if n == 0 {
        return 0
    } else {
        if n % 2 == 0 {
            return n + sumOfEvenNumbers(n: n - 1)
        } else {
            return sumOfEvenNumbers(n: n - 1)
        }
    }
}

// 5. Write a function that takes a number as input and returns the sum of all odd numbers from 1 to that number.
// sumOfOddNumbers(n: 5) == 9
// sumOfOddNumbers(n: 10) == 25
// sumOfOddNumbers(n: 1) == 1
// sumOfOddNumbers(n: 0) == 0
func sumOfOddNumbers(n: Int) -> Int {
    if n == 0 {
        return 0
    } else {
        if n % 2 == 1 {
            return n + sumOfOddNumbers(n: n - 1)
        } else {
            return sumOfOddNumbers(n: n - 1)
        }
    }
}

// 6. Write a function that takes a number as input and returns the sum of all numbers that are divisible by 3 or 5 from 1 to that number.
// sumOfDivisibleNumbers(n: 5) == 8
// sumOfDivisibleNumbers(n: 10) == 30
// sumOfDivisibleNumbers(n: 1) == 1
// sumOfDivisibleNumbers(n: 0) == 0
func sumOfDivisibleNumbers(n: Int) -> Int {
    if n == 0 {
        return 0
    } else {
        if n % 3 == 0 || n % 5 == 0 {
            return n + sumOfDivisibleNumbers(n: n - 1)
        } else {
            return sumOfDivisibleNumbers(n: n - 1)
        }
    }
}

// 7. Write a function that takes a number as input and returns the sum of all numbers that are divisible by 3 or 5 from 1 to that number.
// sumOfDivisibleNumbers(n: 5) == 8
// sumOfDivisibleNumbers(n: 10) == 30
// sumOfDivisibleNumbers(n: 1) == 1
// sumOfDivisibleNumbers(n: 0) == 0
func

func sumToN(n: Int) -> Int {
    if n == 1 {
        return 1
    }
    return n + sumToN(n: n - 1)
}

func vowelCount(string: String) -> Int {
    var count = 0
    for char in string {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}

func sumArray(numbers: [Int]) -> Int {
    var sum = 0
    for number in numbers {
        sum += number
    }
    return sum
}

func charCount(string: String, char: String) -> Int {
    var count = 0
    for char in string {
        if char == char {
            count += 1
        }
    }
    return count
}

func maxArray(numbers: [Int]) -> Int {
    var max = numbers[0]
    for number in numbers {
        if number > max {
            max = number
        }
    }
    return max
}

func minArray(numbers: [Int]) -> Int {
    var min = numbers[0]
    for number in numbers {
        if number < min {
            min = number
        }
    }
    return min
}
```swift
// sum_to_n is a function that sums numbers from 1 to n.
// sumToN(n: 30) == 465
// sumToN(n: 100) == 5050
// sumToN(n: 5) == 15
// sumToN(n: 10) == 55
// sumToN(n: 1) == 1
func sumToN(n: Int) -> Int {
    if n == 1 {
        return 1
    }
    return n + sumToN(n: n - 1)
}

// 2. Write a function that takes a string and returns the number of vowels in the string.
// vowelCount is a function that counts the number of vowels in a string.
// vowelCount("Hello") == 2
// vowelCount("apple") == 2
// vowelCount("a") == 1
// vowelCount("") == 0
func vowelCount(string: String) -> Int {
    var count = 0
    for char in string {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}

// 3. Write a function that takes an array of numbers and returns the sum of the numbers.
// sumArray is a function that sums the numbers in an array.
// sumArray([1, 2, 3, 4, 5]) == 15
// sumArray([10, 20, 30, 40, 50]) == 150
// sumArray([100, 200, 300, 400, 500]) == 1500
func sumArray(numbers: [Int]) -> Int {
    var sum = 0
    for number in numbers {
        sum += number
    }
    return sum
}

// 4. Write a function that takes a string and returns the number of times a specific character appears in the string.
// charCount is a function that counts the number of times a specific character appears in a string.
// charCount("Hello", "l") == 2
// charCount("apple", "p") == 2
// charCount("a", "a") == 1
// charCount("", "a") == 0
func charCount(string: String, char: String) -> Int {
    var count = 0
    for char in string {
        if char == char {
            count += 1
        }
    }
    return count
}

// 5. Write a function that takes an array of numbers and returns the maximum value in the array.
// maxArray is a function that finds the maximum value in an array of numbers.
// maxArray([1, 2, 3, 4, 5]) == 5
// maxArray([10, 20, 30, 40, 50]) == 50
// maxArray([100, 200, 300, 400, 500]) == 500
func maxArray(numbers: [Int]) -> Int {
    var max = numbers[0]
    for number in numbers {
        if number > max {
            max = number
        }
    }
    return max
}

// 6. Write a function that takes an array of numbers and returns the minimum value in the array.
// minArray is a function that finds the minimum value in an array of numbers.
// minArray([1, 2, 3, 4, 5]) == 1
// minArray([10, 20, 30, 40, 50]) == 10
// minArray([100, 200, 300, 400, 500]) == 100
func minArray(numbers: [Int]) -> Int {
    var min = numbers[0]
    for number in numbers {
        if number < min {
            min = number
        }
    }
    return min
}

// 7. Write a function that takes an array of numbers and returns the average value in the array.
// avgArray is a function that calculates the average value in an array of numbers.
// avgArray([1, 2, 3, 4, 5]) == 3
// avgArray([10, 20, 30, 40, 50]) == 25
// avgArray([100, 200, 300, 400, 500]) == 2

func sumToN(n: Int) -> Int {
    if n == 1 {
        return 1
    } else {
        return n + sumToN(n: n - 1)
    }
}
```swift
// sum_to_n is a function that sums numbers from 1 to n.
// sumToN(n: 30) == 465
// sumToN(n: 100) == 5050
// sumToN(n: 5) == 15
// sumToN(n: 10) == 55
// sumToN(n: 1) == 1
func sumToN(n: Int) -> Int {
    if n == 1 {
        return 1
    } else {
        return n + sumToN(n: n - 1)
    }
}

// 1. Write a function that takes a string and returns the number of vowels in the string.
// 2. Write a function that takes a string and returns the number of consonants in the string.
// 3. Write a function that takes a string and returns the number of words in the string.
// 4. Write a function that takes a string and returns the number of sentences in the string.
// 5. Write a function that takes a string and returns the number of uppercase letters in the string.
// 6. Write a function that takes a string and returns the number of lowercase letters in the string.
// 7. Write a function that takes a string and returns the number of digits in the string.
// 8. Write a function that takes a string and returns the number of whitespace characters in the string.
// 9. Write a function that takes a string and returns the number of characters in the string.
// 10. Write a function that takes a string and returns the number of words in the string.
// 11. Write a function that takes a string and returns the number of sentences in the string.
// 12. Write a function that takes a string and returns the number of uppercase letters in the string.
// 13. Write a function that takes a string and returns the number of lowercase letters in the string.
// 14. Write a function that takes a string and returns the number of digits in the string.
// 15. Write a function that takes a string and returns the number of whitespace characters in the string.
// 16. Write a function that takes a string and returns the number of characters in the string.
// 17. Write a function that takes a string and returns the number of words in the string.
// 18. Write a function that takes a string and returns the number of sentences in the string.
// 19. Write a function that takes a string and returns the number of uppercase letters in the string.
// 20. Write a function that takes a string and returns the number of lowercase letters in the string.
// 21. Write a function that takes a string and returns the number of digits in the string.
// 22. Write a function that takes a string and returns the number of whitespace characters in the string.
// 23. Write a function that takes a string and returns the number of characters in the string.
// 24. Write a function that takes a string and returns the number of words in the string.
// 25. Write a function that takes a string and returns the number of sentences in the string.
// 26. Write a function that takes a string and returns the number of uppercase letters in the string.
// 27. Write a function that takes a string and returns the number of lowercase letters in the string.
// 28. Write a function that takes a string and returns the number of digits in the string.
// 29. Write a function that takes a string and returns the number of whitespace characters in the string.
// 30. Write a function that takes a string and returns the number of characters in the string.
// 31. Write a function that takes a string and returns the number of words in the string.
// 32. Write a function that takes a string and returns the number of sentences in the string.
// 33. Write a function that takes a string and returns the number of uppercase letters in the string.
// 34. Write a function that takes a string and returns the number of lowercase letters in the string.
// 35. Write a function that takes a string and returns the number of digits in the string.
// 36. Write a function that takes a string and returns the number of whitespace characters in the string.
// 37. Write a function that takes a string and returns the number of characters in the string.
// 38. Write a function that takes a string and returns the number of words in the string.
// 39. Write a function that takes a string and returns the number of sentences in the string.
// 40. Write a function that takes a string and returns the number of uppercase letters in the string.
// 41. Write a function that takes a string and returns the number of lowercase letters in the string.
// 42. Write a function that takes a string

func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "(" {
            stack.append(bracket)
        } else {
            if stack.isEmpty {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty
}
```swift
// brackets is a string of "(" and ")".
// return true if every opening bracket has a corresponding closing bracket.
// correctBracketing(brackets: "(") == false
// correctBracketing(brackets: "()") == true
// correctBracketing(brackets: "(()())") == true
// correctBracketing(brackets: ")(()") == false
func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "(" {
            stack.append(bracket)
        } else {
            if stack.isEmpty {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// ------------------------------------
stack.pop() // value of type '[Character]' has no member 'pop'

func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "(" {
            stack.append(bracket)
        } else {
            if stack.isEmpty {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty
}

func repeatedLetters(text: String) -> String {
    var words = text.split(separator: " ")
    var repeatedLetters = [String]()
    var repeatedLettersCount = [Int]()
    for word in words {
        var repeatedLettersCountForWord = 0
        var repeatedLettersForWord = [Character]()
        for letter in word {
            if repeatedLettersForWord.contains(letter) {
                repeatedLettersCountForWord += 1
            } else {
                repeatedLettersForWord.append(letter)
            }
        }
        repeatedLetters.append(word)
        repeatedLettersCount.append(repeatedLettersCountForWord)
    }
    var maxRepeatedLettersCount = repeatedLettersCount[0]
    var indexOfMaxRepeatedLettersCount = 0
    for i in 1..<repeatedLettersCount.count {
        if repeatedLettersCount[i] > maxRepeatedLettersCount {
            maxRepeatedLettersCount = repeatedLettersCount[i]
            indexOfMaxRepeatedLettersCount = i
        }
    }
    return repeatedLetters[indexOfMaxRepeatedLettersCount]
}
```swift
// brackets is a string of "(" and ")".
// return true if every opening bracket has a corresponding closing bracket.
// correctBracketing(brackets: "(") == false
// correctBracketing(brackets: "()") == true
// correctBracketing(brackets: "(()())") == true
// correctBracketing(brackets: ")(()") == false
func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "(" {
            stack.append(bracket)
        } else {
            if stack.isEmpty {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty
}

// 2.
// Given a string of text, return the first word with the greatest number of repeated letters.
// If there are multiple words that have the greatest number of repeated letters, return the first one.
// repeatedLetters("hello world") == "hello"
// repeatedLetters("a a a a b b b b") == "b"
// repeatedLetters("a a a a b b b b c c c c") == "c"
func repeatedLetters(text: String) -> String {
    var words = text.split(separator: " ")
    var repeatedLetters = [String]()
    var repeatedLettersCount = [Int]()
    for word in words {
        var repeatedLettersCountForWord = 0
        var repeatedLettersForWord = [Character]()
        for letter in word {
            if repeatedLettersForWord.contains(letter) {
                repeatedLettersCountForWord += 1
            } else {
                repeatedLettersForWord.append(letter)
            }
        }
        repeatedLetters.append(word)
        repeatedLettersCount.append(repeatedLettersCountForWord)
    }
    var maxRepeatedLettersCount = repeatedLettersCount[0]
    var indexOfMaxRepeatedLettersCount = 0
    for i in 1..<repeatedLettersCount.count {
        if repeatedLettersCount[i] > maxRepeatedLettersCount {
            maxRepeatedLettersCount = repeatedLettersCount[i]
            indexOfMaxRepeatedLettersCount = i
        }
    }
    return repeatedLetters[indexOfMaxRepeatedLettersCount]
}

// 3.
// Given a string of text, return the first word with the greatest number of repeated letters.
// If there are multiple words that have the greatest number of repeated letters, return the first one.
// repeatedLetters("hello world") == "hello"
// repeatedLetters("a a a a b b b b") == "b"
// repeatedLetters("a a a a b b b b c c c c") == "c"
func repeatedLetters(text: String) -> String {
    var words = text.split(separator: " ")
    var repeatedLetters = [String]()
    var repeatedLettersCount = [Int]()
    for word in words {
        var repeatedLettersCountForWord = 0
        var repeatedLettersForWord = [Character]()
        for letter in word {
            if repeatedLettersForWord.contains(letter) {
                repeatedLettersCountForWord += 1
            } else {
                repeatedLettersForWord.append(letter)
            }
        }
        repeatedLetters.append(word)
        repeatedLettersCount.append(repeatedLettersCountForWord)
    }
    var maxRepeatedLettersCount = repeatedLettersCount[0]
    var indexOfMaxRepeatedLettersCount = 0
    for i in 1..<repeatedLettersCount.count {
        if repeatedLettersCount[i] > maxRepeatedLettersCount {
            maxRepeatedLettersCount = repeatedLettersCount[i]
            indexOfMaxRepeatedLettersCount = i
        }
    }
    return repeatedLetters[indexOfMaxRepeatedLettersCount]
}

// 4.
// Given a string of text, return the first word with the greatest number of repeated letters.
// If there are multiple words that have the greatest number of repeated letters, return the first one.
// repeatedLetters("hello world") == "hello"
// repeatedLetters("a a a a b b b b") == "b"
// repeatedLetters("a a a a b b b b c c c c") == "c"
func repeatedLetters(text: String) -> String {
    var words = text.split(separator: " ")
    var repeatedLetters = [String]()
    var repeatedLettersCount = [Int]()
    
stack.pop() // value of type '[Character]' has no member 'pop'
repeatedLetters.append(word) // cannot convert value of type 'String.SubSequence' (aka 'Substring') to expected argument type 'String'

func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "(" {
            stack.append(bracket)
        } else if bracket == ")" {
            if stack.isEmpty() {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty()
}

func reverseString(s: String) -> String {
    var reversed = ""
    for char in s {
        reversed = char + reversed
    }
    return reversed
}
```swift
// brackets is a string of "(" and ")".
// return true if every opening bracket has a corresponding closing bracket.
// correctBracketing(brackets: "(") == false
// correctBracketing(brackets: "()") == true
// correctBracketing(brackets: "(()())") == true
// correctBracketing(brackets: ")(()") == false
func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "(" {
            stack.append(bracket)
        } else if bracket == ")" {
            if stack.isEmpty() {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty()
}

// -----------------------------------------------------------------------------
// 1.1.3
// -----------------------------------------------------------------------------
// Write a function that takes a string as input and returns the string reversed.
// reverseString("hello") == "olleh"
// reverseString("") == ""
// reverseString("h") == "h"
// reverseString("a") == "a"
// reverseString("ab") == "ba"
// reverseString("abc") == "cba"
// reverseString("abcd") == "dcba"
// reverseString("abcde") == "edcba"
func reverseString(s: String) -> String {
    var reversed = ""
    for char in s {
        reversed = char + reversed
    }
    return reversed
}

// -----------------------------------------------------------------------------
// 1.1.4
// -----------------------------------------------------------------------------
// Write a function that takes a string as input and returns the string with
// all capital letters converted to lowercase letters, and vice versa.
// swapCase("Hello, World!") == "hELLO, wORLD!"
// swapCase("HELLO, WORLD!") == "hello, world!"
// swapCase("") == ""
// swapCase("a") == "A"
// swapCase("A") == "a"
// swapCase("aBc") == "AbC"
// swapCase("AbC") == "aBC"
// swapCase("AbCd") == "aBCd"
// swapCase("AbCdEf") == "aBCdEf"
// swapCase("AbCdEfGh") == "aBCdEfgh"
// swapCase("AbCdEfGhIj") == "aBCdEfghIJ"
// swapCase("AbCdEfGhIjKl") == "aBCdEfghIJKL"
// swapCase("AbCdEfGhIjKlMn") == "aBCdEfghIJKLmN"
// swapCase("AbCdEfGhIjKlMnNoPqRsTuVwXyZ") == "aBCdEfghIJKLmNnOPQRSTUVWXYZ"
// swapCase("AbCdEfGhIjKlMnNoPqRsTuVwXyZ!@#$%^&*()") == "aBCdEfghIJKLmNnOPQRSTUVWXYZ!@#$%^&*()"
// swapCase("AbCdEfGhIjKlMnNoPqRsTuVwXyZ!@#$%^&*()-=_+") == "aBCdEfghIJKLmNnOPQRSTUVWXYZ!@#$%^&*()-=_+"
// swapCase("AbCdEfGhIjKlMnNoPqRsTuVwXyZ!@#$%^&*()-=_+{|}") == "aBCdEfghIJKLmNnOPQRSTUVWXYZ!@#$%^&*()-=_+{|}"
// swapCase("AbCdEfGhIjKlMnNoPqRsTuVwXyZ!@#$%^&*()-=_+{|}~") == "aBCdEfghIJKLmNnOPQRSTUVWXYZ!@#$%^&*()-=_+{|}~"
// swapCase("AbCdEfGhIjKlMnNo
if stack.isEmpty() { // cannot call value of non-function type 'Bool'
stack.pop() // value of type '[Character]' has no member 'pop'
return stack.isEmpty() // cannot call value of non-function type 'Bool'
reversed = char + reversed // cannot convert value of type 'Character' to expected argument type 'String'

func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "(" {
            stack.append(bracket)
        } else if bracket == ")" {
            if stack.isEmpty {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty
}

func countVowels(string: String) -> Int {
    var count = 0
    for char in string {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}

func countSubstring(string: String, substring: String) -> Int {
    var count = 0
    var index = 0
    while index < string.count {
        index = string.index(of: substring, range: (index, string.count - index), options: .caseInsensitive)
        if index != nil {
            count += 1
            index += substring.count
        } else {
            break
        }
    }
    return count
}
```swift
// brackets is a string of "(" and ")".
// return true if every opening bracket has a corresponding closing bracket.
// correctBracketing(brackets: "(") == false
// correctBracketing(brackets: "()") == true
// correctBracketing(brackets: "(()())") == true
// correctBracketing(brackets: ")(()") == false
func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "(" {
            stack.append(bracket)
        } else if bracket == ")" {
            if stack.isEmpty {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty
}

// -----------------------------------------------------------------------------
// 2. Write a function that takes a string as input and returns the number of
// vowels in the string.
// countVowels("Hello world") == 3
// countVowels("aeiou") == 5
// countVowels("") == 0
func countVowels(string: String) -> Int {
    var count = 0
    for char in string {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// 3. Write a function that takes a string as input and returns the number of
// times the string appears in the string.
// countSubstring("Hello world", "llo") == 2
// countSubstring("Hello world", "lo") == 2
// countSubstring("Hello world", "world") == 1
// countSubstring("Hello world", "") == 1
func countSubstring(string: String, substring: String) -> Int {
    var count = 0
    var index = 0
    while index < string.count {
        index = string.index(of: substring, range: (index, string.count - index), options: .caseInsensitive)
        if index != nil {
            count += 1
            index += substring.count
        } else {
            break
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// 4. Write a function that takes a string as input and returns the number of
// times the string appears in the string.
// countSubstring("Hello world", "llo") == 2
// countSubstring("Hello world", "lo") == 2
// countSubstring("Hello world", "world") == 1
// countSubstring("Hello world", "") == 1
func countSubstring(string: String, substring: String) -> Int {
    var count = 0
    var index = 0
    while index < string.count {
        index = string.index(of: substring, range: (index, string.count - index), options: .caseInsensitive)
        if index != nil {
            count += 1
            index += substring.count
        } else {
            break
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// 5. Write a function that takes a string as input and returns the number of
// times the string appears in the string.
// countSubstring("Hello world", "llo") == 2
// countSubstring("Hello world", "lo") == 2
// countSubstring("Hello world", "world") == 1
// countSubstring("Hello world", "") == 1
func countSubstring(string: String, substring: String) -> Int {
    var count = 0
    var index = 0
    while index < string.count {
        index = string.index(of: substring, range: (index, string.count - index), options: .caseInsensitive)
        if index != nil {
            count += 1
            index += substring.count
        } else {
            break
        }
    }
    return count
}

// ---------------------------------------------------------
stack.pop() // value of type '[Character]' has no member 'pop'
index = string.index(of: substring, range: (index, string.count - index), options: .caseInsensitive) // cannot assign value of type 'String.Index?' to type 'Int'
index = string.index(of: substring, range: (index, string.count - index), options: .caseInsensitive) // extra arguments at positions #2, #3 in call
index = string.index(of: substring, range: (index, string.count - index), options: .caseInsensitive) // cannot infer contextual base in reference to member 'caseInsensitive'
if index != nil { // comparing non-optional value of type 'Int' to 'nil' always returns true

func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "(" {
            stack.append(bracket)
        } else {
            if stack.isEmpty {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty
}
```swift
// brackets is a string of "(" and ")".
// return true if every opening bracket has a corresponding closing bracket.
// correctBracketing(brackets: "(") == false
// correctBracketing(brackets: "()") == true
// correctBracketing(brackets: "(()())") == true
// correctBracketing(brackets: ")(()") == false
func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "(" {
            stack.append(bracket)
        } else {
            if stack.isEmpty {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty
}

// 2. Write a function that takes a string of brackets and determines if the brackets are balanced.
// The function should return true if the brackets are balanced and false if they are not.
// The brackets are balanced if for every opening bracket, there is a closing bracket.
// The brackets must be closed in the correct order.
// The brackets must also be matched with the correct order.
// The function should return false if the brackets are not balanced.
// balancedBrackets(brackets: "()") == true
// balancedBrackets(brackets: ")(()") == false
// balancedBrackets(brackets: "(()())") == true
// balancedBrackets(brackets: "(()))") == false
// balancedBrackets(brackets: "(()))(") == false
// balancedBrackets(brackets: "(()))((") == false
// balancedBrackets(brackets: "(()))((()") == false
// balancedBrackets(brackets: "(()))((())") == true
// balancedBrackets(brackets: "(()))((())(") == false
// balancedBrackets(brackets: "(()))((())(()") == false
// balancedBrackets(brackets: "(()))((())(())") == true
// balancedBrackets(brackets: "(()))((())(())(") == false
// balancedBrackets(brackets: "(()))((())(())(()") == false
// balancedBrackets(brackets: "(()))((())(())(())") == true
// balancedBrackets(brackets: "(()))((())(())(())(") == false
// balancedBrackets(brackets: "(()))((())(())(())(()") == false
// balancedBrackets(brackets: "(()))((())(())(())(())") == true
// balancedBrackets(brackets: "(()))((())(())(())(())(") == false
// balancedBrackets(brackets: "(()))((())(())(())(())(()") == false
// balancedBrackets(brackets: "(()))((())(())(())(())(())") == true
// balancedBrackets(brackets: "(()))((())(())(())(())(())(") == false
// balancedBrackets(brackets: "(()))((())(())(())(())(())(()") == false
// balancedBrackets(brackets: "(()))((())(())(())(())(())(())") == true
// balancedBrackets(brackets: "(()))((())(())(())(())(())(())(") == false
// balancedBrackets(brackets: "(()))((())(())(())(())(())(())(()") == false
// balancedBrackets(brackets: "(()))((())(())(())(())(())(())(())") == true
// balancedBrackets(brackets: "(()))((())(())(())(())(())(())(())(") == false
// balancedBrackets(brackets: "(()))((())(())(())(())(())(())(())(()") == false
// balancedBrackets(brackets: "(()))((())(())(())(())(())(())(())(()") == false
// balancedBrackets(brackets: "(()))((())(())(())(())(())(())(())(()") == false
// balancedBrackets(brackets: "(()))((())(())(())(())(())(())(())(())(") == false
// balancedBrackets(brackets: "(()))((())(())(())(())(())(())(())(())(()") == false
// balancedBrackets(brackets: "(()))((())(()
stack.pop() // value of type '[Character]' has no member 'pop'

func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "(" {
            stack.append(bracket)
        } else {
            if stack.isEmpty {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty
}

func vowelsInString(string: String) -> Int {
    var vowels = 0
    for char in string {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            vowels += 1
        }
    }
    return vowels
}

func wordsInString(string: String) -> Int {
    var words = 0
    var currentWord = ""
    for char in string {
        if char == " " {
            words += 1
            currentWord = ""
        } else {
            currentWord += char
        }
    }
    if currentWord != "" {
        words += 1
    }
    return words
}

func consonantsInString(string: String) -> Int {
    var consonants = 0
    for char in string {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            consonants += 1
        }
    }
    return consonants
}

func uppercaseInString(string: String) -> Int {
    var uppercase = 0
    for char in string {
        if char == char.uppercase {
            uppercase += 1
        }
    }
    return uppercase
}

func lowercaseInString(string: String) -> Int {
    var lowercase = 0
    for char in string {
        if char == char.lowercase {
            lowercase += 1
        }
    }
    return lowercase
}
```swift
// brackets is a string of "(" and ")".
// return true if every opening bracket has a corresponding closing bracket.
// correctBracketing(brackets: "(") == false
// correctBracketing(brackets: "()") == true
// correctBracketing(brackets: "(()())") == true
// correctBracketing(brackets: ")(()") == false
func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "(" {
            stack.append(bracket)
        } else {
            if stack.isEmpty {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty
}

// -----------------------------------------------------------------------------
// 12. Write a function that takes a string and returns the number of vowels in the string.
// vowelsInString("Hello world") == 3
// vowelsInString("aeiou") == 5
// vowelsInString("") == 0
func vowelsInString(string: String) -> Int {
    var vowels = 0
    for char in string {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            vowels += 1
        }
    }
    return vowels
}

// -----------------------------------------------------------------------------
// 13. Write a function that takes a string and returns the number of words in the string.
// wordsInString("Hello world") == 2
// wordsInString("") == 0
// wordsInString("Hello world, how are you?") == 4
func wordsInString(string: String) -> Int {
    var words = 0
    var currentWord = ""
    for char in string {
        if char == " " {
            words += 1
            currentWord = ""
        } else {
            currentWord += char
        }
    }
    if currentWord != "" {
        words += 1
    }
    return words
}

// -----------------------------------------------------------------------------
// 14. Write a function that takes a string and returns the number of consonants in the string.
// consonantsInString("Hello world") == 5
// consonantsInString("aeiou") == 0
// consonantsInString("") == 0
func consonantsInString(string: String) -> Int {
    var consonants = 0
    for char in string {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            consonants += 1
        }
    }
    return consonants
}

// -----------------------------------------------------------------------------
// 15. Write a function that takes a string and returns the number of uppercase letters in the string.
// uppercaseInString("Hello world") == 1
// uppercaseInString("") == 0
// uppercaseInString("Hello world, how are you?") == 2
func uppercaseInString(string: String) -> Int {
    var uppercase = 0
    for char in string {
        if char == char.uppercase {
            uppercase += 1
        }
    }
    return uppercase
}

// -----------------------------------------------------------------------------
// 16. Write a function that takes a string and returns the number of lowercase letters in the string.
// lowercaseInString("Hello world") == 5
// lowercaseInString("") == 0
// lowercaseInString("Hello world, how are you?") == 11
func lowercaseInString(string: String) -> Int {
    var lowercase = 0
    for char in string {
        if char == char.lowercase {
            lowercase += 1
        }
    }
    return lowercase
}

// ---------------------------------------------------------------------------
stack.pop() // value of type '[Character]' has no member 'pop'
currentWord += char // cannot convert value of type 'Character' to expected argument type 'String'
if char == char.uppercase { // value of type 'Character' has no member 'uppercase'
if char == char.lowercase { // value of type 'Character' has no member 'lowercase'

func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        switch bracket {
        case "(":
            stack.append(bracket)
        case ")":
            if stack.isEmpty {
                return false
            }
            stack.pop()
        default:
            break
        }
    }
    return stack.isEmpty
}

func reverseString(s: String) -> String {
    return String(s.reversed())
}

func isIsomorphic(s: String, t: String) -> Bool {
    return isIsomorphicHelper(s, t) && isIsomorphicHelper(t, s)
}

func isIsomorphicHelper(s: String, t: String) -> Bool {
    var map = [Character: Character]()
    for i in 0..<s.count {
        if map[s[i]] == nil {
            map[s[i]] = t[i]
        } else if map[s[i]] != t[i] {
            return false
        }
    }
    return true
}

func isPalindrome(s: String) -> Bool {
    var s = s.trim().toLowerCase()
    var i = 0
    var j = s.count - 1
    while i < j {
        if !isAlphaNumeric(s[i]) {
            i++
        } else if !isAlphaNumeric(s[j]) {
            j--
        } else if s[i] != s[j] {
            return false
        } else {
            i++
            j--
        }
    }
    return true
}

func isAlphaNumeric(c: Character) -> Bool {
    return (c >= "a" && c <= "z") || (c >= "0" && c <= "9")
}
```swift
// brackets is a string of "(" and ")".
// return true if every opening bracket has a corresponding closing bracket.
// correctBracketing(brackets: "(") == false
// correctBracketing(brackets: "()") == true
// correctBracketing(brackets: "(()())") == true
// correctBracketing(brackets: ")(()") == false
func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        switch bracket {
        case "(":
            stack.append(bracket)
        case ")":
            if stack.isEmpty {
                return false
            }
            stack.pop()
        default:
            break
        }
    }
    return stack.isEmpty
}

// -----------------------------------------------------------------------------
// 1.1
// -----------------------------------------------------------------------------
// Write a function that takes a string as input and returns the string reversed.
// Example:
// Given s = "hello", return "olleh".
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// -----------------------------------------------------------------------------
// 1.2
// -----------------------------------------------------------------------------
// Given two strings s and t, determine if they are isomorphic.
// Two strings are isomorphic if the characters in s can be replaced to get t.
// All occurrences of a character must be replaced with another character while
// preserving the order of characters. No two characters may map to the same
// character but a character may map to itself.
// Example 1:
// Input: s = "egg", t = "add"
// Output: true
// Example 2:
// Input: s = "foo", t = "bar"
// Output: false
// Example 3:
// Input: s = "paper", t = "title"
// Output: true
// Note:
// You may assume both s and t have the same length.
func isIsomorphic(s: String, t: String) -> Bool {
    return isIsomorphicHelper(s, t) && isIsomorphicHelper(t, s)
}

func isIsomorphicHelper(s: String, t: String) -> Bool {
    var map = [Character: Character]()
    for i in 0..<s.count {
        if map[s[i]] == nil {
            map[s[i]] = t[i]
        } else if map[s[i]] != t[i] {
            return false
        }
    }
    return true
}

// -----------------------------------------------------------------------------
// 1.3
// -----------------------------------------------------------------------------
// Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
// Note: For the purpose of this problem, we define empty string as valid palindrome.
// Example 1:
// Input: "A man, a plan, a canal: Panama"
// Output: true
// Example 2:
// Input: "race a car"
// Output: false
func isPalindrome(s: String) -> Bool {
    var s = s.trim().toLowerCase()
    var i = 0
    var j = s.count - 1
    while i < j {
        if !isAlphaNumeric(s[i]) {
            i++
        } else if !isAlphaNumeric(s[j]) {
            j--
        } else if s[i] != s[j] {
            return false
        } else {
            i++
            j--
        }
    }
    return true
}

func isAlphaNumeric(c: Character) -> Bool {
    return (c >= "a" && c <= "z") || (c >= "0" && c <= "9")
}

// -----------------------------------------------------------------------------
// 1.4
// -----------------------------------------------------------------------------
// Given an input string, reverse the string word by word.
// A word is defined as a sequence of
stack.pop() // value of type '[Character]' has no member 'pop'
return isIsomorphicHelper(s, t) && isIsomorphicHelper(t, s) // missing argument labels 's:t:' in call
return isIsomorphicHelper(s, t) && isIsomorphicHelper(t, s) // missing argument labels 's:t:' in call
if map[s[i]] == nil { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
map[s[i]] = t[i] // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
map[s[i]] = t[i] // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
} else if map[s[i]] != t[i] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
} else if map[s[i]] != t[i] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
var s = s.trim().toLowerCase() // value of type 'String' has no member 'trim'
if !isAlphaNumeric(s[i]) { // missing argument label 'c:' in call
i++ // cannot find operator '++' in scope; did you mean '+= 1'?
} else if !isAlphaNumeric(s[j]) { // missing argument label 'c:' in call
j-- // cannot find operator '--' in scope; did you mean '-= 1'?
i++ // cannot find operator '++' in scope; did you mean '+= 1'?
j-- // cannot find operator '--' in scope; did you mean '-= 1'?

func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "(" {
            stack.append(bracket)
        } else if bracket == ")" {
            if stack.isEmpty {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty
}
```swift
// brackets is a string of "(" and ")".
// return true if every opening bracket has a corresponding closing bracket.
// correctBracketing(brackets: "(") == false
// correctBracketing(brackets: "()") == true
// correctBracketing(brackets: "(()())") == true
// correctBracketing(brackets: ")(()") == false
func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "(" {
            stack.append(bracket)
        } else if bracket == ")" {
            if stack.isEmpty {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty
}

// -----------------------------------------------------------------------------
// 1.2
// -----------------------------------------------------------------------------
// Write a function that takes a string as input and returns the string reversed.
// reverseString("hello") == "olleh"
// reverseString("") == ""
// reverseString("h") == "h"
// reverseString("a") == "a"
// reverseString("a b") == "b a"
// reverseString("a b c") == "c b a"
// reverseString("a b c d") == "d c b a"
// reverseString("a b c d e") == "e d c b a"
// reverseString("a b c d e f") == "f e d c b a"
// reverseString("a b c d e f g") == "g f e d c b a"
// reverseString("a b c d e f g h") == "h g f e d c b a"
// reverseString("a b c d e f g h i") == "i h g f e d c b a"
// reverseString("a b c d e f g h i j") == "j i h g f e d c b a"
// reverseString("a b c d e f g h i j k") == "k j i h g f e d c b a"
// reverseString("a b c d e f g h i j k l") == "l k j i h g f e d c b a"
// reverseString("a b c d e f g h i j k l m") == "m l k j i h g f e d c b a"
// reverseString("a b c d e f g h i j k l m n") == "n m l k j i h g f e d c b a"
// reverseString("a b c d e f g h i j k l m n o") == "o n m l k j i h g f e d c b a"
// reverseString("a b c d e f g h i j k l m n o p") == "p o n m l k j i h g f e d c b a"
// reverseString("a b c d e f g h i j k l m n o p q") == "q p o n m l k j i h g f e d c b a"
// reverseString("a b c d e f g h i j k l m n o p q r") == "r q p o n m l k j i h g f e d c b a"
// reverseString("a b c d e f g h i j k l m n o p q r s") == "s r q p o n m l k j i h g f e d c b a"
// reverseString("a b c d e f g h i j k l m n o p q r s t") == "t s r q p o n m l k j i h g f e d c b a"
// reverseString("a b c d e f g h i j k l m n o p q r s t u") == "u t s r q p o n m l k j i h g f e d c b a"
// reverseString("a b c d e f g h i j k l m n o p q r s t u v") == "v w u t s r q p o n m l k j i h g f e d c b a"
// reverseString("a b c d e f g h i j k l m n o p q r s t u v w") == "w x v t s r q p o n m l k j i h g f e d c b a"
// reverseString("a b c d e f g h i j k l m n
stack.pop() // value of type '[Character]' has no member 'pop'

func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "(" {
            stack.append(bracket)
        } else if bracket == ")" {
            if stack.isEmpty() {
                return false
            } else {
                stack.pop()
            }
        }
    }
    return stack.isEmpty()
}

func countVowels(input: String) -> Int {
    var count = 0
    for char in input {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}

func countWords(input: String) -> Int {
    var count = 0
    for char in input {
        if char == " " {
            count += 1
        }
    }
    return count + 1
}

func countSentences(input: String) -> Int {
    var count = 0
    for char in input {
        if char == "." {
            count += 1
        }
    }
    return count
}

func countParagraphs(input: String) -> Int {
    var count = 0
    for char in input {
        if char == "\n" {
            count += 1
        }
    }
    return count
}
```swift
// brackets is a string of "(" and ")".
// return true if every opening bracket has a corresponding closing bracket.
// correctBracketing(brackets: "(") == false
// correctBracketing(brackets: "()") == true
// correctBracketing(brackets: "(()())") == true
// correctBracketing(brackets: ")(()") == false
func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "(" {
            stack.append(bracket)
        } else if bracket == ")" {
            if stack.isEmpty() {
                return false
            } else {
                stack.pop()
            }
        }
    }
    return stack.isEmpty()
}

// 1.1.2
// Write a function that takes a string as input and returns the number of vowels in the string.
// countVowels("Hello world") == 3
// countVowels("I love cats") == 4
// countVowels("I love dogs") == 3
// countVowels("I love birds") == 4
// countVowels("I love birds and cats") == 8
func countVowels(input: String) -> Int {
    var count = 0
    for char in input {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}

// 1.1.3
// Write a function that takes a string as input and returns the number of words in the string.
// countWords("Hello world") == 2
// countWords("I love cats") == 2
// countWords("I love dogs") == 2
// countWords("I love birds") == 2
// countWords("I love birds and cats") == 4
func countWords(input: String) -> Int {
    var count = 0
    for char in input {
        if char == " " {
            count += 1
        }
    }
    return count + 1
}

// 1.1.4
// Write a function that takes a string as input and returns the number of sentences in the string.
// countSentences("Hello world. I love cats.") == 2
// countSentences("I love dogs. I love cats.") == 2
// countSentences("I love birds. I love cats.") == 2
// countSentences("I love birds and cats.") == 1
// countSentences("I love birds and cats. I love cats.") == 2
func countSentences(input: String) -> Int {
    var count = 0
    for char in input {
        if char == "." {
            count += 1
        }
    }
    return count
}

// 1.1.5
// Write a function that takes a string as input and returns the number of paragraphs in the string.
// countParagraphs("Hello world. I love cats.") == 1
// countParagraphs("I love dogs. I love cats.") == 1
// countParagraphs("I love birds. I love cats.") == 1
// countParagraphs("I love birds and cats.") == 1
// countParagraphs("I love birds and cats. I love cats.") == 2
func countParagraphs(input: String) -> Int {
    var count = 0
    for char in input {
        if char == "\n" {
            count += 1
        }
    }
    return count
}

// 1.1.6
// Write a function that takes a string as input and returns the number of words in the string.
// countWords("Hello world. I love cats.") == 2
// countWords("I love dogs. I love cats.") == 2
// countWords("I love birds. I love cats.") == 2
// countWords("I love birds and cats.") == 2
// countWords("I love birds and cats. I love cats.") == 2
func countWords(input: String) -> Int {
    var count = 0
    for char in input {
        if char == " " {
            count += 1
        }
    }
    return count + 1
}

// 1.1.7
// Write a function that takes a string as input and returns the number of words in the string.
// countWords("Hello world. I love
if stack.isEmpty() { // cannot call value of non-function type 'Bool'
stack.pop() // value of type '[Character]' has no member 'pop'
return stack.isEmpty() // cannot call value of non-function type 'Bool'

func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "(" {
            stack.append(bracket)
        } else if bracket == ")" {
            if stack.isEmpty() {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty()
}

func isNotIsNot(input: String) -> Bool {
    var isCount = 0
    var notCount = 0
    for char in input {
        if char == "is" {
            isCount += 1
        } else if char == "not" {
            notCount += 1
        }
    }
    return isCount == notCount
}

func isNotIsNot(input: String) -> Bool {
    var isCount = 0
    var notCount = 0
    for char in input {
        if char == "is" {
            isCount += 1
        } else if char == "not" {
            notCount += 1
        }
    }
    return isCount > notCount
}
```swift
// brackets is a string of "(" and ")".
// return true if every opening bracket has a corresponding closing bracket.
// correctBracketing(brackets: "(") == false
// correctBracketing(brackets: "()") == true
// correctBracketing(brackets: "(()())") == true
// correctBracketing(brackets: ")(()") == false
func correctBracketing(brackets: String) -> Bool {
    var stack = [Character]()
    for bracket in brackets {
        if bracket == "(" {
            stack.append(bracket)
        } else if bracket == ")" {
            if stack.isEmpty() {
                return false
            }
            stack.pop()
        }
    }
    return stack.isEmpty()
}

// 1.1.2
// Given a string, return true if the number of appearances of "is" anywhere in the
// string is equal to the number of appearances of "not" anywhere in the string (case sensitive).
// isNotIsNot("not not is not") == true
// isNotIsNot("is is not not") == false
// isNotIsNot("is is not is not") == false
func isNotIsNot(input: String) -> Bool {
    var isCount = 0
    var notCount = 0
    for char in input {
        if char == "is" {
            isCount += 1
        } else if char == "not" {
            notCount += 1
        }
    }
    return isCount == notCount
}

// 1.1.3
// Given a string, return true if the number of appearances of "is" anywhere in the
// string is greater than the number of appearances of "not" anywhere in the string (case sensitive).
// isNotIsNot("not not is not") == true
// isNotIsNot("is is not not") == false
// isNotIsNot("is is not is not") == true
func isNotIsNot(input: String) -> Bool {
    var isCount = 0
    var notCount = 0
    for char in input {
        if char == "is" {
            isCount += 1
        } else if char == "not" {
            notCount += 1
        }
    }
    return isCount > notCount
}

// 1.1.4
// Given a string, return true if the number of appearances of "is" anywhere in the
// string is greater than the number of appearances of "not" anywhere in the string (case sensitive).
// isNotIsNot("not not is not") == true
// isNotIsNot("is is not not") == false
// isNotIsNot("is is not is not") == true
func isNotIsNot(input: String) -> Bool {
    var isCount = 0
    var notCount = 0
    for char in input {
        if char == "is" {
            isCount += 1
        } else if char == "not" {
            notCount += 1
        }
    }
    return isCount > notCount
}

// 1.1.5
// Given a string, return true if the number of appearances of "is" anywhere in the
// string is greater than the number of appearances of "not" anywhere in the string (case sensitive).
// isNotIsNot("not not is not") == true
// isNotIsNot("is is not not") == false
// isNotIsNot("is is not is not") == true
func isNotIsNot(input: String) -> Bool {
    var isCount = 0
    var notCount = 0
    for char in input {
        if char == "is" {
            isCount += 1
        } else if char == "not" {
            notCount += 1
        }
    }
    return isCount > notCount
}

// 1.1.6
// Given a string, return true if the number of appearances of "is" anywhere in the
// string is greater than the number of appearances of "not" anywhere in the string (case sensitive).
// isNotIsNot("not not is not") == true
// isNotIsNot("is is not not") == false
// isNotIsNot("is is not is not") == true
func isNotIsNot(input: String) -> Bool {
    var isCount = 0
    var notCount = 0
    for char in input {
        if char == "is" {
            isCount += 1
        } else if char == "not" {
            notCount += 1
        }
    }
    return isCount > notCount
}
if stack.isEmpty() { // cannot call value of non-function type 'Bool'
stack.pop() // value of type '[Character]' has no member 'pop'
return stack.isEmpty() // cannot call value of non-function type 'Bool'
if char == "is" { // binary operator '==' cannot be applied to operands of type 'Character' and 'String'
} else if char == "not" { // binary operator '==' cannot be applied to operands of type 'Character' and 'String'
func isNotIsNot(input: String) -> Bool { // invalid redeclaration of 'isNotIsNot(input:)'
if char == "is" { // binary operator '==' cannot be applied to operands of type 'Character' and 'String'
} else if char == "not" { // binary operator '==' cannot be applied to operands of type 'Character' and 'String'

func derivative(xs: [Int]) -> [Int] {
    var result = [Int]()
    for i in 1..<xs.count {
        result.append(xs[i] * i)
    }
    return result
}

struct Polynomial {
    var coefficients: [Int]

    init(coefficients: [Int]) {
        self.coefficients = coefficients
    }

    func derivative() -> Polynomial {
        return Polynomial(coefficients: derivative(xs: coefficients))
    }
}
```swift
// xs represent coefficients of a polynomial.
// xs[0] + xs[1] * x + xs[2] * x^2 + ....
// Return derivative of this polynomial in the same form.
// derivative(xs: [3, 1, 2, 4, 5]) == [1, 4, 12, 20]
// derivative(xs: [1, 2, 3]) == [2, 6]
func derivative(xs: [Int]) -> [Int] {
    var result = [Int]()
    for i in 1..<xs.count {
        result.append(xs[i] * i)
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

struct Polynomial {
    var coefficients: [Int]

    init(coefficients: [Int]) {
        self.coefficients = coefficients
    }

    func derivative() -> Polynomial {
        return Polynomial(coefficients: derivative(xs: coefficients))
    }
}

func derivative(xs: [Int]) -> [Int] {
    var result = [Int]()
    for i in 1..<xs.count {
        result.append(xs[i] * i)
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

struct Polynomial {
    var coefficients: [Int]

    init(coefficients: [Int]) {
        self.coefficients = coefficients
    }

    func derivative() -> Polynomial {
        return Polynomial(coefficients: derivative(xs: coefficients))
    }
}

func derivative(xs: [Int]) -> [Int] {
    var result = [Int]()
    for i in 1..<xs.count {
        result.append(xs[i] * i)
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

struct Polynomial {
    var coefficients: [Int]

    init(coefficients: [Int]) {
        self.coefficients = coefficients
    }

    func derivative() -> Polynomial {
        return Polynomial(coefficients: derivative(xs: coefficients))
    }
}

func derivative(xs: [Int]) -> [Int] {
    var result = [Int]()
    for i in 1..<xs.count {
        result.append(xs[i] * i)
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

struct Polynomial {
    var coefficients: [Int]

    init(coefficients: [Int]) {
        self.coefficients = coefficients
    }

    func derivative() -> Polynomial {
        return Polynomial(coefficients: derivative(xs: coefficients))
    }
}

func derivative(xs: [Int]) -> [Int] {
    var result = [Int]()
    for i in 1..<xs.count {
        result.append(xs[i] * i)
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

struct Polynomial {
    var coefficients: [Int]

    init(coefficients: [Int]) {
        self.coe
return Polynomial(coefficients: derivative(xs: coefficients)) // use of 'derivative' refers to instance method rather than global function 'derivative(xs:)' in module 'Solution'

func derivative(xs: [Int]) -> [Int] {
    var result = [Int]()
    for i in 1..<xs.count {
        result.append(xs[i] * i)
    }
    return result
}
```swift
// xs represent coefficients of a polynomial.
// xs[0] + xs[1] * x + xs[2] * x^2 + ....
// Return derivative of this polynomial in the same form.
// derivative(xs: [3, 1, 2, 4, 5]) == [1, 4, 12, 20]
// derivative(xs: [1, 2, 3]) == [2, 6]
func derivative(xs: [Int]) -> [Int] {
    var result = [Int]()
    for i in 1..<xs.count {
        result.append(xs[i] * i)
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ------

func derivative(xs: [Int]) -> [Int] {
    var result = [Int]()
    for i in 1..<xs.count {
        result.append(xs[i] * i)
    }
    return result
}
```swift
// xs represent coefficients of a polynomial.
// xs[0] + xs[1] * x + xs[2] * x^2 + ....
// Return derivative of this polynomial in the same form.
// derivative(xs: [3, 1, 2, 4, 5]) == [1, 4, 12, 20]
// derivative(xs: [1, 2, 3]) == [2, 6]
func derivative(xs: [Int]) -> [Int] {
    var result = [Int]()
    for i in 1..<xs.count {
        result.append(xs[i] * i)
    }
    return result
}

print(derivative([3, 1, 2, 4, 5]))
print(derivative([1, 2, 3]))

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------

func derivative(xs: [Int]) -> [Int] {
    var result = [Int]()
    for i in 0..<xs.count {
        if i == 0 {
            result.append(xs[i])
        } else {
            result.append(xs[i] * i)
        }
    }
    return result
}

func alphabetize(s: String) -> String {
    var result = String()
    var chars = Array(s)
    var sortedChars = chars.sorted()
    for char in sortedChars {
        result += char
    }
    return result
}

func reverseAlphabetize(s: String) -> String {
    var result = String()
    var chars = Array(s)
    var sortedChars = chars.sorted(by: <)
    for char in sortedChars {
        result += char
    }
    return result
}

func removeDuplicates(s: String) -> String {
    var result = String()
    var chars = Array(s)
    var sortedChars = chars.sorted()
    for char in sortedChars {
        if !result.contains(char) {
            result += char
        }
    }
    return result
}

func reverseRemoveDuplicates(s: String) -> String {
    var result = String()
    var chars = Array(s)
    var sortedChars = chars.sorted(by: >)
    for char in sortedChars {
        if !result.contains(char) {
            result += char
        }
    }
    return result
}
```swift
// xs represent coefficients of a polynomial.
// xs[0] + xs[1] * x + xs[2] * x^2 + ....
// Return derivative of this polynomial in the same form.
// derivative(xs: [3, 1, 2, 4, 5]) == [1, 4, 12, 20]
// derivative(xs: [1, 2, 3]) == [2, 6]
func derivative(xs: [Int]) -> [Int] {
    var result = [Int]()
    for i in 0..<xs.count {
        if i == 0 {
            result.append(xs[i])
        } else {
            result.append(xs[i] * i)
        }
    }
    return result
}

// 1. Write a function that takes a string and returns a string with all the letters in alphabetical order.
// Example: alphabetize("hello") == "ehllo"
// alphabetize("edabit") == "abdeit"
// alphabetize("") == ""
// alphabetize("sama") == "amass"
// alphabetize("c") == "c"

func alphabetize(s: String) -> String {
    var result = String()
    var chars = Array(s)
    var sortedChars = chars.sorted()
    for char in sortedChars {
        result += char
    }
    return result
}

// 2. Write a function that takes a string and returns a string with all the letters in reverse alphabetical order.
// Example: reverseAlphabetize("hello") == "olleh"
// reverseAlphabetize("edabit") == "tibade"
// reverseAlphabetize("") == ""
// reverseAlphabetize("sama") == "assam"
// reverseAlphabetize("c") == "c"

func reverseAlphabetize(s: String) -> String {
    var result = String()
    var chars = Array(s)
    var sortedChars = chars.sorted(by: <)
    for char in sortedChars {
        result += char
    }
    return result
}

// 3. Write a function that takes a string and returns a string with all the letters in alphabetical order, but with any duplicate letters removed.
// Example: removeDuplicates("hello") == "helo"
// removeDuplicates("edabit") == "abdeit"
// removeDuplicates("") == ""
// removeDuplicates("sama") == "amass"
// removeDuplicates("c") == "c"

func removeDuplicates(s: String) -> String {
    var result = String()
    var chars = Array(s)
    var sortedChars = chars.sorted()
    for char in sortedChars {
        if !result.contains(char) {
            result += char
        }
    }
    return result
}

// 4. Write a function that takes a string and returns a string with all the letters in reverse alphabetical order, but with any duplicate letters removed.
// Example: reverseRemoveDuplicates("hello") == "olleh"
// reverseRemoveDuplicates("edabit") == "tibade"
// reverseRemoveDuplicates("") == ""
// reverseRemoveDuplicates("sama") == "assam"
// reverseRemoveDuplicates("c") == "c"

func reverseRemoveDuplicates(s: String) -> String {
    var result = String()
    var chars = Array(s)
    var sortedChars = chars.sorted(by: >)
    for char in sortedChars {
        if !result.contains(char) {
            result += char
        }
    }
    return result
}

// 5. Write a function that takes a string and returns a string with all the letters in alphabetical order, but with any duplicate letters removed.
// Example: removeDuplicates("hello") == "helo"
// removeDuplicates("edabit") == "abdeit"
// removeDuplicates("") == ""
// removeDuplicates("sama") == "amass"
// removeDuplicates("c") == "c"

func removeDuplicates(s: String) -> String {
    var result = String()
    var chars = Array(s)
    var sortedChars = chars.sorted()
    for char in sortedChars {
        if !result.contains(char) {
            result += char
        }
    }
    return result
}

// 6
result += char // cannot convert value of type 'String.Element' (aka 'Character') to expected argument type 'String'
result += char // cannot convert value of type 'String.Element' (aka 'Character') to expected argument type 'String'
result += char // cannot convert value of type 'String.Element' (aka 'Character') to expected argument type 'String'
result += char // cannot convert value of type 'String.Element' (aka 'Character') to expected argument type 'String'

func derivative(xs: [Int]) -> [Int] {
    var result = [Int]()
    for i in 1..<xs.count {
        result.append(xs[i] * i)
    }
    return result
}
```swift
// xs represent coefficients of a polynomial.
// xs[0] + xs[1] * x + xs[2] * x^2 + ....
// Return derivative of this polynomial in the same form.
// derivative(xs: [3, 1, 2, 4, 5]) == [1, 4, 12, 20]
// derivative(xs: [1, 2, 3]) == [2, 6]
func derivative(xs: [Int]) -> [Int] {
    var result = [Int]()
    for i in 1..<xs.count {
        result.append(xs[i] * i)
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ---------------------

func derivative(xs: [Int]) -> [Int] {
    var result = [Int]()
    for i in 0..<xs.count {
        if i == 0 {
            result.append(xs[i])
        } else {
            result.append(xs[i] * i)
        }
    }
    return result
}
```swift
// xs represent coefficients of a polynomial.
// xs[0] + xs[1] * x + xs[2] * x^2 + ....
// Return derivative of this polynomial in the same form.
// derivative(xs: [3, 1, 2, 4, 5]) == [1, 4, 12, 20]
// derivative(xs: [1, 2, 3]) == [2, 6]
func derivative(xs: [Int]) -> [Int] {
    var result = [Int]()
    for i in 0..<xs.count {
        if i == 0 {
            result.append(xs[i])
        } else {
            result.append(xs[i] * i)
        }
    }
    return result
}

print(derivative([3, 1, 2, 4, 5]))
print(derivative([1, 2, 3]))

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // XCTAssertTrue failed

func derivative(xs: [Int]) -> [Int] {
    var result = [Int]()
    for i in 0..<xs.count {
        if i == 0 {
            result.append(xs[i])
        } else {
            result.append(xs[i] * i)
        }
    }
    return result
}
```swift
// xs represent coefficients of a polynomial.
// xs[0] + xs[1] * x + xs[2] * x^2 + ....
// Return derivative of this polynomial in the same form.
// derivative(xs: [3, 1, 2, 4, 5]) == [1, 4, 12, 20]
// derivative(xs: [1, 2, 3]) == [2, 6]
func derivative(xs: [Int]) -> [Int] {
    var result = [Int]()
    for i in 0..<xs.count {
        if i == 0 {
            result.append(xs[i])
        } else {
            result.append(xs[i] * i)
        }
    }
    return result
}

var xs = [3, 1, 2, 4, 5]
var result = derivative(xs: xs)
print("result: \(result)")

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------------------
 // XCTAssertTrue failed

func derivative(xs: [Int]) -> [Int] {
    var result = [Int]()
    for i in 1..<xs.count {
        result.append(xs[i] * i)
    }
    return result
}
```swift
// xs represent coefficients of a polynomial.
// xs[0] + xs[1] * x + xs[2] * x^2 + ....
// Return derivative of this polynomial in the same form.
// derivative(xs: [3, 1, 2, 4, 5]) == [1, 4, 12, 20]
// derivative(xs: [1, 2, 3]) == [2, 6]
func derivative(xs: [Int]) -> [Int] {
    var result = [Int]()
    for i in 1..<xs.count {
        result.append(xs[i] * i)
    }
    return result
}

// 2.
// Given a string, return the length of the longest substring without repeating characters.
// Example 1:
// Input: "abcabcbb"
// Output: 3
// Explanation: The answer is "abc", with the length of 3.
// Example 2:
// Input: "bbbbb"
// Output: 1
// Explanation: The answer is "b", with the length of 1.
// Example 3:
// Input: "pwwkew"
// Output: 3
// Explanation: The answer is "wke", with the length of 3.
//              Note that the answer must be a substring, "pwke" is a subsequence and not a substring.

// 3.
// Given a string s, find the length of the longest substring without repeating characters.
// Example 1:
// Input: s = "abcabcbb"
// Output: 3
// Explanation: The answer is "abc", with the length of 3.
// Example 2:
// Input: s = "bbbbb"
// Output: 1
// Explanation: The answer is "b", with the length of 1.
// Example 3:
// Input: s = "pwwkew"
// Output: 3
// Explanation: The answer is "wke", with the length of 3.
//              Note that the answer must be a substring, "pwke" is a subsequence and not a substring.

// 4.
// Given a string s, find the longest palindromic substring in s.
// You may assume that the maximum length of s is 1000.
// Example 1:
// Input: "babad"
// Output: "bab"
// Note: "aba" is also a valid answer.
// Example 2:
// Input: "cbbd"
// Output: "bb"

// 5.
// Given a string s, find the longest palindromic substring in s.
// You may assume that the maximum length of s is 1000.
// Example 1:
// Input: "babad"
// Output: "bab"
// Note: "aba" is also a valid answer.
// Example 2:
// Input: "cbbd"
// Output: "bb"

// 6.
// Given a string s, find the longest palindromic substring in s.
// You may assume that the maximum length of s is 1000.
// Example 1:
// Input: "babad"
// Output: "bab"
// Note: "aba" is also a valid answer.
// Example 2:
// Input: "cbbd"
// Output: "bb"

// 7.
// Given a string s, find the longest palindromic substring in s.
// You may assume that the maximum length of s is 1000.
// Example 1:
// Input: "babad"
// Output: "bab"
// Note: "aba" is also a valid answer.
// Example 2:
// Input: "cbbd"
// Output: "bb"

// 8.
// Given a string s, find the longest palindromic substring in s.
// You may assume that the maximum length of s is 1000.
// Example 1:
// Input: "babad"
// Output: "bab"
// Note: "aba" is also a valid answer.
// Example 2:
// Input: "cbbd"
// Output: "bb"

// 9.
// Given a string s, find the longest palindromic substring in s.
// You may assume that the maximum length of s is 1000.
// Example 1:
// Input: "babad"
// Output: "bab"
// Note: "aba" is also a valid answer.
// Example 2:
// Input: "cbbd"
// Output: "bb"

// 10.
// Given a string s, find the longest palindromic substring in s.
// You may assume that

func derivative(xs: [Int]) -> [Int] {
    var result = [Int]()
    for i in 1..<xs.count {
        result.append(xs[i] * i)
    }
    return result
}
```swift
// xs represent coefficients of a polynomial.
// xs[0] + xs[1] * x + xs[2] * x^2 + ....
// Return derivative of this polynomial in the same form.
// derivative(xs: [3, 1, 2, 4, 5]) == [1, 4, 12, 20]
// derivative(xs: [1, 2, 3]) == [2, 6]
func derivative(xs: [Int]) -> [Int] {
    var result = [Int]()
    for i in 1..<xs.count {
        result.append(xs[i] * i)
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ------

func derivative(xs: [Int]) -> [Int] {
    var result = [Int]()
    for i in 0..<xs.count {
        if i == 0 {
            result.append(xs[i])
        } else {
            result.append(xs[i] * i)
        }
    }
    return result
}
```swift
// xs represent coefficients of a polynomial.
// xs[0] + xs[1] * x + xs[2] * x^2 + ....
// Return derivative of this polynomial in the same form.
// derivative(xs: [3, 1, 2, 4, 5]) == [1, 4, 12, 20]
// derivative(xs: [1, 2, 3]) == [2, 6]
func derivative(xs: [Int]) -> [Int] {
    var result = [Int]()
    for i in 0..<xs.count {
        if i == 0 {
            result.append(xs[i])
        } else {
            result.append(xs[i] * i)
        }
    }
    return result
}

print(derivative([3, 1, 2, 4, 5]))
print(derivative([1, 2, 3]))

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // XCTAssertTrue failed

func fibfib(n: Int) -> Int {
    if n == 0 {
        return 0
    }
    if n == 1 {
        return 0
    }
    if n == 2 {
        return 1
    }
    return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3)
}
```swift
// The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
// fibfib(0) == 0
// fibfib(1) == 0
// fibfib(2) == 1
// fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).
// Please write a function to efficiently compute the n-th element of the fibfib number sequence.
// fibfib(n: 1) == 0
// fibfib(n: 5) == 4
// fibfib(n: 8) == 24
func fibfib(n: Int) -> Int {
    if n == 0 {
        return 0
    }
    if n == 1 {
        return 0
    }
    if n == 2 {
        return 1
    }
    return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3)
}

// 10. Write a function that takes a string and returns the number of vowels in the string.
//     You may assume the input is guaranteed to be a string.
//     You may iterate through the string as many times as necessary.
//     You may not use any built-in string methods.
//     You may use the `indexOf` method on strings.
//     You may use the `charAt` method on strings.
//     You may use the `length` property on strings.
//     You may use the `charCodeAt` method on strings.
//     You may use the `toLowerCase` method on strings.
//     You may use the `toUpperCase` method on strings.
//     You may use the `split` method on strings.
//     You may use the `join` method on strings.
//     You may use the `indexOf` method on strings.
//     You may use the `charAt` method on strings.
//     You may use the `length` property on strings.
//     You may use the `charCodeAt` method on strings.
//     You may use the `toLowerCase` method on strings.
//     You may use the `toUpperCase` method on strings.
//     You may use the `split` method on strings.
//     You may use the `join` method on strings.
//     You may use the `indexOf` method on strings.
//     You may use the `charAt` method on strings.
//     You may use the `length` property on strings.
//     You may use the `charCodeAt` method on strings.
//     You may use the `toLowerCase` method on strings.
//     You may use the `toUpperCase` method on strings.
//     You may use the `split` method on strings.
//     You may use the `join` method on strings.
//     You may use the `indexOf` method on strings.
//     You may use the `charAt` method on strings.
//     You may use the `length` property on strings.
//     You may use the `charCodeAt` method on strings.
//     You may use the `toLowerCase` method on strings.
//     You may use the `toUpperCase` method on strings.
//     You may use the `split` method on strings.
//     You may use the `join` method on strings.
//     You may use the `indexOf` method on strings.
//     You may use the `charAt` method on strings.
//     You may use the `length` property on strings.
//     You may use the `charCodeAt` method on strings.
//     You may use the `toLowerCase` method on strings.
//     You may use the `toUpperCase` method on strings.
//     You may use the `split` method on strings.
//     You may use the `join` method on strings.
//     You may use the `indexOf` method on strings.
//     You may use the `charAt` method on strings.
//     You may use the `length` property on strings.
//     You may use the `charCodeAt` method on strings.
//     You may use the `toLowerCase` method on strings.
//     You may use the `toUpperCase` method on strings.
//     You may use the `split` method on strings.
//     You may use the `join` method on strings.
//     You may use the `indexOf` method on strings.
//     You may use the `charAt` method on strings.
//     You may use the `length` property on strings.
//     You may use the `charCodeAt` method on strings.
//     You may use the `toLowerCase` method on strings.
//     You may use the `toUpperCase` method on strings.
//     You may use the `split` method on strings.
//     You may use the `join` method on strings.
//     You may use the `indexOf` method on strings.
//     You may use the `charAt` method on strings.
//     You may use the `length` property on strings.
//     You may use the
return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3) // missing argument label 'n:' in call
return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3) // missing argument label 'n:' in call
return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3) // missing argument label 'n:' in call

func fibfib(n: Int) -> Int {
    if n == 0 {
        return 0
    } else if n == 1 {
        return 0
    } else if n == 2 {
        return 1
    } else {
        return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3)
    }
}
```swift
// The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
// fibfib(0) == 0
// fibfib(1) == 0
// fibfib(2) == 1
// fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).
// Please write a function to efficiently compute the n-th element of the fibfib number sequence.
// fibfib(n: 1) == 0
// fibfib(n: 5) == 4
// fibfib(n: 8) == 24
func fibfib(n: Int) -> Int {
    if n == 0 {
        return 0
    } else if n == 1 {
        return 0
    } else if n == 2 {
        return 1
    } else {
        return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3)
    }
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ------------------------------------------
return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3) // missing argument label 'n:' in call
return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3) // missing argument label 'n:' in call
return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3) // missing argument label 'n:' in call

func fibfib(n: Int) -> Int {
    if n == 0 {
        return 0
    } else if n == 1 {
        return 0
    } else if n == 2 {
        return 1
    } else {
        return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3)
    }
}
```swift
// The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
// fibfib(0) == 0
// fibfib(1) == 0
// fibfib(2) == 1
// fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).
// Please write a function to efficiently compute the n-th element of the fibfib number sequence.
// fibfib(n: 1) == 0
// fibfib(n: 5) == 4
// fibfib(n: 8) == 24
func fibfib(n: Int) -> Int {
    if n == 0 {
        return 0
    } else if n == 1 {
        return 0
    } else if n == 2 {
        return 1
    } else {
        return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3)
    }
}

// 2. Write a function that takes a string and returns the number of vowels in the string.
// The vowel letters are a, e, i, o, u.
// Example:
// countVowels("Hello") == 2
// countVowels("Why do you ask?") == 4
// countVowels("Why?") == 0
// countVowels("") == 0
// countVowels("aeiou") == 5
// countVowels("aeiouaeiou") == 10
// countVowels("aeiouaeiouaeiouaeiou") == 15
// countVowels("aeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaei
return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3) // missing argument label 'n:' in call
return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3) // missing argument label 'n:' in call
return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3) // missing argument label 'n:' in call

func fibfib(n: Int) -> Int {
    if n == 0 {
        return 0
    }
    if n == 1 {
        return 0
    }
    if n == 2 {
        return 1
    }
    return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3)
}
```swift
// The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
// fibfib(0) == 0
// fibfib(1) == 0
// fibfib(2) == 1
// fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).
// Please write a function to efficiently compute the n-th element of the fibfib number sequence.
// fibfib(n: 1) == 0
// fibfib(n: 5) == 4
// fibfib(n: 8) == 24
func fibfib(n: Int) -> Int {
    if n == 0 {
        return 0
    }
    if n == 1 {
        return 0
    }
    if n == 2 {
        return 1
    }
    return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3)
}

print(fibfib(1)) // 0
print(fibfib(5)) // 4
print(fibfib(8)) // 24
print(fibfib(10)) // 41
print(fibfib(100)) // 354224848179261915075

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3) // missing argument label 'n:' in call
return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3) // missing argument label 'n:' in call
return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3) // missing argument label 'n:' in call

func fibfib(n: Int) -> Int {
    if n == 0 {
        return 0
    }
    if n == 1 {
        return 0
    }
    if n == 2 {
        return 1
    }
    return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3)
}
```swift
// The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
// fibfib(0) == 0
// fibfib(1) == 0
// fibfib(2) == 1
// fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).
// Please write a function to efficiently compute the n-th element of the fibfib number sequence.
// fibfib(n: 1) == 0
// fibfib(n: 5) == 4
// fibfib(n: 8) == 24
func fibfib(n: Int) -> Int {
    if n == 0 {
        return 0
    }
    if n == 1 {
        return 0
    }
    if n == 2 {
        return 1
    }
    return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3)
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------------
return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3) // missing argument label 'n:' in call
return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3) // missing argument label 'n:' in call
return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3) // missing argument label 'n:' in call

func fibfib(n: Int) -> Int {
    if n == 0 {
        return 0
    }
    if n == 1 {
        return 0
    }
    if n == 2 {
        return 1
    }
    return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3)
}
```swift
// The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
// fibfib(0) == 0
// fibfib(1) == 0
// fibfib(2) == 1
// fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).
// Please write a function to efficiently compute the n-th element of the fibfib number sequence.
// fibfib(n: 1) == 0
// fibfib(n: 5) == 4
// fibfib(n: 8) == 24
func fibfib(n: Int) -> Int {
    if n == 0 {
        return 0
    }
    if n == 1 {
        return 0
    }
    if n == 2 {
        return 1
    }
    return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3)
}

// 2. Write a function that takes a string and returns the number of vowels in the string.
// The vowel letters are a, e, i, o, u.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
// Please write a function that takes a string and returns the number of vowels in the string.
return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3) // missing argument label 'n:' in call
return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3) // missing argument label 'n:' in call
return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3) // missing argument label 'n:' in call

func fibfib(n: Int) -> Int {
    if n == 0 {
        return 0
    } else if n == 1 {
        return 0
    } else if n == 2 {
        return 1
    } else {
        return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3)
    }
}
```swift
// The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
// fibfib(0) == 0
// fibfib(1) == 0
// fibfib(2) == 1
// fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).
// Please write a function to efficiently compute the n-th element of the fibfib number sequence.
// fibfib(n: 1) == 0
// fibfib(n: 5) == 4
// fibfib(n: 8) == 24
func fibfib(n: Int) -> Int {
    if n == 0 {
        return 0
    } else if n == 1 {
        return 0
    } else if n == 2 {
        return 1
    } else {
        return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3)
    }
}

print(fibfib(1)) // 0
print(fibfib(5)) // 4
print(fibfib(8)) // 24

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3) // missing argument label 'n:' in call
return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3) // missing argument label 'n:' in call
return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3) // missing argument label 'n:' in call

func fibfib(n: Int) -> Int {
    if n == 0 {
        return 0
    }
    if n == 1 {
        return 0
    }
    if n == 2 {
        return 1
    }
    var fib1 = 0
    var fib2 = 0
    var fib3 = 1
    for _ in 1...n - 2 {
        fib1 = fib2
        fib2 = fib3
        fib3 = fib1 + fib2
    }
    return fib3
}
```swift
// The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
// fibfib(0) == 0
// fibfib(1) == 0
// fibfib(2) == 1
// fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).
// Please write a function to efficiently compute the n-th element of the fibfib number sequence.
// fibfib(n: 1) == 0
// fibfib(n: 5) == 4
// fibfib(n: 8) == 24
func fibfib(n: Int) -> Int {
    if n == 0 {
        return 0
    }
    if n == 1 {
        return 0
    }
    if n == 2 {
        return 1
    }
    var fib1 = 0
    var fib2 = 0
    var fib3 = 1
    for _ in 1...n - 2 {
        fib1 = fib2
        fib2 = fib3
        fib3 = fib1 + fib2
    }
    return fib3
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------------------
 // XCTAssertTrue failed

func fibfib(n: Int) -> Int {
    if n == 0 {
        return 0
    }
    if n == 1 {
        return 0
    }
    if n == 2 {
        return 1
    }
    return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3)
}

func reverseString(s: String) -> String {
    return String(s.reversed())
}
```swift
// The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
// fibfib(0) == 0
// fibfib(1) == 0
// fibfib(2) == 1
// fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).
// Please write a function to efficiently compute the n-th element of the fibfib number sequence.
// fibfib(n: 1) == 0
// fibfib(n: 5) == 4
// fibfib(n: 8) == 24
func fibfib(n: Int) -> Int {
    if n == 0 {
        return 0
    }
    if n == 1 {
        return 0
    }
    if n == 2 {
        return 1
    }
    return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3)
}

// 1.5
// Write a function that takes a string as input and returns the string reversed.
// Example:
// Given s = "hello", return "olleh".
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// 1.6
// Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
// Note: For the purpose of this problem, we define empty string as valid palindrome.
// Example:
// Input: "A man, a plan, a canal: Panama"
// Output: true
// Input: "race a car"
// Output: false
func isPalindrome(s: String) -> Bool {
    var s = s.trimmingCharacters(in: .whitespace)
    s = s.replacingOccurrences(with: " ")
    s = s.replacingOccurrences(with: ",")
    s = s.replacingOccurrences(with: ":")
    s = s.replacingOccurrences(with: ";")
    s = s.replacingOccurrences(with: ".")
    s = s.replacingOccurrences(with: "!")
    s = s.replacingOccurrences(with: "?")
    s = s.replacingOccurrences(with: "'")
    s = s.replacingOccurrences(with: "/")
    s = s.replacingOccurrences(with: "\\")
    s = s.replacingOccurrences(with: "(")
    s = s.replacingOccurrences(with: ")")
    s = s.replacingOccurrences(with: "[")
    s = s.replacingOccurrences(with: "]")
    s = s.replacingOccurrences(with: "{")
    s = s.replacingOccurrences(with: "}")
    s = s.replacingOccurrences(with: "@")
    s = s.replacingOccurrences(with: "#")
    s = s.replacingOccurrences(with: "$")
    s = s.replacingOccurrences(with: "%")
    s = s.replacingOccurrences(with: "^")
    s = s.replacingOccurrences(with: "&")
    s = s.replacingOccurrences(with: "*")
    s = s.replacingOccurrences(with: "+")
    s = s.replacingOccurrences(with: "=")
    s = s.replacingOccurrences(with: "|")
    s = s.replacingOccurrences(with: "~")
    s = s.replacingOccurrences(with: "`")
    s = s.replacingOccurrences(with: "<")
    s = s.replacingOccurrences(with: ">")
    s = s.replacingOccurrences(with: "/")
    s = s.replacingOccurrences(with: "-")
    s = s.replacingOccurrences(with: "_")
    s = s.replacingOccurrences(with: ".")
    s = s.replacingOccurrences(with: ",")
    s = s.replacingOccurrences(with: " ")
    s = s.replacingOccurrences(with: "\n")
    s = s.replacingOccurrences(with: "\t")
    s = s.replacingOccurrences(with: "\r")
    s = s.replacingOccurrences(with: "\f")
    s = s.replacingOccurrences(with: "\v")
    s = s.replacingOccurrences(with: "\
return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3) // missing argument label 'n:' in call
return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3) // missing argument label 'n:' in call
return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3) // missing argument label 'n:' in call

func fibfib(n: Int) -> Int {
    if n == 0 {
        return 0
    }
    if n == 1 {
        return 0
    }
    if n == 2 {
        return 1
    }
    return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3)
}
```swift
// The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
// fibfib(0) == 0
// fibfib(1) == 0
// fibfib(2) == 1
// fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).
// Please write a function to efficiently compute the n-th element of the fibfib number sequence.
// fibfib(n: 1) == 0
// fibfib(n: 5) == 4
// fibfib(n: 8) == 24
func fibfib(n: Int) -> Int {
    if n == 0 {
        return 0
    }
    if n == 1 {
        return 0
    }
    if n == 2 {
        return 1
    }
    return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3)
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------------
return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3) // missing argument label 'n:' in call
return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3) // missing argument label 'n:' in call
return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3) // missing argument label 'n:' in call

func vowelsCount(s: String) -> Int {
    var count = 0
    for char in s {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}

func length(s: String) -> Int {
    return s.count
}

func countUppercase(s: String) -> Int {
    var count = 0
    for char in s {
        if char == char.uppercase {
            count += 1
        }
    }
    return count
}

func countLowercase(s: String) -> Int {
    var count = 0
    for char in s {
        if char == char.lowercase {
            count += 1
        }
    }
    return count
}

func countDigits(s: String) -> Int {
    var count = 0
    for char in s {
        if char == char.digit {
            count += 1
        }
    }
    return count
}

func countWhitespace(s: String) -> Int {
    var count = 0
    for char in s {
        if char == char.whitespace {
            count += 1
        }
    }
    return count
}

func countNonWhitespace(s: String) -> Int {
    var count = 0
    for char in s {
        if char != char.whitespace {
            count += 1
        }
    }
    return count
}
```swift
// Write a function vowels_count which takes a string representing
// a word as input and returns the number of vowels in the string.
// Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a
// vowel, but only when it is at the end of the given word.
// Example:
// vowelsCount(s: "abcde") == 2
// vowelsCount(s: "ACEDY") == 3
func vowelsCount(s: String) -> Int {
    var count = 0
    for char in s {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// 2. Write a function that takes a string as input and returns the number of
// characters in the string.
// Example:
// length(s: "abcde") == 5
func length(s: String) -> Int {
    return s.count
}

// -----------------------------------------------------------------------------
// 3. Write a function that takes a string as input and returns the number of
// uppercase letters in the string.
// Example:
// countUppercase(s: "abcde") == 0
// countUppercase(s: "ABCDE") == 5
func countUppercase(s: String) -> Int {
    var count = 0
    for char in s {
        if char == char.uppercase {
            count += 1
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// 4. Write a function that takes a string as input and returns the number of
// lowercase letters in the string.
// Example:
// countLowercase(s: "abcde") == 5
// countLowercase(s: "ABCDE") == 0
func countLowercase(s: String) -> Int {
    var count = 0
    for char in s {
        if char == char.lowercase {
            count += 1
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// 5. Write a function that takes a string as input and returns the number of
// digits in the string.
// Example:
// countDigits(s: "abcde") == 0
// countDigits(s: "12345") == 5
func countDigits(s: String) -> Int {
    var count = 0
    for char in s {
        if char == char.digit {
            count += 1
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// 6. Write a function that takes a string as input and returns the number of
// whitespace characters in the string.
// Example:
// countWhitespace(s: "abcde") == 0
// countWhitespace(s: " abcde") == 1
// countWhitespace(s: "abcde ") == 1
// countWhitespace(s: " abcde ") == 2
func countWhitespace(s: String) -> Int {
    var count = 0
    for char in s {
        if char == char.whitespace {
            count += 1
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// 7. Write a function that takes a string as input and returns the number of
// non-whitespace characters in the string.
// Example:
// countNonWhitespace(s: "abcde") == 5
// countNonWhitespace(s: " abcde") == 5
// countNonWhitespace(s: " abcde ") == 5
func countNonWhitespace(s: String) -> Int {
    var count = 0
    for char in s {
        if char != char.whitespace {
            count += 1
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// 8. Write a function that takes a string
if char == char.uppercase { // value of type 'Character' has no member 'uppercase'
if char == char.lowercase { // value of type 'Character' has no member 'lowercase'
if char == char.digit { // value of type 'Character' has no member 'digit'
if char == char.whitespace { // value of type 'Character' has no member 'whitespace'
if char != char.whitespace { // value of type 'Character' has no member 'whitespace'

func vowelsCount(s: String) -> Int {
    var count = 0
    for char in s {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}

func lengthOfString(s: String) -> Int {
    return s.count
}

func numberOfWords(s: String) -> Int {
    return s.split(separator: " ").count
}

func numberOfVowels(s: String) -> Int {
    var count = 0
    for char in s {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}

func numberOfConsonants(s: String) -> Int {
    var count = 0
    for char in s {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            continue
        }
        count += 1
    }
    return count
}

func numberOfUppercaseLetters(s: String) -> Int {
    var count = 0
    for char in s {
        if char == char.uppercase {
            count += 1
        }
    }
    return count
}

func numberOfLowercaseLetters(s: String) -> Int {
    var count = 0
    for char in s {
        if char == char.lowercase {
            count += 1
        }
    }
    return count
}
```swift
// Write a function vowels_count which takes a string representing
// a word as input and returns the number of vowels in the string.
// Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a
// vowel, but only when it is at the end of the given word.
// Example:
// vowelsCount(s: "abcde") == 2
// vowelsCount(s: "ACEDY") == 3
func vowelsCount(s: String) -> Int {
    var count = 0
    for char in s {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// 1. Write a function that takes a string as input and returns the number of
// characters in the string.
// Example:
// lengthOfString(s: "Hello") == 5
// lengthOfString(s: "") == 0
// lengthOfString(s: "a") == 1
func lengthOfString(s: String) -> Int {
    return s.count
}

// 2. Write a function that takes a string as input and returns the number of
// words in the string.
// Example:
// numberOfWords(s: "Hello world") == 2
// numberOfWords(s: "") == 0
// numberOfWords(s: "a") == 1
func numberOfWords(s: String) -> Int {
    return s.split(separator: " ").count
}

// 3. Write a function that takes a string as input and returns the number of
// vowels in the string.
// Example:
// numberOfVowels(s: "Hello world") == 3
// numberOfVowels(s: "") == 0
// numberOfVowels(s: "a") == 1
func numberOfVowels(s: String) -> Int {
    var count = 0
    for char in s {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}

// 4. Write a function that takes a string as input and returns the number of
// consonants in the string.
// Example:
// numberOfConsonants(s: "Hello world") == 7
// numberOfConsonants(s: "") == 0
// numberOfConsonants(s: "a") == 0
func numberOfConsonants(s: String) -> Int {
    var count = 0
    for char in s {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            continue
        }
        count += 1
    }
    return count
}

// 5. Write a function that takes a string as input and returns the number of
// uppercase letters in the string.
// Example:
// numberOfUppercaseLetters(s: "Hello world") == 2
// numberOfUppercaseLetters(s: "") == 0
// numberOfUppercaseLetters(s: "a") == 0
func numberOfUppercaseLetters(s: String) -> Int {
    var count = 0
    for char in s {
        if char == char.uppercase {
            count += 1
        }
    }
    return count
}

// 6. Write a function that takes a string as input and returns the number of
// lowercase letters in the string.
// Example:
// numberOfLowercaseLetters(s: "Hello world") == 5
// numberOfLowercaseLetters(s: "") == 0
// numberOfLowercaseLetters(s: "a") == 1
func numberOfLowercaseLetters(s: String) -> Int {
    var count = 0
    for char in s {
        if char == char.lowercase {
            count += 1
        }
    }
    return count
}

// 7. Write a function that takes a string as input and returns the number of
// digits in the string.
// Example:
// numberOfDigits(s: "
if char == char.uppercase { // value of type 'Character' has no member 'uppercase'
if char == char.lowercase { // value of type 'Character' has no member 'lowercase'

func vowelsCount(s: String) -> Int {
    let vowels = "aeiouy"
    var count = 0
    for char in s {
        if vowels.contains(char) {
            count += 1
        }
    }
    return count
}

func removeSpaces(s: String) -> String {
    return s.trimmingCharacters(in: .whitespace)
}

func removeVowels(s: String) -> String {
    let vowels = "aeiouy"
    var result = ""
    for char in s {
        if !vowels.contains(char) {
            result += char
        }
    }
    return result
}

func removeVowelsMiddle(s: String) -> String {
    let vowels = "aeiouy"
    var result = ""
    var middle = false
    for char in s {
        if !vowels.contains(char) {
            result += char
            middle = true
        } else if (middle) {
            result += char
        }
    }
    return result
}
```swift
// Write a function vowels_count which takes a string representing
// a word as input and returns the number of vowels in the string.
// Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a
// vowel, but only when it is at the end of the given word.
// Example:
// vowelsCount(s: "abcde") == 2
// vowelsCount(s: "ACEDY") == 3
func vowelsCount(s: String) -> Int {
    let vowels = "aeiouy"
    var count = 0
    for char in s {
        if vowels.contains(char) {
            count += 1
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// 1.1.2
// Write a function that takes a string as input and returns the string
// with all the spaces removed.
// Example:
// removeSpaces(s: "Hello, world!") == "Hello,world!"
func removeSpaces(s: String) -> String {
    return s.trimmingCharacters(in: .whitespace)
}

// -----------------------------------------------------------------------------
// 1.1.3
// Write a function that takes a string as input and returns the string
// with all the vowels removed.
// Example:
// removeVowels(s: "Hello, world!") == "Hll, wrld!"
func removeVowels(s: String) -> String {
    let vowels = "aeiouy"
    var result = ""
    for char in s {
        if !vowels.contains(char) {
            result += char
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.1.4
// Write a function that takes a string as input and returns the string
// with all the vowels removed, but with the vowels in the middle of the
// string intact.
// Example:
// removeVowelsMiddle(s: "Hello, world!") == "Hll, wrld!"
func removeVowelsMiddle(s: String) -> String {
    let vowels = "aeiouy"
    var result = ""
    var middle = false
    for char in s {
        if !vowels.contains(char) {
            result += char
            middle = true
        } else if (middle) {
            result += char
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.1.5
// Write a function that takes a string as input and returns the string
// with all the vowels removed, but with the vowels in the middle of the
// string intact.
// Example:
// removeVowelsMiddle(s: "Hello, world!") == "Hll, wrld!"
func removeVowelsMiddle(s: String) -> String {
    let vowels = "aeiouy"
    var result = ""
    var middle = false
    for char in s {
        if !vowels.contains(char) {
            result += char
            middle = true
        } else if (middle) {
            result += char
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.1.6
// Write a function that takes a string as input and returns the string
// with all the vowels removed, but with the vowels in the middle of the
// string intact.
// Example:
// removeVowelsMiddle(s: "Hello, world!") == "Hll, wrld!"
func removeVowelsMiddle(s: String) -> String {
    let vowels = "aeiouy"
    var result = ""
    var middle = false
    for char in s {
        if !vowels.contains(char) {
            result += char
            middle = true
        } else if (middle) {
            result += char
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.1.7
// Write a function that takes a string as input and returns the string
// with all the vowels removed, but with the vowels in the middle of the
// string
return s.trimmingCharacters(in: .whitespace) // type 'CharacterSet' has no member 'whitespace'
result += char // cannot convert value of type 'Character' to expected argument type 'String'
result += char // cannot convert value of type 'Character' to expected argument type 'String'
result += char // cannot convert value of type 'Character' to expected argument type 'String'

func vowelsCount(s: String) -> Int {
    var count = 0
    for char in s {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}
```swift
// Write a function vowels_count which takes a string representing
// a word as input and returns the number of vowels in the string.
// Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a
// vowel, but only when it is at the end of the given word.
// Example:
// vowelsCount(s: "abcde") == 2
// vowelsCount(s: "ACEDY") == 3
func vowelsCount(s: String) -> Int {
    var count = 0
    for char in s {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// 1. Write a function that takes a string as input and returns the number of vowels in the string.
// Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a vowel, but only when it is at the end of the given word.
// Example:
// vowelsCount(s: "abcde") == 2
// vowelsCount(s: "ACEDY") == 3

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// 1. Write a function that takes a string as input and returns the number of vowels in the string.
// Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a vowel, but only when it is at the end of the given word.
// Example:
// vowelsCount(s: "abcde") == 2
// vowelsCount(s: "ACEDY") == 3

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// 1. Write a function that takes a string as input and returns the number of vowels in the string.
// Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a vowel, but only when it is at the end of the given word.
// Example:
// vowelsCount(s: "abcde") == 2
// vowelsCount(s: "ACEDY") == 3

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// 1. Write a function that takes a string as input and returns the number of vowels in the string.
// Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a vowel, but only when it is at the end of the given word.
// Example:
// vowelsCount(s:
 // XCTAssertTrue failed

func vowelsCount(s: String) -> Int {
    var count = 0
    for char in s {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}
```swift
// Write a function vowels_count which takes a string representing
// a word as input and returns the number of vowels in the string.
// Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a
// vowel, but only when it is at the end of the given word.
// Example:
// vowelsCount(s: "abcde") == 2
// vowelsCount(s: "ACEDY") == 3
func vowelsCount(s: String) -> Int {
    var count = 0
    for char in s {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // XCTAssertTrue failed

func vowelsCount(s: String) -> Int {
    var count = 0
    for char in s {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}
```swift
// Write a function vowels_count which takes a string representing
// a word as input and returns the number of vowels in the string.
// Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a
// vowel, but only when it is at the end of the given word.
// Example:
// vowelsCount(s: "abcde") == 2
// vowelsCount(s: "ACEDY") == 3
func vowelsCount(s: String) -> Int {
    var count = 0
    for char in s {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// ---------------------------------------------------------------------------
 // XCTAssertTrue failed

func vowelsCount(s: String) -> Int {
    var vowels = 0
    for char in s {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            vowels += 1
        }
    }
    return vowels
}
```swift
// Write a function vowels_count which takes a string representing
// a word as input and returns the number of vowels in the string.
// Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a
// vowel, but only when it is at the end of the given word.
// Example:
// vowelsCount(s: "abcde") == 2
// vowelsCount(s: "ACEDY") == 3
func vowelsCount(s: String) -> Int {
    var vowels = 0
    for char in s {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            vowels += 1
        }
    }
    return vowels
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // XCTAssertTrue failed

func vowelsCount(s: String) -> Int {
    let vowels = "aeiou"
    var count = 0
    for char in s {
        if vowels.contains(char) {
            count += 1
        }
    }
    return count
}
```swift
// Write a function vowels_count which takes a string representing
// a word as input and returns the number of vowels in the string.
// Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a
// vowel, but only when it is at the end of the given word.
// Example:
// vowelsCount(s: "abcde") == 2
// vowelsCount(s: "ACEDY") == 3
func vowelsCount(s: String) -> Int {
    let vowels = "aeiou"
    var count = 0
    for char in s {
        if vowels.contains(char) {
            count += 1
        }
    }
    return count
}

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ------------------
 // XCTAssertTrue failed

func vowelsCount(s: String) -> Int {
    var count = 0
    for char in s {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}
```swift
// Write a function vowels_count which takes a string representing
// a word as input and returns the number of vowels in the string.
// Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a
// vowel, but only when it is at the end of the given word.
// Example:
// vowelsCount(s: "abcde") == 2
// vowelsCount(s: "ACEDY") == 3
func vowelsCount(s: String) -> Int {
    var count = 0
    for char in s {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------

// 2. Write a function that takes a string representing a word and returns
// the number of vowels in the string. Vowels in this case are 'a', 'e',
// 'i', 'o', 'u'. Here, 'y' is also a vowel, but only when it is at the
// end of the given word.
// Example:
// vowelsCount(s: "abcde") == 2
// vowelsCount(s: "ACEDY") == 3
func vowelsCount(s: String) -> Int {
    var count = 0
    for char in s {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------

// 3. Write a function that takes a string representing a word and returns
// the number of vowels in the string. Vowels in this case are 'a', 'e',
// 'i', 'o', 'u'. Here, 'y' is also a vowel, but only when it is at the
// end of the given word.
// Example:
// vowelsCount(s: "abcde") == 2
// vowelsCount(s: "ACEDY") == 3
func vowelsCount(s: String) -> Int {
    var count = 0
    for char in s {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------

// 4. Write a function that takes a string representing a word and returns
// the number of vowels in the string. Vowels in this case are 'a', 'e',
// 'i', 'o', 'u'. Here, 'y' is also a vowel, but only when it is at the
// end of the given word.
// Example:
// vowelsCount(s: "abcde") == 2
// vowelsCount(s: "ACEDY") == 3
func vowelsCount(s: String) -> Int {
    var count = 0
    for char in s {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 1
        }
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------

// 5. Write a function that takes a string representing a word and returns
// the number of vowels in the string. Vowels in this case are 'a', 'e',
// 'i', 'o', 'u'. Here, 'y' is also a vowel, but only when it is at the
// end of the given word.
// Example:
// vowelsCount(s: "abcde") == 2
// vowelsCount(s: "ACEDY") == 3
func vowelsCount(s: String) -> Int {
    var count = 0
    for char in s {
        if char == "a" || char == "e" || char == "i" || char == "o" || char == "u" {
            count += 
 // XCTAssertTrue failed

func vowelsCount(s: String) -> Int {
    var count = 0
    for char in s {
        switch char {
        case "a", "e", "i", "o", "u":
            count += 1
        case "y":
            if s.last == "y" {
                count += 1
            }
        default:
            continue
        }
    }
    return count
}
```swift
// Write a function vowels_count which takes a string representing
// a word as input and returns the number of vowels in the string.
// Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a
// vowel, but only when it is at the end of the given word.
// Example:
// vowelsCount(s: "abcde") == 2
// vowelsCount(s: "ACEDY") == 3
func vowelsCount(s: String) -> Int {
    var count = 0
    for char in s {
        switch char {
        case "a", "e", "i", "o", "u":
            count += 1
        case "y":
            if s.last == "y" {
                count += 1
            }
        default:
            continue
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ---------------------------------------------------------
 // XCTAssertTrue failed

func circularShift(x: Int, shift: Int) -> String {
    let digits = String(x).split(separator: "").map(String.init)
    let shiftCount = shift % digits.count
    let shifted = digits.dropLast(shiftCount).concat(digits.prefix(shiftCount))
    return String(shifted)
}

func reverseString(s: String) -> String {
    return String(s.reversed())
}

func twoSum(nums: [Int], target: Int) -> [Int] {
    var result = [Int]()
    for i in 0..<nums.count {
        for j in i+1..<nums.count {
            if nums[i] + nums[j] == target {
                result = [i, j]
                break
            }
        }
    }
    return result
}

func countElements(nums: [Int]) -> Int {
    var result = 0
    var min = nums[0]
    var max = nums[0]
    for num in nums {
        if num < min {
            min = num
        }
        if num > max {
            max = num
        }
    }
    for num in nums {
        if num > min && num < max {
            result += 1
        }
    }
    return result
}
```swift
// Circular shift the digits of the integer x, shift the digits right by shift
// and return the result as a string.
// If shift > number of digits, return digits reversed.
// circularShift(x: 12, shift: 1) == "21"
// circularShift(x: 12, shift: 2) == "12"
func circularShift(x: Int, shift: Int) -> String {
    let digits = String(x).split(separator: "").map(String.init)
    let shiftCount = shift % digits.count
    let shifted = digits.dropLast(shiftCount).concat(digits.prefix(shiftCount))
    return String(shifted)
}

// 12.10.2022
// 1. Write a function that takes a string as input and returns the string reversed.
// reverseString("hello") == "olleh"
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// 12.10.2022
// 1. Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
// You may assume that each input would have exactly one solution, and you may not use the same element twice.
// You can return the answer in any order.
// twoSum(nums: [2,7,11,15], target: 9) == [0,1]
func twoSum(nums: [Int], target: Int) -> [Int] {
    var result = [Int]()
    for i in 0..<nums.count {
        for j in i+1..<nums.count {
            if nums[i] + nums[j] == target {
                result = [i, j]
                break
            }
        }
    }
    return result
}

// 12.10.2022
// 1. Given an integer array nums, return the number of elements that have both a strictly smaller and a strictly greater element appear in nums.
// countElements(nums: [11,7,2,15]) == 2
func countElements(nums: [Int]) -> Int {
    var result = 0
    var min = nums[0]
    var max = nums[0]
    for num in nums {
        if num < min {
            min = num
        }
        if num > max {
            max = num
        }
    }
    for num in nums {
        if num > min && num < max {
            result += 1
        }
    }
    return result
}

// 12.10.2022
// 1. Given an integer array nums, return the number of elements that have both a strictly smaller and a strictly greater element appear in nums.
// countElements(nums: [11,7,2,15]) == 2
func countElements(nums: [Int]) -> Int {
    var result = 0
    var min = nums[0]
    var max = nums[0]
    for num in nums {
        if num < min {
            min = num
        }
        if num > max {
            max = num
        }
    }
    for num in nums {
        if num > min && num < max {
            result += 1
        }
    }
    return result
}

// 12.10.2022
// 1. Given an integer array nums, return the number of elements that have both a strictly smaller and a strictly greater element appear in nums.
// countElements(nums: [11,7,2,15]) == 2
func countElements(nums: [Int]) -> Int {
    var result = 0
    var min = nums[0]
    var max = nums[0]
    for num in nums {
        if num < min {
            min = num
        }
        if num > max {
            max = num
        }
    }
    for num in nums {
        if num > min && num < max {
            result += 1
        }
    }
    return result
}

// 12.10.2022
// 1. Given an integer array nums, return the number of elements that have both a strictly smaller and a strictly greater element appear in nums.
// countElements(nums: [11,7,2,15]) == 2
func countElements(nums: [Int]) -> Int {
    var result = 0
    var min = nums[0]
    
let shifted = digits.dropLast(shiftCount).concat(digits.prefix(shiftCount)) // reference to member 'concat' cannot be resolved without a contextual type

func circularShift(x: Int, shift: Int) -> String {
    let s = String(x)
    let n = s.count
    if shift >= n {
        return s.reversed().join()
    }
    let i = n - shift
    return s.substring(from: i) + s.substring(0, i)
}

func longestPalindrome(s: String) -> String {
    var max = ""
    for i in 0..<s.count {
        for j in i..<s.count {
            let sub = s.substring(from: i, length: j - i + 1)
            if sub.isPalindrome() {
                if sub.count > max.count {
                    max = sub
                }
            }
        }
    }
    return max
}
```swift
// Circular shift the digits of the integer x, shift the digits right by shift
// and return the result as a string.
// If shift > number of digits, return digits reversed.
// circularShift(x: 12, shift: 1) == "21"
// circularShift(x: 12, shift: 2) == "12"
func circularShift(x: Int, shift: Int) -> String {
    let s = String(x)
    let n = s.count
    if shift >= n {
        return s.reversed().join()
    }
    let i = n - shift
    return s.substring(from: i) + s.substring(0, i)
}

// 2.
// Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.
// Example 1:
// Input: "babad"
// Output: "bab"
// Note: "aba" is also a valid answer.
// Example 2:
// Input: "cbbd"
// Output: "bb"
func longestPalindrome(s: String) -> String {
    var max = ""
    for i in 0..<s.count {
        for j in i..<s.count {
            let sub = s.substring(from: i, length: j - i + 1)
            if sub.isPalindrome() {
                if sub.count > max.count {
                    max = sub
                }
            }
        }
    }
    return max
}

// 3.
// Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.
// Example 1:
// Input: "babad"
// Output: "bab"
// Note: "aba" is also a valid answer.
// Example 2:
// Input: "cbbd"
// Output: "bb"
func longestPalindrome(s: String) -> String {
    var max = ""
    for i in 0..<s.count {
        for j in i..<s.count {
            let sub = s.substring(from: i, length: j - i + 1)
            if sub.isPalindrome() {
                if sub.count > max.count {
                    max = sub
                }
            }
        }
    }
    return max
}

// 4.
// Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.
// Example 1:
// Input: "babad"
// Output: "bab"
// Note: "aba" is also a valid answer.
// Example 2:
// Input: "cbbd"
// Output: "bb"
func longestPalindrome(s: String) -> String {
    var max = ""
    for i in 0..<s.count {
        for j in i..<s.count {
            let sub = s.substring(from: i, length: j - i + 1)
            if sub.isPalindrome() {
                if sub.count > max.count {
                    max = sub
                }
            }
        }
    }
    return max
}

// 5.
// Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.
// Example 1:
// Input: "babad"
// Output: "bab"
// Note: "aba" is also a valid answer.
// Example 2:
// Input: "cbbd"
// Output: "bb"
func longestPalindrome(s: String) -> String {
    var max = ""
    for i in 0..<s.count {
        for j in i..<s.count {
            let sub = s.substring(from: i, length: j - i + 1)
            if sub.isPalindrome() {
                if sub.count > max.count {
                    max = sub
                }
            }
        }
    }
    return max
}

// 6.
// Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.
// Example 1:
// Input: "babad"
// Output: "bab"
// Note: "aba" is also a valid answer.
// Example 2:
// Input: "cbbd"
// Output: "bb"
func longestPalindrome(
return s.reversed().join() // reference to member 'join' cannot be resolved without a contextual type
return s.substring(from: i) + s.substring(0, i) // no exact matches in call to instance method 'substring'
return s.substring(from: i) + s.substring(0, i) // cannot convert value of type 'Int' to expected argument type 'String.Index'
let sub = s.substring(from: i, length: j - i + 1) // extra argument 'length' in call
let sub = s.substring(from: i, length: j - i + 1) // cannot convert value of type 'Int' to expected argument type 'String.Index'

func circularShift(x: Int, shift: Int) -> String {
    let str = String(x)
    let len = str.count
    let shiftLen = shift % len
    let result = str.suffix(len - shiftLen) + str.prefix(shiftLen)
    return result
}

func repeatString(str: String, n: Int) -> String {
    var result = ""
    for i in 0..<n {
        result += str
    }
    return result
}

func toUpperCase(str: String) -> String {
    return str.uppercaseString
}

func toLowerCase(str: String) -> String {
    return str.lowercaseString
}

func removeVowels(str: String) -> String {
    var result = ""
    for char in str {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

func removeConsonants(str: String) -> String {
    var result = ""
    for char in str {
        if isConsonant(char) {
            result += char
        }
    }
    return result
}
```swift
// Circular shift the digits of the integer x, shift the digits right by shift
// and return the result as a string.
// If shift > number of digits, return digits reversed.
// circularShift(x: 12, shift: 1) == "21"
// circularShift(x: 12, shift: 2) == "12"
func circularShift(x: Int, shift: Int) -> String {
    let str = String(x)
    let len = str.count
    let shiftLen = shift % len
    let result = str.suffix(len - shiftLen) + str.prefix(shiftLen)
    return result
}

// 2. Given a string, return the string concatenated with itself n times where n is the length of the string.
// repeatString("Hello", 3) == "HelloHelloHello"
func repeatString(str: String, n: Int) -> String {
    var result = ""
    for i in 0..<n {
        result += str
    }
    return result
}

// 3. Given a string, return the string with all the letters converted to uppercase.
// toUpperCase("Hello") == "HELLO"
func toUpperCase(str: String) -> String {
    return str.uppercaseString
}

// 4. Given a string, return the string with all the letters converted to lowercase.
// toLowerCase("Hello") == "hello"
func toLowerCase(str: String) -> String {
    return str.lowercaseString
}

// 5. Given a string, return the string with all the vowels removed.
// removeVowels("Hello") == "Hll"
func removeVowels(str: String) -> String {
    var result = ""
    for char in str {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// 6. Given a string, return the string with all the consonants removed.
// removeConsonants("Hello") == "Hll"
func removeConsonants(str: String) -> String {
    var result = ""
    for char in str {
        if isConsonant(char) {
            result += char
        }
    }
    return result
}

// 7. Given a string, return the string with all the vowels removed.
// removeVowels("Hello") == "Hll"
func removeVowels(str: String) -> String {
    var result = ""
    for char in str {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// 8. Given a string, return the string with all the consonants removed.
// removeConsonants("Hello") == "Hll"
func removeConsonants(str: String) -> String {
    var result = ""
    for char in str {
        if isConsonant(char) {
            result += char
        }
    }
    return result
}

// 9. Given a string, return the string with all the vowels removed.
// removeVowels("Hello") == "Hll"
func removeVowels(str: String) -> String {
    var result = ""
    for char in str {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// 10. Given a string, return the string with all the consonants removed.
// removeConsonants("Hello") == "Hll"
func removeConsonants(str: String) -> String {
    var result = ""
    for char in str {
        if isConsonant(char) {
            result += char
        }
    }
    return result
}

// 11. Given a string, return the string with all the vowels removed.
// removeVowels("Hello") == "Hll"
func removeVowels(str: String) -> String {
    var result = ""
    for char in str {
        if !isVowel(char) {
            result += char
        }
    }
    return result
}

// 12. Given a string, return the string with all the consonants removed.
// removeConsonants("Hello") == "Hll"
func removeConsonants(str: String) -> String {
    var result = ""
    for char in str {
        if isConsonant(char) {
            result += char
        }
    }
    return result
}

// 
return result // cannot convert return expression of type 'String.SubSequence' (aka 'Substring') to return type 'String'
for i in 0..<n { // immutable value 'i' was never used; consider replacing with '_' or removing it
return str.uppercaseString // value of type 'String' has no member 'uppercaseString'
return str.lowercaseString // value of type 'String' has no member 'lowercaseString'
if !isVowel(char) { // cannot find 'isVowel' in scope
result += char // cannot convert value of type 'Character' to expected argument type 'String'
if isConsonant(char) { // cannot find 'isConsonant' in scope
result += char // cannot convert value of type 'Character' to expected argument type 'String'

func circularShift(x: Int, shift: Int) -> String {
    let digits = String(x)
    let length = digits.lengthOfLastSubstring()
    let shiftAmount = shift % length
    let shifted = String(digits.prefix(length - shiftAmount)) + String(digits.suffix(shiftAmount))
    return shifted
}
```swift
// Circular shift the digits of the integer x, shift the digits right by shift
// and return the result as a string.
// If shift > number of digits, return digits reversed.
// circularShift(x: 12, shift: 1) == "21"
// circularShift(x: 12, shift: 2) == "12"
func circularShift(x: Int, shift: Int) -> String {
    let digits = String(x)
    let length = digits.lengthOfLastSubstring()
    let shiftAmount = shift % length
    let shifted = String(digits.prefix(length - shiftAmount)) + String(digits.suffix(shiftAmount))
    return shifted
}

// 2.
// Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
// You may assume that each input would have exactly one solution, and you may not use the same element twice.
// You can return the answer in any order.
// Example 1:
// Input: nums = [2,7,11,15], target = 9
// Output: [0,1]
// Output: Because nums[0] + nums[1] == 9, we return [0, 1].
// Example 2:
// Input: nums = [3,2,4], target = 6
// Output: [1,2]
// Example 3:
// Input: nums = [3,3], target = 6
// Output: [0,1]
// Constraints:
// 2 <= nums.length <= 104
// -109 <= nums[i] <= 109
// -109 <= target <= 109
// Only one valid answer exists.
// Follow-up: Can you come up with an algorithm that is less than O(n2) time complexity?

// 1.
// Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
// You may assume that each input would have exactly one solution, and you may not use the same element twice.
// You can return the answer in any order.
// Example 1:
// Input: nums = [2,7,11,15], target = 9
// Output: [0,1]
// Output: Because nums[0] + nums[1] == 9, we return [0, 1].
// Example 2:
// Input: nums = [3,2,4], target = 6
// Output: [1,2]
// Example 3:
// Input: nums = [3,3], target = 6
// Output: [0,1]
// Constraints:
// 2 <= nums.length <= 104
// -109 <= nums[i] <= 109
// -109 <= target <= 109
// Only one valid answer exists.
// Follow-up: Can you come up with an algorithm that is less than O(n2) time complexity?

// 1.
// Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
// You may assume that each input would have exactly one solution, and you may not use the same element twice.
// You can return the answer in any order.
// Example 1:
// Input: nums = [2,7,11,15], target = 9
// Output: [0,1]
// Output: Because nums[0] + nums[1] == 9, we return [0, 1].
// Example 2:
// Input: nums = [3,2,4], target = 6
// Output: [1,2]
// Example 3:
// Input: nums = [3,3], target = 6
// Output: [0,1]
// Constraints:
// 2 <= nums.length <= 104
// -109 <= nums[i] <= 109
// -109 <= target <= 109
// Only one valid answer exists.
// Follow-up: Can you come up with an algorithm that is less than O(n2) time complexity?

// 1.
// Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
// You may assume that each input would have exactly one solution, and you may not use the same element twice.
// You can return the answer in any order.
// Example 1:
// Input: nums = [2,7,11,15], target = 9
// Output: [0,1
let length = digits.lengthOfLastSubstring() // value of type 'String' has no member 'lengthOfLastSubstring'

func circularShift(x: Int, shift: Int) -> String {
    let digits = String(x).map(String.init)
    let n = digits.count
    let shiftMod = shift % n
    let result = digits.dropFirst(n - shiftMod) + digits.dropFirst(shiftMod)
    return result
}

func reverseString(s: String) -> String {
    return String(s.reversed())
}

func removeEvenChars(s: String) -> String {
    return String(s.map { $0.isAsciiLetter ? "" : $0 })
}

func removeOddChars(s: String) -> String {
    return String(s.map { $0.isAsciiLetter ? $0 : "" })
}
```swift
// Circular shift the digits of the integer x, shift the digits right by shift
// and return the result as a string.
// If shift > number of digits, return digits reversed.
// circularShift(x: 12, shift: 1) == "21"
// circularShift(x: 12, shift: 2) == "12"
func circularShift(x: Int, shift: Int) -> String {
    let digits = String(x).map(String.init)
    let n = digits.count
    let shiftMod = shift % n
    let result = digits.dropFirst(n - shiftMod) + digits.dropFirst(shiftMod)
    return result
}

// 2.
// Given a string, return the string reversed.
// reverseString("hello") == "olleh"
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// 3.
// Given a string, return the string with all the even characters removed.
// removeEvenChars("hello") == "hlo"
func removeEvenChars(s: String) -> String {
    return String(s.map { $0.isAsciiLetter ? "" : $0 })
}

// 4.
// Given a string, return the string with all the odd characters removed.
// removeOddChars("hello") == "hllo"
func removeOddChars(s: String) -> String {
    return String(s.map { $0.isAsciiLetter ? $0 : "" })
}

// 5.
// Given a string, return the string with all the even characters removed.
// removeEvenChars("hello") == "hlo"
func removeEvenChars(s: String) -> String {
    return String(s.map { $0.isAsciiLetter ? "" : $0 })
}

// 6.
// Given a string, return the string with all the odd characters removed.
// removeOddChars("hello") == "hllo"
func removeOddChars(s: String) -> String {
    return String(s.map { $0.isAsciiLetter ? $0 : "" })
}

// 7.
// Given a string, return the string with all the even characters removed.
// removeEvenChars("hello") == "hlo"
func removeEvenChars(s: String) -> String {
    return String(s.map { $0.isAsciiLetter ? "" : $0 })
}

// 8.
// Given a string, return the string with all the odd characters removed.
// removeOddChars("hello") == "hllo"
func removeOddChars(s: String) -> String {
    return String(s.map { $0.isAsciiLetter ? $0 : "" })
}

// 9.
// Given a string, return the string with all the even characters removed.
// removeEvenChars("hello") == "hlo"
func removeEvenChars(s: String) -> String {
    return String(s.map { $0.isAsciiLetter ? "" : $0 })
}

// 10.
// Given a string, return the string with all the odd characters removed.
// removeOddChars("hello") == "hllo"
func removeOddChars(s: String) -> String {
    return String(s.map { $0.isAsciiLetter ? $0 : "" })
}

// 11.
// Given a string, return the string with all the even characters removed.
// removeEvenChars("hello") == "hlo"
func removeEvenChars(s: String) -> String {
    return String(s.map { $0.isAsciiLetter ? "" : $0 })
}

// 12.
// Given a string, return the string with all the odd characters removed.
// removeOddChars("hello") == "hllo"
func removeOddChars(s: String) -> String {
    return String(s.map { $0.isAsciiLetter ? $0 : "" })
}

// 13.
// Given a string, return the string with all the even characters removed.
// removeEvenChars("hello") == "hlo"
func removeEvenChars(s: String) -> String {
    return String(s.map { $0.isAsciiLetter ? "" : $0 })
}

// 14.
// Given a
return result // cannot convert return expression of type 'Array<String>.SubSequence' (aka 'ArraySlice<String>') to return type 'String'
return String(s.map { $0.isAsciiLetter ? "" : $0 }) // result values in '? :' expression have mismatching types 'String' and 'String.Element' (aka 'Character')
return String(s.map { $0.isAsciiLetter ? "" : $0 }) // value of type 'String.Element' (aka 'Character') has no member 'isAsciiLetter'
return String(s.map { $0.isAsciiLetter ? $0 : "" }) // value of type 'String.Element' (aka 'Character') has no member 'isAsciiLetter'
return String(s.map { $0.isAsciiLetter ? $0 : "" }) // no exact matches in call to initializer
return String(s.map { $0.isAsciiLetter ? $0 : "" }) // result values in '? :' expression have mismatching types 'String.Element' (aka 'Character') and 'String'

func circularShift(x: Int, shift: Int) -> String {
    let digits = String(x).map(Character.init)
    let shiftCount = digits.count
    let shiftMod = shift % shiftCount
    let shiftedDigits = digits.dropFirst(shiftCount - shiftMod)
    let shiftedString = String(shiftedDigits)
    return shiftedString
}

func firstTwo(s: String) -> String {
    if s.count < 2 {
        return s
    }
    return s.prefix(2)
}

func stringTimes(s: String, n: Int) -> String {
    var result = ""
    for _ in 0..<n {
        result += s
    }
    return result
}

func frontTimes(s: String, n: Int) -> String {
    let front = s.prefix(min(3, s.count))
    var result = ""
    for _ in 0..<n {
        result += front
    }
    return result
}

func equalIsNot(s: String) -> Bool {
    let isCount = s.count(for: "is")
    let notCount = s.count(for: "not")
    return isCount == notCount
}

func stringBits(s: String) -> String {
    var result = ""
    for i in 0..<s.count {
        if i % 2 == 0 {
            result += s[i]
        }
    }
    return result
}

func stringSplosion(s: String) -> String {
    var result = ""
    for i in 0..<s.count {
        result += s[0..<i+1]
    }
    return result
}
```swift
// Circular shift the digits of the integer x, shift the digits right by shift
// and return the result as a string.
// If shift > number of digits, return digits reversed.
// circularShift(x: 12, shift: 1) == "21"
// circularShift(x: 12, shift: 2) == "12"
func circularShift(x: Int, shift: Int) -> String {
    let digits = String(x).map(Character.init)
    let shiftCount = digits.count
    let shiftMod = shift % shiftCount
    let shiftedDigits = digits.dropFirst(shiftCount - shiftMod)
    let shiftedString = String(shiftedDigits)
    return shiftedString
}

// 2.
// Given a string s, return the string made of its first two chars, so if the
// string length is less than 2, return whatever there is, so "X" and "" both
// return "X".
// firstTwo("Hello") == "He"
// firstTwo("abcdefg") == "ab"
func firstTwo(s: String) -> String {
    if s.count < 2 {
        return s
    }
    return s.prefix(2)
}

// 3.
// Given a string and a non-negative int n, return a larger string that is n
// copies of the original string.
// stringTimes("Hi", 2) == "HiHi"
// stringTimes("Hi", 3) == "HiHiHi"
// stringTimes("Hi", 1) == "Hi"
func stringTimes(s: String, n: Int) -> String {
    var result = ""
    for _ in 0..<n {
        result += s
    }
    return result
}

// 4.
// Given a string and a non-negative int n, we'll say that the front of the
// string is the first 3 chars, or whatever is there if the string is less than
// length 3. Return n copies of the front;
// frontTimes("Chocolate", 2) == "ChoCho"
// frontTimes("Chocolate", 3) == "ChoChoCho"
// frontTimes("Abc", 3) == "AbcAbcAbc"
func frontTimes(s: String, n: Int) -> String {
    let front = s.prefix(min(3, s.count))
    var result = ""
    for _ in 0..<n {
        result += front
    }
    return result
}

// 5.
// Given a string, return true if the number of appearances of "is" anywhere
// in the string is equal to the number of appearances of "not" anywhere in
// the string (case sensitive).
// equalIsNot("This is not") == true
// equalIsNot("This is notnot") == false
// equalIsNot("noisxxnotyynotxisi") == true
func equalIsNot(s: String) -> Bool {
    let isCount = s.count(for: "is")
    let notCount = s.count(for: "not")
    return isCount == notCount
}

// 6.
// Given a string, return a new string made of every other char starting with
// the first, so "Hello" yields "Hlo".
// stringBits("Hello") == "Hlo"
// stringBits("Hi") == "H"
// stringBits("Heeololeo") == "Hello"
func stringBits(s: String) -> String {
    var result = ""
    for i in 0..<s.count {
        if i % 2 == 0 {
            result += s[i]
        }
    }
    return result
}

// 7.
// Given a non-empty string like "Code" return a string like "CCoCodCode".
// stringSplosion("Code") == "CCoCodCode"
// stringSplosion("abc") == "aababc"
// stringSplosion("ab") == "aab"
func stringSplosion(s: String) -> String {
    var result = ""
    for i in 0..<s.count {
        result += s[0..<i+1]
    }
    return result
}

// 8.
// Given a string, return the count of the number of times that a substring
// length 2 appears in the string and also as the last 2 chars of the string,
// so "hixxxhi" yields 1 (we won't count the end
return s.prefix(2) // no 'prefix' candidates produce the expected contextual result type 'String'
let isCount = s.count(for: "is") // cannot call value of non-function type 'Int'
let notCount = s.count(for: "not") // cannot call value of non-function type 'Int'
result += s[i] // no exact matches in call to subscript
result += s[0..<i+1] // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.

func circularShift(x: Int, shift: Int) -> String {
    let digits = String(x).map { Int($0) }
    let shiftCount = shift % digits.count
    let shifted = digits.dropFirst(digits.count - shiftCount)
    let shifted2 = shifted.dropLast(shiftCount)
    return String(shifted2).joined(separator: "")
}

func largestPerimeter(nums: [Int]) -> Int {
    let sorted = nums.sorted(by: { $0 < $1 })
    for i in 0..<sorted.count - 2 {
        if sorted[i] + sorted[i + 1] > sorted[i + 2] {
            return sorted[i] + sorted[i + 1] + sorted[i + 2]
        }
    }
    return 0
}
```swift
// Circular shift the digits of the integer x, shift the digits right by shift
// and return the result as a string.
// If shift > number of digits, return digits reversed.
// circularShift(x: 12, shift: 1) == "21"
// circularShift(x: 12, shift: 2) == "12"
func circularShift(x: Int, shift: Int) -> String {
    let digits = String(x).map { Int($0) }
    let shiftCount = shift % digits.count
    let shifted = digits.dropFirst(digits.count - shiftCount)
    let shifted2 = shifted.dropLast(shiftCount)
    return String(shifted2).joined(separator: "")
}

// 2.
// Given an integer array nums, return the largest perimeter of a triangle with a non-zero area,
// formed from three of these lengths. If it is impossible to form any triangle of a non-zero area, return 0.
// largestPerimeter([2, 1, 2]) == 5
// largestPerimeter([1, 2, 1]) == 0
func largestPerimeter(nums: [Int]) -> Int {
    let sorted = nums.sorted(by: { $0 < $1 })
    for i in 0..<sorted.count - 2 {
        if sorted[i] + sorted[i + 1] > sorted[i + 2] {
            return sorted[i] + sorted[i + 1] + sorted[i + 2]
        }
    }
    return 0
}

// 3.
// Given an integer array nums, return the largest perimeter of a triangle with a non-zero area,
// formed from three of these lengths. If it is impossible to form any triangle of a non-zero area, return 0.
// largestPerimeter([2, 1, 2]) == 5
// largestPerimeter([1, 2, 1]) == 0
func largestPerimeter(nums: [Int]) -> Int {
    let sorted = nums.sorted(by: { $0 < $1 })
    for i in 0..<sorted.count - 2 {
        if sorted[i] + sorted[i + 1] > sorted[i + 2] {
            return sorted[i] + sorted[i + 1] + sorted[i + 2]
        }
    }
    return 0
}

// 4.
// Given an integer array nums, return the largest perimeter of a triangle with a non-zero area,
// formed from three of these lengths. If it is impossible to form any triangle of a non-zero area, return 0.
// largestPerimeter([2, 1, 2]) == 5
// largestPerimeter([1, 2, 1]) == 0
func largestPerimeter(nums: [Int]) -> Int {
    let sorted = nums.sorted(by: { $0 < $1 })
    for i in 0..<sorted.count - 2 {
        if sorted[i] + sorted[i + 1] > sorted[i + 2] {
            return sorted[i] + sorted[i + 1] + sorted[i + 2]
        }
    }
    return 0
}

// 5.
// Given an integer array nums, return the largest perimeter of a triangle with a non-zero area,
// formed from three of these lengths. If it is impossible to form any triangle of a non-zero area, return 0.
// largestPerimeter([2, 1, 2]) == 5
// largestPerimeter([1, 2, 1]) == 0
func largestPerimeter(nums: [Int]) -> Int {
    let sorted = nums.sorted(by: { $0 < $1 })
    for i in 0..<sorted.count - 2 {
        if sorted[i] + sorted[i + 1] > sorted[i + 2] {
            return sorted[i] + sorted[i + 1] + sorted[i + 2]
        }
    }
    return 0
}

// 6.
// Given an integer array nums, return the largest perimeter of a triangle with a non-zero area,
// formed from three of these lengths. If it is impossible to form any triangle of a non-zero area, return 0.
// largestPerimeter([2, 1, 2]) == 5
// largestPerimeter([1, 2, 1]) == 0
func largestPerimeter(nums: [Int]) -> Int {
    let sorted = nums.sorted(by: { $0 < $1 })
    
let digits = String(x).map { Int($0) } // no exact matches in call to initializer
let digits = String(x).map { Int($0) } // no exact matches in call to initializer
return String(shifted2).joined(separator: "") // referencing instance method 'joined(separator:)' on 'BidirectionalCollection' requires the types 'String.Element' (aka 'Character') and 'String' be equivalent

func circularShift(x: Int, shift: Int) -> String {
    let digits = String(x).count
    let shift = shift % digits
    return String(x).prefix(digits - shift) + String(x).suffix(shift)
}
```swift
// Circular shift the digits of the integer x, shift the digits right by shift
// and return the result as a string.
// If shift > number of digits, return digits reversed.
// circularShift(x: 12, shift: 1) == "21"
// circularShift(x: 12, shift: 2) == "12"
func circularShift(x: Int, shift: Int) -> String {
    let digits = String(x).count
    let shift = shift % digits
    return String(x).prefix(digits - shift) + String(x).suffix(shift)
}

// 2022-09-21-14-51-41
// 2022-09-21-14-52-10
// 2022-09-21-14-52-53
// 2022-09-21-14-53-11
// 2022-09-21-14-53-42
// 2022-09-21-14-54-22
// 2022-09-21-14-54-43
// 2022-09-21-14-55-11
// 2022-09-21-14-55-30
// 2022-09-21-14-55-43
// 2022-09-21-14-56-00
// 2022-09-21-14-56-11
// 2022-09-21-14-56-22
// 2022-09-21-14-56-30
// 2022-09-21-14-56-43
// 2022-09-21-14-57-00
// 2022-09-21-14-57-11
// 2022-09-21-14-57-22
// 2022-09-21-14-57-30
// 2022-09-21-14-57-43
// 2022-09-21-14-58-00
// 2022-09-21-14-58-11
// 2022-09-21-14-58-22
// 2022-09-21-14-58-30
// 2022-09-21-14-58-43
// 2022-09-21-14-59-00
// 2022-09-21-14-59-11
// 2022-09-21-14-59-22
// 2022-09-21-14-59-30
// 2022-09-21-14-59-43
// 2022-09-21-14-60-00
// 2022-09-21-14-60-11
// 2022-09-21-14-60-22
// 2022-09-21-14-60-30
// 2022-09-21-14-60-43
// 2022-09-21-14-61-00
// 2022-09-21-14-61-11
// 2022-09-21-14-61-22
// 2022-09-21-14-61-30
// 2022-09-21-14-61-43
// 2022-09-21-14-62-00
// 2022-09-21-14-62-11
// 2022-09-21-14-62-22
// 2022-09-21-14-62-30
// 2022-
return String(x).prefix(digits - shift) + String(x).suffix(shift) // cannot convert return expression of type 'String.SubSequence' (aka 'Substring') to return type 'String'

func circularShift(x: Int, shift: Int) -> String {
    let digits = String(x).split(separator: "").map { Int($0) }
    let shiftCount = shift % digits.count
    let shiftedDigits = digits.dropLast(shiftCount)
    let reversedShiftedDigits = shiftedDigits.reversed()
    return String(reversedShiftedDigits.joined(separator: ""))
}

func firstTwo(str: String) -> String {
    return str.prefix(min: 2)
}

func isNot(str: String) -> Bool {
    let isCount = str.count(for: "is")
    let notCount = str.count(for: "not")
    return isCount == notCount
}

func frontBack(str: String) -> String {
    return str.last() + str.subString(1, length: str.count - 2) + str.first()
}

func front3(str: String) -> String {
    return str.prefix(3) + str.prefix(3) + str.prefix(3)
}

func front23(str: String) -> String {
    return str.prefix(2) + str.suffix(2)
}
```swift
// Circular shift the digits of the integer x, shift the digits right by shift
// and return the result as a string.
// If shift > number of digits, return digits reversed.
// circularShift(x: 12, shift: 1) == "21"
// circularShift(x: 12, shift: 2) == "12"
func circularShift(x: Int, shift: Int) -> String {
    let digits = String(x).split(separator: "").map { Int($0) }
    let shiftCount = shift % digits.count
    let shiftedDigits = digits.dropLast(shiftCount)
    let reversedShiftedDigits = shiftedDigits.reversed()
    return String(reversedShiftedDigits.joined(separator: ""))
}

// -----------------------------------------------------------------------------
// 2.
// Given a string, return the string made of its first two chars, so the String
// "Hello" yields "He". If the string is shorter than length 2, return whatever
// there is, so "X" yields "X", and the empty string "" yields the empty string
// "".
// firstTwo("Hello") == "He"
// firstTwo("abcdefg") == "ab"
// firstTwo("ab") == "ab"
func firstTwo(str: String) -> String {
    return str.prefix(min: 2)
}

// -----------------------------------------------------------------------------
// 3.
// Given a string, return true if the number of appearances of "is" anywhere in
// the string is equal to the number of appearances of "not" anywhere in the
// string (case sensitive).
// isNot("not not is not") == true
// isNot("is is not not") == false
// isNot("is is not is") == false
func isNot(str: String) -> Bool {
    let isCount = str.count(for: "is")
    let notCount = str.count(for: "not")
    return isCount == notCount
}

// -----------------------------------------------------------------------------
// 4.
// Given a string, return a new string where the first and last chars have been
// exchanged.
// frontBack("code") == "eodc"
// frontBack("a") == "a"
// frontBack("ab") == "ba"
func frontBack(str: String) -> String {
    return str.last() + str.subString(1, length: str.count - 2) + str.first()
}

// -----------------------------------------------------------------------------
// 5.
// Given a string, return a new string where the first and last chars have been
// exchanged.
// front3("Java") == "JavJavJav"
// front3("Chocolate") == "ChoChoCho"
// front3("abc") == "abcabcabc"
func front3(str: String) -> String {
    return str.prefix(3) + str.prefix(3) + str.prefix(3)
}

// -----------------------------------------------------------------------------
// 6.
// Given a string, return a new string where the first and last chars have been
// exchanged.
// front23("Java") == "avJav"
// front23("Chocolate") == "ChoCho"
// front23("abc") == "abcabc"
func front23(str: String) -> String {
    return str.prefix(2) + str.suffix(2)
}

// -----------------------------------------------------------------------------
// 7.
// Given a string, return true if the number of appearances of "is" anywhere in
// the string is equal to the number of appearances of "not" anywhere in the
// string (case sensitive).
// mixStart("mix snacks") == true
// mixStart("pix snacks") == true
// mixStart("piz snacks") == false
// mixStart("pxiq snacks") == true
// mixStart("piq snacks") == false
// mixStart("pizx snacks") == false
// mixStart
return String(reversedShiftedDigits.joined(separator: "")) // no exact matches in call to instance method 'joined'
return str.prefix(min: 2) // no exact matches in call to instance method 'prefix'
return str.prefix(min: 2) // no 'prefix' candidates produce the expected contextual result type 'String'
let isCount = str.count(for: "is") // cannot call value of non-function type 'Int'
let notCount = str.count(for: "not") // cannot call value of non-function type 'Int'
return str.last() + str.subString(1, length: str.count - 2) + str.first() // cannot call value of non-function type 'String.Element?' (aka 'Optional<Character>')
return str.last() + str.subString(1, length: str.count - 2) + str.first() // cannot call value of non-function type 'String.Element?' (aka 'Optional<Character>')
return str.last() + str.subString(1, length: str.count - 2) + str.first() // value of type 'String' has no member 'subString'
return str.prefix(3) + str.prefix(3) + str.prefix(3) // cannot convert return expression of type 'String.SubSequence' (aka 'Substring') to return type 'String'
return str.prefix(2) + str.suffix(2) // cannot convert return expression of type 'String.SubSequence' (aka 'Substring') to return type 'String'

func circularShift(x: Int, shift: Int) -> String {
    let digits = String(x).characters
    let length = digits.count
    let shiftMod = shift % length
    let newDigits = digits.dropFirst(shiftMod)
    let newDigits2 = newDigits.dropLast(length - shiftMod)
    return String(newDigits2)
}

func firstTwo(s: String) -> String {
    return s.prefix(min(2, s.count))
}

func withoutEnd(s: String) -> String {
    return s[1..<s.count - 1]
}

func middleTwo(s: String) -> String {
    return s[s.count / 2 - 1..<s.count / 2 + 1]
}

func endsLy(s: String) -> Bool {
    return s.hasSuffix("ly")
}

func nTwice(s: String, n: Int) -> String {
    return s.prefix(n) + s.suffix(n)
}

func twoChar(s: String, index: Int) -> String {
    return s.prefix(min(2, s.count))
}
```swift
// Circular shift the digits of the integer x, shift the digits right by shift
// and return the result as a string.
// If shift > number of digits, return digits reversed.
// circularShift(x: 12, shift: 1) == "21"
// circularShift(x: 12, shift: 2) == "12"
func circularShift(x: Int, shift: Int) -> String {
    let digits = String(x).characters
    let length = digits.count
    let shiftMod = shift % length
    let newDigits = digits.dropFirst(shiftMod)
    let newDigits2 = newDigits.dropLast(length - shiftMod)
    return String(newDigits2)
}

// 2.
// Given a string, return the string made of its first two chars, so the String
// "Hello" yields "He". If the string is shorter than length 2, return whatever
// there is, so "X" yields "X", and the empty string "" yields the empty string
// "".
// firstTwo("Hello") == "He"
// firstTwo("abcdefg") == "ab"
// firstTwo("ab") == "ab"
func firstTwo(s: String) -> String {
    return s.prefix(min(2, s.count))
}

// 3.
// Given a string, return a version without the first and last char, so
// "Hello" yields "ell". The string length will be at least 2.
// withoutEnd("Hello") == "ell"
// withoutEnd("java") == "av"
// withoutEnd("coding") == "odin"
func withoutEnd(s: String) -> String {
    return s[1..<s.count - 1]
}

// 4.
// Given a string, return a string length 2 made of its first 2 chars. If the
// string length is less than 2, use '@' for the missing chars.
// firstTwo("Hello") == "He"
// firstTwo("abcdefg") == "ab"
// firstTwo("ab") == "ab"
func firstTwo(s: String) -> String {
    return s.prefix(min(2, s.count))
}

// 5.
// Given a string of even length, return a string made of the middle two chars,
// so the string "string" yields "ri". The string length will be at least 2.
// middleTwo("string") == "ri"
// middleTwo("code") == "od"
// middleTwo("Practice") == "ct"
func middleTwo(s: String) -> String {
    return s[s.count / 2 - 1..<s.count / 2 + 1]
}

// 6.
// Given a string, return true if it ends in "ly".
// endsLy("oddly") == true
// endsLy("y") == false
// endsLy("oddy") == false
func endsLy(s: String) -> Bool {
    return s.hasSuffix("ly")
}

// 7.
// Given a string and an int n, return a string made of the first and last n
// chars from the string. The string length will be at least n.
// nTwice("Hello", 2) == "Helo"
// nTwice("Chocolate", 3) == "Choate"
// nTwice("Chocolate", 1) == "Ce"
func nTwice(s: String, n: Int) -> String {
    return s.prefix(n) + s.suffix(n)
}

// 8.
// Given a string and an index, return a string length 2 starting at the index
// given, or if the index is too big or too small to define a string length
// 2, use the first 2 chars. The original string will be length 2 or more
// and the index will be at least 0.
// twoChar("java", 0) == "ja"
// twoChar("java", 2) == "va"
// twoChar("java", 3) == "ja"
// twoChar("java", 100) == "ja"
func twoChar(s: String, index: Int) -> String {
    return s.prefix(min(2, s.count))
}

// 9.
// Given a string and a non-negative int n, return a larger string that is n
// copies of the original string.
// stringTimes("Hi
let digits = String(x).characters // 'characters' is unavailable: Please use String directly
return s.prefix(min(2, s.count)) // no 'prefix' candidates produce the expected contextual result type 'String'
return s[1..<s.count - 1] // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.
return s[s.count / 2 - 1..<s.count / 2 + 1] // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.
return s.prefix(n) + s.suffix(n) // no '+' candidates produce the expected contextual result type 'String'
return s.prefix(min(2, s.count)) // no 'prefix' candidates produce the expected contextual result type 'String'

func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isUpperCased {
            sum += char.asciiValue
        }
    }
    return sum
}
```swift
// Task
// Write a function that takes a string as input and returns the sum of the upper characters only'
// ASCII codes.
// Examples:
// digitSum(s: "") == 0
// digitSum(s: "abAB") == 131
// digitSum(s: "abcCd") == 67
// digitSum(s: "helloE") == 69
// digitSum(s: "woArBld") == 131
// digitSum(s: "aAaaaXa") == 153
func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isUpperCased {
            sum += char.asciiValue
        }
    }
    return sum
}

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
if char.isUpperCased { // value of type 'Character' has no member 'isUpperCased'
sum += char.asciiValue // cannot convert value of type 'UInt8?' to expected argument type 'Int'

func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isUpperCased {
            sum += char.asciiValue
        }
    }
    return sum
}
```swift
// Task
// Write a function that takes a string as input and returns the sum of the upper characters only'
// ASCII codes.
// Examples:
// digitSum(s: "") == 0
// digitSum(s: "abAB") == 131
// digitSum(s: "abcCd") == 67
// digitSum(s: "helloE") == 69
// digitSum(s: "woArBld") == 131
// digitSum(s: "aAaaaXa") == 153
func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isUpperCased {
            sum += char.asciiValue
        }
    }
    return sum
}

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
if char.isUpperCased { // value of type 'Character' has no member 'isUpperCased'
sum += char.asciiValue // cannot convert value of type 'UInt8?' to expected argument type 'Int'

func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isUpper {
            sum += char.asciiValue
        }
    }
    return sum
}
```swift
// Task
// Write a function that takes a string as input and returns the sum of the upper characters only'
// ASCII codes.
// Examples:
// digitSum(s: "") == 0
// digitSum(s: "abAB") == 131
// digitSum(s: "abcCd") == 67
// digitSum(s: "helloE") == 69
// digitSum(s: "woArBld") == 131
// digitSum(s: "aAaaaXa") == 153
func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isUpper {
            sum += char.asciiValue
        }
    }
    return sum
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
if char.isUpper { // value of type 'Character' has no member 'isUpper'
sum += char.asciiValue // cannot convert value of type 'UInt8?' to expected argument type 'Int'

func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isUpper {
            sum += char.asciiValue
        }
    }
    return sum
}

func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isLower {
            sum += char.asciiValue
        }
    }
    return sum
}

func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isDigit {
            sum += char.asciiValue
        }
    }
    return sum
}
```swift
// Task
// Write a function that takes a string as input and returns the sum of the upper characters only'
// ASCII codes.
// Examples:
// digitSum(s: "") == 0
// digitSum(s: "abAB") == 131
// digitSum(s: "abcCd") == 67
// digitSum(s: "helloE") == 69
// digitSum(s: "woArBld") == 131
// digitSum(s: "aAaaaXa") == 153
func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isUpper {
            sum += char.asciiValue
        }
    }
    return sum
}

// ----------------------------------------------------------------------------------------------------------------------

// 2. Write a function that takes a string as input and returns the sum of the lower characters only'
// ASCII codes.
// Examples:
// digitSum(s: "") == 0
// digitSum(s: "abAB") == 65
// digitSum(s: "abcCd") == 67
// digitSum(s: "helloE") == 69
// digitSum(s: "woArBld") == 101
// digitSum(s: "aAaaaXa") == 153
func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isLower {
            sum += char.asciiValue
        }
    }
    return sum
}

// ----------------------------------------------------------------------------------------------------------------------

// 3. Write a function that takes a string as input and returns the sum of the digits only'
// ASCII codes.
// Examples:
// digitSum(s: "") == 0
// digitSum(s: "abAB") == 131
// digitSum(s: "abcCd") == 67
// digitSum(s: "helloE") == 69
// digitSum(s: "woArBld") == 131
// digitSum(s: "aAaaaXa") == 153
func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isDigit {
            sum += char.asciiValue
        }
    }
    return sum
}

// ----------------------------------------------------------------------------------------------------------------------

// 4. Write a function that takes a string as input and returns the sum of the upper characters only'
// ASCII codes.
// Examples:
// digitSum(s: "") == 0
// digitSum(s: "abAB") == 131
// digitSum(s: "abcCd") == 67
// digitSum(s: "helloE") == 69
// digitSum(s: "woArBld") == 131
// digitSum(s: "aAaaaXa") == 153
func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isUpper {
            sum += char.asciiValue
        }
    }
    return sum
}

// ----------------------------------------------------------------------------------------------------------------------

// 5. Write a function that takes a string as input and returns the sum of the lower characters only'
// ASCII codes.
// Examples:
// digitSum(s: "") == 0
// digitSum(s: "abAB") == 65
// digitSum(s: "abcCd") == 67
// digitSum(s: "helloE") == 69
// digitSum(s: "woArBld") == 101
// digitSum(s: "aAaaaXa") == 153
func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isLower {
            sum += char.asciiValue
        }
    }
    return sum
}

// ----------------------------------------------------------------------------------------------------------------------
if char.isUpper { // value of type 'Character' has no member 'isUpper'
sum += char.asciiValue // cannot convert value of type 'UInt8?' to expected argument type 'Int'
func digitSum(s: String) -> Int { // invalid redeclaration of 'digitSum(s:)'
if char.isLower { // value of type 'Character' has no member 'isLower'
sum += char.asciiValue // cannot convert value of type 'UInt8?' to expected argument type 'Int'
func digitSum(s: String) -> Int { // invalid redeclaration of 'digitSum(s:)'
if char.isDigit { // value of type 'Character' has no member 'isDigit'
sum += char.asciiValue // cannot convert value of type 'UInt8?' to expected argument type 'Int'

func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isUpperCased {
            sum += char.asciiValue
        }
    }
    return sum
}
```swift
// Task
// Write a function that takes a string as input and returns the sum of the upper characters only'
// ASCII codes.
// Examples:
// digitSum(s: "") == 0
// digitSum(s: "abAB") == 131
// digitSum(s: "abcCd") == 67
// digitSum(s: "helloE") == 69
// digitSum(s: "woArBld") == 131
// digitSum(s: "aAaaaXa") == 153
func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isUpperCased {
            sum += char.asciiValue
        }
    }
    return sum
}

// Task
// Write a function that takes a string as input and returns the sum of the upper characters only'
// ASCII codes.
// Examples:
// digitSum(s: "") == 0
// digitSum(s: "abAB") == 131
// digitSum(s: "abcCd") == 67
// digitSum(s: "helloE") == 69
// digitSum(s: "woArBld") == 131
// digitSum(s: "aAaaaXa") == 153
func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isUpperCased {
            sum += char.asciiValue
        }
    }
    return sum
}

// Task
// Write a function that takes a string as input and returns the sum of the upper characters only'
// ASCII codes.
// Examples:
// digitSum(s: "") == 0
// digitSum(s: "abAB") == 131
// digitSum(s: "abcCd") == 67
// digitSum(s: "helloE") == 69
// digitSum(s: "woArBld") == 131
// digitSum(s: "aAaaaXa") == 153
func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isUpperCased {
            sum += char.asciiValue
        }
    }
    return sum
}

// Task
// Write a function that takes a string as input and returns the sum of the upper characters only'
// ASCII codes.
// Examples:
// digitSum(s: "") == 0
// digitSum(s: "abAB") == 131
// digitSum(s: "abcCd") == 67
// digitSum(s: "helloE") == 69
// digitSum(s: "woArBld") == 131
// digitSum(s: "aAaaaXa") == 153
func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isUpperCased {
            sum += char.asciiValue
        }
    }
    return sum
}

// Task
// Write a function that takes a string as input and returns the sum of the upper characters only'
// ASCII codes.
// Examples:
// digitSum(s: "") == 0
// digitSum(s: "abAB") == 131
// digitSum(s: "abcCd") == 67
// digitSum(s: "helloE") == 69
// digitSum(s: "woArBld") == 131
// digitSum(s: "aAaaaXa") == 153
func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isUpperCased {
            sum += char.asciiValue
        }
    }
    return sum
}

// Task
// Write a function that takes a string as input and returns the sum of the upper characters only'
// ASCII codes.
// Examples:
// digitSum(s: "") == 0
// digitSum(s: "abAB") == 131
// digitSum(s: "abcCd") == 67
// digitSum(s: "helloE") == 69
// digitSum(s: "woArBld") == 131
// digitSum(s: "aAaaaXa") == 153
func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isUpperCased {
            sum += char.asciiValue
        }
    }
    return sum
}

// Task
// Write a function that takes a string as input
if char.isUpperCased { // value of type 'Character' has no member 'isUpperCased'
sum += char.asciiValue // cannot convert value of type 'UInt8?' to expected argument type 'Int'

func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isUpperCased {
            sum += char.asciiValue
        }
    }
    return sum
}
```swift
// Task
// Write a function that takes a string as input and returns the sum of the upper characters only'
// ASCII codes.
// Examples:
// digitSum(s: "") == 0
// digitSum(s: "abAB") == 131
// digitSum(s: "abcCd") == 67
// digitSum(s: "helloE") == 69
// digitSum(s: "woArBld") == 131
// digitSum(s: "aAaaaXa") == 153
func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isUpperCased {
            sum += char.asciiValue
        }
    }
    return sum
}

// ----------------------------------------------------------------------------------------------------------------------

// Task
// Given a string, return a new string that has transformed based on the input:
// Change case of every character, ie. lower case to upper case, upper case to lower case.
// Reverse the order of words from the input.
// Note: You will have to handle multiple spaces, and leading/trailing spaces.
// Examples:
// "Example Input" ==> "iNPUT eXAMPLE"
// "Warmup - Strings" ==> "gnimmAReW - dnaS"
// "This is a test" ==> "tSET a si htiw"

// ----------------------------------------------------------------------------------------------------------------------

// Task
// Given a string, return a new string with the reversed order of characters.
// Examples:
// "example" ==> "elpmaxe"
// "coding" ==> "gniidoC"
// "12345" ==> "54321"
// "Sadie" ==> "ediyS"

// ----------------------------------------------------------------------------------------------------------------------

// Task
// Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
// Note: For the purpose of this problem, we define empty string as valid palindrome.
// Examples:
// "A man, a plan, a canal: Panama" is a palindrome.
// "race a car" is not a palindrome.
// " " is a valid palindrome.

// ----------------------------------------------------------------------------------------------------------------------

// Task
// Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
// Note: For the purpose of this problem, we define empty string as valid palindrome.
// Examples:
// "A man, a plan, a canal: Panama" is a palindrome.
// "race a car" is not a palindrome.
// " " is a valid palindrome.

// ----------------------------------------------------------------------------------------------------------------------

// Task
// Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
// Note: For the purpose of this problem, we define empty string as valid palindrome.
// Examples:
// "A man, a plan, a canal: Panama" is a palindrome.
// "race a car" is not a palindrome.
// " " is a valid palindrome.

// ----------------------------------------------------------------------------------------------------------------------

// Task
// Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
// Note: For the purpose of this problem, we define empty string as valid palindrome.
// Examples:
// "A man, a plan, a canal: Panama" is a palindrome.
// "race a car" is not a palindrome.
// " " is a valid palindrome.

// ----------------------------------------------------------------------------------------------------------------------

// Task
// Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
// Note: For the purpose of this problem, we define empty string as valid palindrome.
// Examples:
if char.isUpperCased { // value of type 'Character' has no member 'isUpperCased'
sum += char.asciiValue // cannot convert value of type 'UInt8?' to expected argument type 'Int'

func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isUpperCased {
            sum += char.asciiValue
        }
    }
    return sum
}
```swift
// Task
// Write a function that takes a string as input and returns the sum of the upper characters only'
// ASCII codes.
// Examples:
// digitSum(s: "") == 0
// digitSum(s: "abAB") == 131
// digitSum(s: "abcCd") == 67
// digitSum(s: "helloE") == 69
// digitSum(s: "woArBld") == 131
// digitSum(s: "aAaaaXa") == 153
func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isUpperCased {
            sum += char.asciiValue
        }
    }
    return sum
}

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// Task
// Given a string, find the first character that is not repeated anywhere in the string.
// Examples:
// firstNotRepeatedCharacter(s: "abcdcaf") == "b"
// firstNotRepeatedCharacter(s: "abcd") == "e"
// firstNotRepeatedCharacter(s: "") == ""
// firstNotRepeatedCharacter(s: "aabbcc") == "e"
// firstNotRepeatedCharacter(s: "aabbccddeef") == "f"
// firstNotRepeatedCharacter(s: "abcdefghijklmnopqrstuvwxyz") == "a"
// firstNotRepeatedCharacter(s: "abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba") == "a"
// firstNotRepeatedCharacter(s: "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba") == "b"
// firstNotRepeatedCharacter(s: "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba") == "c"
// firstNotRepeatedCharacter(s: "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba") == "d"
// firstNotRepeatedCharacter(s: "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcdef
if char.isUpperCased { // value of type 'Character' has no member 'isUpperCased'
sum += char.asciiValue // cannot convert value of type 'UInt8?' to expected argument type 'Int'

func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isUpper {
            sum += char.asciiValue
        }
    }
    return sum
}

func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isLower {
            sum += char.asciiValue
        }
    }
    return sum
}

func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isDigit {
            sum += char.asciiValue
        }
    }
    return sum
}
```swift
// Task
// Write a function that takes a string as input and returns the sum of the upper characters only'
// ASCII codes.
// Examples:
// digitSum(s: "") == 0
// digitSum(s: "abAB") == 131
// digitSum(s: "abcCd") == 67
// digitSum(s: "helloE") == 69
// digitSum(s: "woArBld") == 131
// digitSum(s: "aAaaaXa") == 153
func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isUpper {
            sum += char.asciiValue
        }
    }
    return sum
}

// 2. Write a function that takes a string as input and returns the sum of the lower characters only'
// ASCII codes.
// Examples:
// digitSum(s: "") == 0
// digitSum(s: "abAB") == 98
// digitSum(s: "abcCd") == 100
// digitSum(s: "helloE") == 101
// digitSum(s: "woArBld") == 101
// digitSum(s: "aAaaaXa") == 101
func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isLower {
            sum += char.asciiValue
        }
    }
    return sum
}

// 3. Write a function that takes a string as input and returns the sum of the digits only'
// ASCII codes.
// Examples:
// digitSum(s: "") == 0
// digitSum(s: "abAB") == 1
// digitSum(s: "abcCd") == 10
// digitSum(s: "helloE") == 11
// digitSum(s: "woArBld") == 11
// digitSum(s: "aAaaaXa") == 11
func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isDigit {
            sum += char.asciiValue
        }
    }
    return sum
}

// 4. Write a function that takes a string as input and returns the sum of the upper characters only'
// ASCII codes.
// Examples:
// digitSum(s: "") == 0
// digitSum(s: "abAB") == 131
// digitSum(s: "abcCd") == 67
// digitSum(s: "helloE") == 69
// digitSum(s: "woArBld") == 131
// digitSum(s: "aAaaaXa") == 153
func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isUpper {
            sum += char.asciiValue
        }
    }
    return sum
}

// 5. Write a function that takes a string as input and returns the sum of the lower characters only'
// ASCII codes.
// Examples:
// digitSum(s: "") == 0
// digitSum(s: "abAB") == 98
// digitSum(s: "abcCd") == 100
// digitSum(s: "helloE") == 101
// digitSum(s: "woArBld") == 101
// digitSum(s: "aAaaaXa") == 101
func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isLower {
            sum += char.asciiValue
        }
    }
    return sum
}

// 6. Write a function that takes a string as input and returns the sum of the digits only'
// ASCII codes.
// Examples:
// digitSum(s: "") == 0
// digitSum(s: "abAB") == 1
// digitSum(s: "abcCd") == 10
// digitSum(s: "helloE") == 11
// digitSum(s: "woArBld") == 11
// digitSum(s: "aAaaaXa") == 11
func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isDigit {
            sum += char.asciiValue
        }
    }
    return sum
}

// 7. Write a function that takes a string as input and returns the sum of the upper characters only'
// ASCII codes.
//
if char.isUpper { // value of type 'Character' has no member 'isUpper'
sum += char.asciiValue // cannot convert value of type 'UInt8?' to expected argument type 'Int'
func digitSum(s: String) -> Int { // invalid redeclaration of 'digitSum(s:)'
if char.isLower { // value of type 'Character' has no member 'isLower'
sum += char.asciiValue // cannot convert value of type 'UInt8?' to expected argument type 'Int'
func digitSum(s: String) -> Int { // invalid redeclaration of 'digitSum(s:)'
if char.isDigit { // value of type 'Character' has no member 'isDigit'
sum += char.asciiValue // cannot convert value of type 'UInt8?' to expected argument type 'Int'

func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isUpperCased {
            sum += char.asciiValue
        }
    }
    return sum
}
```swift
// Task
// Write a function that takes a string as input and returns the sum of the upper characters only'
// ASCII codes.
// Examples:
// digitSum(s: "") == 0
// digitSum(s: "abAB") == 131
// digitSum(s: "abcCd") == 67
// digitSum(s: "helloE") == 69
// digitSum(s: "woArBld") == 131
// digitSum(s: "aAaaaXa") == 153
func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isUpperCased {
            sum += char.asciiValue
        }
    }
    return sum
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------
if char.isUpperCased { // value of type 'Character' has no member 'isUpperCased'
sum += char.asciiValue // cannot convert value of type 'UInt8?' to expected argument type 'Int'

func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isUpper {
            sum += char.asciiValue
        }
    }
    return sum
}
```swift
// Task
// Write a function that takes a string as input and returns the sum of the upper characters only'
// ASCII codes.
// Examples:
// digitSum(s: "") == 0
// digitSum(s: "abAB") == 131
// digitSum(s: "abcCd") == 67
// digitSum(s: "helloE") == 69
// digitSum(s: "woArBld") == 131
// digitSum(s: "aAaaaXa") == 153
func digitSum(s: String) -> Int {
    var sum = 0
    for char in s {
        if char.isUpper {
            sum += char.asciiValue
        }
    }
    return sum
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------
if char.isUpper { // value of type 'Character' has no member 'isUpper'
sum += char.asciiValue // cannot convert value of type 'UInt8?' to expected argument type 'Int'

func fruitDistribution(s: String, n: Int) -> Int {
    let apples = Int(s.split(separator: " apples and ")[0])!
    let oranges = Int(s.split(separator: " oranges and ")[0])!
    return n - apples - oranges
}
```swift
// In this task, you will be given a string that represents a number of apples and oranges 
// that are distributed in a basket of fruit this basket contains 
// apples, oranges, and mango fruits. Given the string that represents the total number of 
// the oranges and apples and an integer that represent the total number of the fruits 
// in the basket return the number of the mango fruits in the basket.
// for examble:
// fruitDistribution(s: "5 apples and 6 oranges", n: 19) == 8
// fruitDistribution(s: "0 apples and 1 oranges", n: 3) == 2
// fruitDistribution(s: "2 apples and 3 oranges", n: 100) == 95
// fruitDistribution(s: "100 apples and 1 oranges", n: 120) == 19
func fruitDistribution(s: String, n: Int) -> Int {
    let apples = Int(s.split(separator: " apples and ")[0])!
    let oranges = Int(s.split(separator: " oranges and ")[0])!
    return n - apples - oranges
}

// ----------------------------------------------------------------------------------------------------------------------
// Task 2:
// Given a string that represents a number of apples and oranges ,
// return the number of the mango fruits in the basket.
// for examble:
// fruitDistribution(s: "5 apples and 6 oranges", n: 19) == 8
// fruitDistribution(s: "0 apples and 1 oranges", n: 3) == 2
// fruitDistribution(s: "2 apples and 3 oranges", n: 100) == 95
// fruitDistribution(s: "100 apples and 1 oranges", n: 120) == 19
func fruitDistribution(s: String, n: Int) -> Int {
    let apples = Int(s.split(separator: " apples and ")[0])!
    let oranges = Int(s.split(separator: " oranges and ")[0])!
    return n - apples - oranges
}

// ----------------------------------------------------------------------------------------------------------------------
// Task 3:
// Given a string that represents a number of apples and oranges ,
// return the number of the mango fruits in the basket.
// for examble:
// fruitDistribution(s: "5 apples and 6 oranges", n: 19) == 8
// fruitDistribution(s: "0 apples and 1 oranges", n: 3) == 2
// fruitDistribution(s: "2 apples and 3 oranges", n: 100) == 95
// fruitDistribution(s: "100 apples and 1 oranges", n: 120) == 19
func fruitDistribution(s: String, n: Int) -> Int {
    let apples = Int(s.split(separator: " apples and ")[0])!
    let oranges = Int(s.split(separator: " oranges and ")[0])!
    return n - apples - oranges
}

// ----------------------------------------------------------------------------------------------------------------------
// Task 4:
// Given a string that represents a number of apples and oranges ,
// return the number of the mango fruits in the basket.
// for examble:
// fruitDistribution(s: "5 apples and 6 oranges", n: 19) == 8
// fruitDistribution(s: "0 apples and 1 oranges", n: 3) == 2
// fruitDistribution(s: "2 apples and 3 oranges", n: 100) == 95
// fruitDistribution(s: "100 apples and 1 oranges", n: 120) == 19
func fruitDistribution(s: String, n: Int) -> Int {
    let apples = Int(s.split(separator: " apples and ")[0])!
    let oranges = Int(s.split(separator: " oranges and ")[0])!
    return n - apples - oranges
}

// ----------------------------------------------------------------------------------------------------------------------
// Task 5:
// Given a string that represents a number of apples and oranges ,
// return the number of the mango fruits in the basket.
// for examble:
// fruitDistribution(s: "5 apples and 6 oranges", n: 19) == 8
// fruitDistribution(s: "0 apples and 1 oranges", n: 3) == 2
// fruitDistribution(s: "2 apples and 3 oranges", n: 100) == 95
// fruitDistribution(s
 // Fatal error: Unexpectedly found nil while unwrapping an Optional value

func fruitDistribution(s: String, n: Int) -> Int {
    let split = s.split(separator: " ")
    let apples = Int(split[0])!
    let oranges = Int(split[2])!
    let mango = n - apples - oranges
    return mango
}
```swift
// In this task, you will be given a string that represents a number of apples and oranges 
// that are distributed in a basket of fruit this basket contains 
// apples, oranges, and mango fruits. Given the string that represents the total number of 
// the oranges and apples and an integer that represent the total number of the fruits 
// in the basket return the number of the mango fruits in the basket.
// for examble:
// fruitDistribution(s: "5 apples and 6 oranges", n: 19) == 8
// fruitDistribution(s: "0 apples and 1 oranges", n: 3) == 2
// fruitDistribution(s: "2 apples and 3 oranges", n: 100) == 95
// fruitDistribution(s: "100 apples and 1 oranges", n: 120) == 19
func fruitDistribution(s: String, n: Int) -> Int {
    let split = s.split(separator: " ")
    let apples = Int(split[0])!
    let oranges = Int(split[2])!
    let mango = n - apples - oranges
    return mango
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // Fatal error: Unexpectedly found nil while unwrapping an Optional value

func fruitDistribution(s: String, n: Int) -> Int {
    let splitted = s.split(separator: " ")
    let apples = Int(splitted[0])!
    let oranges = Int(splitted[2])!
    let mango = n - apples - oranges
    return mango
}
```swift
// In this task, you will be given a string that represents a number of apples and oranges 
// that are distributed in a basket of fruit this basket contains 
// apples, oranges, and mango fruits. Given the string that represents the total number of 
// the oranges and apples and an integer that represent the total number of the fruits 
// in the basket return the number of the mango fruits in the basket.
// for examble:
// fruitDistribution(s: "5 apples and 6 oranges", n: 19) == 8
// fruitDistribution(s: "0 apples and 1 oranges", n: 3) == 2
// fruitDistribution(s: "2 apples and 3 oranges", n: 100) == 95
// fruitDistribution(s: "100 apples and 1 oranges", n: 120) == 19
func fruitDistribution(s: String, n: Int) -> Int {
    let splitted = s.split(separator: " ")
    let apples = Int(splitted[0])!
    let oranges = Int(splitted[2])!
    let mango = n - apples - oranges
    return mango
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // Fatal error: Unexpectedly found nil while unwrapping an Optional value

func fruitDistribution(s: String, n: Int) -> Int {
    let apples = Int(String(s.split(" apples")[0]))
    let oranges = Int(String(s.split(" oranges")[0]))
    return n - apples - oranges
}
```swift
// In this task, you will be given a string that represents a number of apples and oranges 
// that are distributed in a basket of fruit this basket contains 
// apples, oranges, and mango fruits. Given the string that represents the total number of 
// the oranges and apples and an integer that represent the total number of the fruits 
// in the basket return the number of the mango fruits in the basket.
// for examble:
// fruitDistribution(s: "5 apples and 6 oranges", n: 19) == 8
// fruitDistribution(s: "0 apples and 1 oranges", n: 3) == 2
// fruitDistribution(s: "2 apples and 3 oranges", n: 100) == 95
// fruitDistribution(s: "100 apples and 1 oranges", n: 120) == 19
func fruitDistribution(s: String, n: Int) -> Int {
    let apples = Int(String(s.split(" apples")[0]))
    let oranges = Int(String(s.split(" oranges")[0]))
    return n - apples - oranges
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
let apples = Int(String(s.split(" apples")[0])) // missing argument label 'separator:' in call
let oranges = Int(String(s.split(" oranges")[0])) // missing argument label 'separator:' in call

func fruitDistribution(s: String, n: Int) -> Int {
    let split = s.split(separator: " ")
    let apples = Int(split[0])!
    let oranges = Int(split[2])!
    let mango = n - apples - oranges
    return mango
}
```swift
// In this task, you will be given a string that represents a number of apples and oranges 
// that are distributed in a basket of fruit this basket contains 
// apples, oranges, and mango fruits. Given the string that represents the total number of 
// the oranges and apples and an integer that represent the total number of the fruits 
// in the basket return the number of the mango fruits in the basket.
// for examble:
// fruitDistribution(s: "5 apples and 6 oranges", n: 19) == 8
// fruitDistribution(s: "0 apples and 1 oranges", n: 3) == 2
// fruitDistribution(s: "2 apples and 3 oranges", n: 100) == 95
// fruitDistribution(s: "100 apples and 1 oranges", n: 120) == 19
func fruitDistribution(s: String, n: Int) -> Int {
    let split = s.split(separator: " ")
    let apples = Int(split[0])!
    let oranges = Int(split[2])!
    let mango = n - apples - oranges
    return mango
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // Fatal error: Unexpectedly found nil while unwrapping an Optional value

func fruitDistribution(s: String, n: Int) -> Int {
    let splitted = s.split(separator: " ")
    let apples = Int(splitted[0])!
    let oranges = Int(splitted[2])!
    let mango = n - apples - oranges
    return mango
}
```swift
// In this task, you will be given a string that represents a number of apples and oranges 
// that are distributed in a basket of fruit this basket contains 
// apples, oranges, and mango fruits. Given the string that represents the total number of 
// the oranges and apples and an integer that represent the total number of the fruits 
// in the basket return the number of the mango fruits in the basket.
// for examble:
// fruitDistribution(s: "5 apples and 6 oranges", n: 19) == 8
// fruitDistribution(s: "0 apples and 1 oranges", n: 3) == 2
// fruitDistribution(s: "2 apples and 3 oranges", n: 100) == 95
// fruitDistribution(s: "100 apples and 1 oranges", n: 120) == 19
func fruitDistribution(s: String, n: Int) -> Int {
    let splitted = s.split(separator: " ")
    let apples = Int(splitted[0])!
    let oranges = Int(splitted[2])!
    let mango = n - apples - oranges
    return mango
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // Fatal error: Unexpectedly found nil while unwrapping an Optional value

func fruitDistribution(s: String, n: Int) -> Int {
    let apples = Int(s.split(separator: " apples and ")[0])!
    let oranges = Int(s.split(separator: " oranges and ")[0])!
    let mango = n - apples - oranges
    return mango
}
```swift
// In this task, you will be given a string that represents a number of apples and oranges 
// that are distributed in a basket of fruit this basket contains 
// apples, oranges, and mango fruits. Given the string that represents the total number of 
// the oranges and apples and an integer that represent the total number of the fruits 
// in the basket return the number of the mango fruits in the basket.
// for examble:
// fruitDistribution(s: "5 apples and 6 oranges", n: 19) == 8
// fruitDistribution(s: "0 apples and 1 oranges", n: 3) == 2
// fruitDistribution(s: "2 apples and 3 oranges", n: 100) == 95
// fruitDistribution(s: "100 apples and 1 oranges", n: 120) == 19
func fruitDistribution(s: String, n: Int) -> Int {
    let apples = Int(s.split(separator: " apples and ")[0])!
    let oranges = Int(s.split(separator: " oranges and ")[0])!
    let mango = n - apples - oranges
    return mango
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // Fatal error: Unexpectedly found nil while unwrapping an Optional value

func fruitDistribution(s: String, n: Int) -> Int {
    let apples = Int(s.split(separator: " apples")[0])!
    let oranges = Int(s.split(separator: " oranges")[0])!
    return n - apples - oranges
}
```swift
// In this task, you will be given a string that represents a number of apples and oranges 
// that are distributed in a basket of fruit this basket contains 
// apples, oranges, and mango fruits. Given the string that represents the total number of 
// the oranges and apples and an integer that represent the total number of the fruits 
// in the basket return the number of the mango fruits in the basket.
// for examble:
// fruitDistribution(s: "5 apples and 6 oranges", n: 19) == 8
// fruitDistribution(s: "0 apples and 1 oranges", n: 3) == 2
// fruitDistribution(s: "2 apples and 3 oranges", n: 100) == 95
// fruitDistribution(s: "100 apples and 1 oranges", n: 120) == 19
func fruitDistribution(s: String, n: Int) -> Int {
    let apples = Int(s.split(separator: " apples")[0])!
    let oranges = Int(s.split(separator: " oranges")[0])!
    return n - apples - oranges
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // Fatal error: Unexpectedly found nil while unwrapping an Optional value

func fruitDistribution(s: String, n: Int) -> Int {
    let apples = Int(s.split(separator: " apples and ")[0])!
    let oranges = Int(s.split(separator: " oranges and ")[0])!
    return n - apples - oranges
}
```swift
// In this task, you will be given a string that represents a number of apples and oranges 
// that are distributed in a basket of fruit this basket contains 
// apples, oranges, and mango fruits. Given the string that represents the total number of 
// the oranges and apples and an integer that represent the total number of the fruits 
// in the basket return the number of the mango fruits in the basket.
// for examble:
// fruitDistribution(s: "5 apples and 6 oranges", n: 19) == 8
// fruitDistribution(s: "0 apples and 1 oranges", n: 3) == 2
// fruitDistribution(s: "2 apples and 3 oranges", n: 100) == 95
// fruitDistribution(s: "100 apples and 1 oranges", n: 120) == 19
func fruitDistribution(s: String, n: Int) -> Int {
    let apples = Int(s.split(separator: " apples and ")[0])!
    let oranges = Int(s.split(separator: " oranges and ")[0])!
    return n - apples - oranges
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // Fatal error: Unexpectedly found nil while unwrapping an Optional value

func fruitDistribution(s: String, n: Int) -> Int {
    let apples = Int(s.split(separator: " apples and ")[0])!
    let oranges = Int(s.split(separator: " oranges and ")[0])!
    let mango = n - apples - oranges
    return mango
}
```swift
// In this task, you will be given a string that represents a number of apples and oranges 
// that are distributed in a basket of fruit this basket contains 
// apples, oranges, and mango fruits. Given the string that represents the total number of 
// the oranges and apples and an integer that represent the total number of the fruits 
// in the basket return the number of the mango fruits in the basket.
// for examble:
// fruitDistribution(s: "5 apples and 6 oranges", n: 19) == 8
// fruitDistribution(s: "0 apples and 1 oranges", n: 3) == 2
// fruitDistribution(s: "2 apples and 3 oranges", n: 100) == 95
// fruitDistribution(s: "100 apples and 1 oranges", n: 120) == 19
func fruitDistribution(s: String, n: Int) -> Int {
    let apples = Int(s.split(separator: " apples and ")[0])!
    let oranges = Int(s.split(separator: " oranges and ")[0])!
    let mango = n - apples - oranges
    return mango
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // Fatal error: Unexpectedly found nil while unwrapping an Optional value

func pluck(arr: [Int]) -> [Int] {
    var smallestEven = Int.max
    var smallestIndex = 0
    for i in 0..<arr.count {
        if arr[i] % 2 == 0 && arr[i] < smallestEven {
            smallestEven = arr[i]
            smallestIndex = i
        }
    }
    return [smallestEven, smallestIndex]
}

struct pluck_test {
    static let input = [4, 2, 3]
    static let expected = [2, 1]
    static func test() {
        let actual = pluck(input)
        assert(actual == expected)
    }
}

struct pluck_test {
    static let input = [1, 2, 3]
    static let expected = [2, 1]
    static func test() {
        let actual = pluck(input)
        assert(actual == expected)
    }
}

struct pluck_test {
    static let input = [] as [Int]
    static let expected = [] as [Int]
    static func test() {
        let actual = pluck(input)
        assert(actual == expected)
    }
}

struct pluck_test {
    static let input = [5, 0, 3, 0, 4, 2]
    static let expected = [0, 1]
    static func test() {
        let actual = pluck(input)
        assert(actual == expected)
    }
}

struct pluck_test {
    static let input = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    static let expected = [2, 1]
    static func test() {
        let actual = pluck(input)
        assert(actual == expected)
    }
}
```swift
// "Given an array representing a branch of a tree that has non-negative integer nodes
// your task is to pluck one of the nodes and return it.
// The plucked node should be the node with the smallest even value.
// If multiple nodes with the same smallest even value are found return the node that has smallest index.
// The plucked node should be returned in an array, [ smalest_value, its index ],
// If there are no even values or the given array is empty, return [].
// Example 1:
// Explanation: 2 has the smallest even value, and 2 has the smallest index.
// Example 2:
// Explanation: 2 has the smallest even value, and 2 has the smallest index.
// Example 3:
// Example 4:
// Explanation: 0 is the smallest value, but  there are two zeros,
// so we will choose the first zero, which has the smallest index.
// Constraints:
// * 1 <= nodes.length <= 10000
// * 0 <= node.value
// pluck(arr: [4, 2, 3]) == [2, 1]
// pluck(arr: [1, 2, 3]) == [2, 1]
// pluck(arr: [] as [Int]) == [] as [Int]
// pluck(arr: [5, 0, 3, 0, 4, 2]) == [0, 1]
func pluck(arr: [Int]) -> [Int] {
    var smallestEven = Int.max
    var smallestIndex = 0
    for i in 0..<arr.count {
        if arr[i] % 2 == 0 && arr[i] < smallestEven {
            smallestEven = arr[i]
            smallestIndex = i
        }
    }
    return [smallestEven, smallestIndex]
}
}

struct pluck_test {
    static let input = [4, 2, 3]
    static let expected = [2, 1]
    static func test() {
        let actual = pluck(input)
        assert(actual == expected)
    }
}

struct pluck_test {
    static let input = [1, 2, 3]
    static let expected = [2, 1]
    static func test() {
        let actual = pluck(input)
        assert(actual == expected)
    }
}

struct pluck_test {
    static let input = [] as [Int]
    static let expected = [] as [Int]
    static func test() {
        let actual = pluck(input)
        assert(actual == expected)
    }
}

struct pluck_test {
    static let input = [5, 0, 3, 0, 4, 2]
    static let expected = [0, 1]
    static func test() {
        let actual = pluck(input)
        assert(actual == expected)
    }
}

struct pluck_test {
    static let input = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    static let expected = [2, 1]
    static func test() {
        let actual = pluck(input)
        assert(actual == expected)
    }
}

struct pluck_test {
    static let input = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 
let actual = pluck(input) // missing argument label 'arr:' in call
struct pluck_test { // invalid redeclaration of 'pluck_test'
let actual = pluck(input) // missing argument label 'arr:' in call
struct pluck_test { // invalid redeclaration of 'pluck_test'
let actual = pluck(input) // missing argument label 'arr:' in call
struct pluck_test { // invalid redeclaration of 'pluck_test'
let actual = pluck(input) // missing argument label 'arr:' in call
struct pluck_test { // invalid redeclaration of 'pluck_test'
let actual = pluck(input) // missing argument label 'arr:' in call

func pluck(arr: [Int]) -> [Int] {
    if arr.isEmpty {
        return []
    }
    let minEven = arr.min(by: { $0 % 2 == 0 })
    let index = arr.firstIndex(of: minEven!)
    return [minEven!, index!]
}

struct pluck_test {
    static let input = [4, 2, 3]
    static let expected = [2, 1]
    static func test() {
        let actual = pluck(arr: input)
        print("pluck(arr: \(input)) == \(actual)")
        print("expected: \(expected)")
        print("actual: \(actual)")
        print("")
    }
}

struct pluck_test2 {
    static let input = [1, 2, 3]
    static let expected = [2, 1]
    static func test() {
        let actual = pluck(arr: input)
        print("pluck(arr: \(input)) == \(actual)")
        print("expected: \(expected)")
        print("actual: \(actual)")
        print("")
    }
}

struct pluck_test3 {
    static let input = []
    static let expected = []
    static func test() {
        let actual = pluck(arr: input)
        print("pluck(arr: \(input)) == \(actual)")
        print("expected: \(expected)")
        print("actual: \(actual)")
        print("")
    }
}

struct pluck_test4 {
    static let input = [5, 0, 3, 0, 4, 2]
    static let expected = [0, 1]
    static func test() {
        let actual = pluck(arr: input)
        print("pluck(arr: \(input)) == \(actual)")
        print("expected: \(expected)")
        print("actual: \(actual)")
        print("")
    }
}
```swift
// "Given an array representing a branch of a tree that has non-negative integer nodes
// your task is to pluck one of the nodes and return it.
// The plucked node should be the node with the smallest even value.
// If multiple nodes with the same smallest even value are found return the node that has smallest index.
// The plucked node should be returned in an array, [ smalest_value, its index ],
// If there are no even values or the given array is empty, return [].
// Example 1:
// Explanation: 2 has the smallest even value, and 2 has the smallest index.
// Example 2:
// Explanation: 2 has the smallest even value, and 2 has the smallest index.
// Example 3:
// Example 4:
// Explanation: 0 is the smallest value, but  there are two zeros,
// so we will choose the first zero, which has the smallest index.
// Constraints:
// * 1 <= nodes.length <= 10000
// * 0 <= node.value
// pluck(arr: [4, 2, 3]) == [2, 1]
// pluck(arr: [1, 2, 3]) == [2, 1]
// pluck(arr: [] as [Int]) == [] as [Int]
// pluck(arr: [5, 0, 3, 0, 4, 2]) == [0, 1]
func pluck(arr: [Int]) -> [Int] {
    if arr.isEmpty {
        return []
    }
    let minEven = arr.min(by: { $0 % 2 == 0 })
    let index = arr.firstIndex(of: minEven!)
    return [minEven!, index!]
}

struct pluck_test {
    static let input = [4, 2, 3]
    static let expected = [2, 1]
    static func test() {
        let actual = pluck(arr: input)
        print("pluck(arr: \(input)) == \(actual)")
        print("expected: \(expected)")
        print("actual: \(actual)")
        print("")
    }
}

struct pluck_test2 {
    static let input = [1, 2, 3]
    static let expected = [2, 1]
    static func test() {
        let actual = pluck(arr: input)
        print("pluck(arr: \(input)) == \(actual)")
        print("expected: \(expected)")
        print("actual: \(actual)")
        print("")
    }
}

struct pluck_test3 {
    static let input = []
    static let expected = []
    static func test() {
        let actual = pluck(arr: input)
        print("pluck(arr: \(input)) == \(actual)")
        print("expected: \(expected)")
        print("actual: \(actual)")
        print("")
    }
}

struct pluck_test4 {
    static let input = [5, 0, 3, 0, 4, 2]
    static let expected = [0, 1]
    static func test() {
        let actual = pluck(arr: input)
        print("pluck(arr: \(input)) == \(actual)")
        print("expected: \(expected)")
        print("actual: \(actual)")
        print("")
    }
}

struct pluck_test5 {
    static let input = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 12
let minEven = arr.min(by: { $0 % 2 == 0 }) // contextual closure type '(Int, Int) throws -> Bool' expects 2 arguments, but 1 was used in closure body
static let input = [] // empty collection literal requires an explicit type
static let expected = [] // empty collection literal requires an explicit type
let actual = pluck(arr: input) // cannot convert value of type '[Any]' to expected argument type '[Int]'

func pluck(arr: [Int]) -> [Int] {
    if arr.count == 0 {
        return []
    }
    var minEven = Int.max
    var minEvenIndex = 0
    for i in 0..<arr.count {
        if arr[i] % 2 == 0 && arr[i] < minEven {
            minEven = arr[i]
            minEvenIndex = i
        }
    }
    return [minEven, minEvenIndex]
}
```swift
// "Given an array representing a branch of a tree that has non-negative integer nodes
// your task is to pluck one of the nodes and return it.
// The plucked node should be the node with the smallest even value.
// If multiple nodes with the same smallest even value are found return the node that has smallest index.
// The plucked node should be returned in an array, [ smalest_value, its index ],
// If there are no even values or the given array is empty, return [].
// Example 1:
// Explanation: 2 has the smallest even value, and 2 has the smallest index.
// Example 2:
// Explanation: 2 has the smallest even value, and 2 has the smallest index.
// Example 3:
// Example 4:
// Explanation: 0 is the smallest value, but  there are two zeros,
// so we will choose the first zero, which has the smallest index.
// Constraints:
// * 1 <= nodes.length <= 10000
// * 0 <= node.value
// pluck(arr: [4, 2, 3]) == [2, 1]
// pluck(arr: [1, 2, 3]) == [2, 1]
// pluck(arr: [] as [Int]) == [] as [Int]
// pluck(arr: [5, 0, 3, 0, 4, 2]) == [0, 1]
func pluck(arr: [Int]) -> [Int] {
    if arr.count == 0 {
        return []
    }
    var minEven = Int.max
    var minEvenIndex = 0
    for i in 0..<arr.count {
        if arr[i] % 2 == 0 && arr[i] < minEven {
            minEven = arr[i]
            minEvenIndex = i
        }
    }
    return [minEven, minEvenIndex]
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// ------------------------------------------
 // XCTAssertTrue failed

func pluck(arr: [Int]) -> [Int] {
    if arr.isEmpty {
        return []
    }
    var min = Int.max
    var index = 0
    for (i, v) in arr.enumerated() {
        if v % 2 == 0 && v < min {
            min = v
            index = i
        }
    }
    return [min, index]
}

struct Pluck {
    static func pluck(arr: [Int]) -> [Int] {
        if arr.isEmpty {
            return []
        }
        var min = Int.max
        var index = 0
        for (i, v) in arr.enumerated() {
            if v % 2 == 0 && v < min {
                min = v
                index = i
            }
        }
        return [min, index]
    }
}
```swift
// "Given an array representing a branch of a tree that has non-negative integer nodes
// your task is to pluck one of the nodes and return it.
// The plucked node should be the node with the smallest even value.
// If multiple nodes with the same smallest even value are found return the node that has smallest index.
// The plucked node should be returned in an array, [ smalest_value, its index ],
// If there are no even values or the given array is empty, return [].
// Example 1:
// Explanation: 2 has the smallest even value, and 2 has the smallest index.
// Example 2:
// Explanation: 2 has the smallest even value, and 2 has the smallest index.
// Example 3:
// Example 4:
// Explanation: 0 is the smallest value, but  there are two zeros,
// so we will choose the first zero, which has the smallest index.
// Constraints:
// * 1 <= nodes.length <= 10000
// * 0 <= node.value
// pluck(arr: [4, 2, 3]) == [2, 1]
// pluck(arr: [1, 2, 3]) == [2, 1]
// pluck(arr: [] as [Int]) == [] as [Int]
// pluck(arr: [5, 0, 3, 0, 4, 2]) == [0, 1]
func pluck(arr: [Int]) -> [Int] {
    if arr.isEmpty {
        return []
    }
    var min = Int.max
    var index = 0
    for (i, v) in arr.enumerated() {
        if v % 2 == 0 && v < min {
            min = v
            index = i
        }
    }
    return [min, index]
}

// -----------------------------------------------------------------------------

struct Pluck {
    static func pluck(arr: [Int]) -> [Int] {
        if arr.isEmpty {
            return []
        }
        var min = Int.max
        var index = 0
        for (i, v) in arr.enumerated() {
            if v % 2 == 0 && v < min {
                min = v
                index = i
            }
        }
        return [min, index]
    }
}

// -----------------------------------------------------------------------------

struct Pluck {
    static func pluck(arr: [Int]) -> [Int] {
        if arr.isEmpty {
            return []
        }
        var min = Int.max
        var index = 0
        for (i, v) in arr.enumerated() {
            if v % 2 == 0 && v < min {
                min = v
                index = i
            }
        }
        return [min, index]
    }
}

// -----------------------------------------------------------------------------

struct Pluck {
    static func pluck(arr: [Int]) -> [Int] {
        if arr.isEmpty {
            return []
        }
        var min = Int.max
        var index = 0
        for (i, v) in arr.enumerated() {
            if v % 2 == 0 && v < min {
                min = v
                index = i
            }
        }
        return [min, index]
    }
}

// -----------------------------------------------------------------------------

struct Pluck {
    static func pluck(arr: [Int]) -> [Int] {
        if arr.isEmpty {
            return []
        }
        var min = Int.max
        var index = 0
        for (i, v) in arr.enumerated() {
            if v % 2 == 0 && v < min {
                min = v
                index = i
            }
        }
        return [min, index]
    }
}

// -----------------------------------------------------------------------------

struct Pluck {
    static func pluck(arr: [Int]) -> [Int] {
        if arr.isEmpty {
            return []
        }
        var min = Int.max
        var index = 0
        for (i, v) in arr.enumerated() {
            if v % 2 == 0 && v < min {
                min = v
                index = i
            }
        }
        return [min, index]
    }
}

// -----------------------------------------------------------------------------

struct Pluck {
    static func pluck(arr: [Int]) -> [Int] {
        if arr.isEmpty {
            return []
        }
        var min = Int.max
        var index = 0
        for (i, v) in arr.enumerated() {
            if v % 2 == 0 && v < min {
                min = v
                index = i
            }
        }
        return [min, index]
    }
}

// -----------------------------------------------------------------------------

struct Pluck {
    static func pluck(arr: [Int]) -> [Int] {
        if arr.isEmpty {
            return []
        }
        var min = Int.max
        var index = 0
        for (
 // XCTAssertTrue failed

func pluck(arr: [Int]) -> [Int] {
    var smallestEven = Int.max
    var smallestIndex = 0
    for i in 0..<arr.count {
        if arr[i] % 2 == 0 && arr[i] < smallestEven {
            smallestEven = arr[i]
            smallestIndex = i
        }
    }
    return [smallestEven, smallestIndex]
}
```swift
// "Given an array representing a branch of a tree that has non-negative integer nodes
// your task is to pluck one of the nodes and return it.
// The plucked node should be the node with the smallest even value.
// If multiple nodes with the same smallest even value are found return the node that has smallest index.
// The plucked node should be returned in an array, [ smalest_value, its index ],
// If there are no even values or the given array is empty, return [].
// Example 1:
// Explanation: 2 has the smallest even value, and 2 has the smallest index.
// Example 2:
// Explanation: 2 has the smallest even value, and 2 has the smallest index.
// Example 3:
// Example 4:
// Explanation: 0 is the smallest value, but  there are two zeros,
// so we will choose the first zero, which has the smallest index.
// Constraints:
// * 1 <= nodes.length <= 10000
// * 0 <= node.value
// pluck(arr: [4, 2, 3]) == [2, 1]
// pluck(arr: [1, 2, 3]) == [2, 1]
// pluck(arr: [] as [Int]) == [] as [Int]
// pluck(arr: [5, 0, 3, 0, 4, 2]) == [0, 1]
func pluck(arr: [Int]) -> [Int] {
    var smallestEven = Int.max
    var smallestIndex = 0
    for i in 0..<arr.count {
        if arr[i] % 2 == 0 && arr[i] < smallestEven {
            smallestEven = arr[i]
            smallestIndex = i
        }
    }
    return [smallestEven, smallestIndex]
}
// }}}

// {{{
// Task:
// Given an array representing a branch of a tree that has non-negative integer nodes
// your task is to pluck one of the nodes and return it.
// The plucked node should be the node with the smallest even value.
// If multiple nodes with the same smallest even value are found return the node that has smallest index.
// The plucked node should be returned in an array, [ smalest_value, its index ],
// If there are no even values or the given array is empty, return [].
// Example 1:
// Explanation: 2 has the smallest even value, and 2 has the smallest index.
// Example 2:
// Explanation: 2 has the smallest even value, and 2 has the smallest index.
// Example 3:
// Example 4:
// Explanation: 0 is the smallest value, but  there are two zeros,
// so we will choose the first zero, which has the smallest index.
// Constraints:
// * 1 <= nodes.length <= 10000
// * 0 <= node.value
// pluck(arr: [4, 2, 3]) == [2, 1]
// pluck(arr: [1, 2, 3]) == [2, 1]
// pluck(arr: [] as [Int]) == [] as [Int]
// pluck(arr: [5, 0, 3, 0, 4, 2]) == [0, 1]
func pluck(arr: [Int]) -> [Int] {
    var smallestEven = Int.max
    var smallestIndex = 0
    for i in 0..<arr.count {
        if arr[i] % 2 == 0 && arr[i] < smallestEven {
            smallestEven = arr[i]
            smallestIndex = i
        }
    }
    return [smallestEven, smallestIndex]
}
// }}}

// {{{
// Task:
// Given an array representing a branch of a tree that has non-negative integer nodes
// your task is to pluck one of the nodes and return it.
// The plucked node should be the node with the smallest even value.
// If multiple nodes with the same smallest even value are found return the node that has smallest index.
// The plucked node should be returned in an array, [ smalest_value, its index ],
// If there are no even values or the given array is empty, return [].
// Example 1:
// Explanation: 2 has the smallest even value, and 2 has the smallest index.
// Example 2:
// Explanation: 2 has the smallest even value, and 2 has the smallest index.
// Example 3:
// Example 4:
// Explanation: 0 is the smallest value, but  there are two zeros,
// so we will choose the first zero, which has the smallest index.
// Constraints:
// * 1 <= nodes.length <= 10000
// * 0 <= node.value
// pluck(arr: [4, 2, 3]) == [2, 1]
// pluck(arr: [1, 2, 3]) == [2, 1]
// pluck(arr: [] as [Int]) == [] as [Int]
// pluck(arr: [5, 0, 3, 0, 4, 2]) == [0, 1]
func pluck(arr: [Int]) -> [Int] {
    var smallestEven = Int.max
    var smallestIndex = 0
    for i in 0..<arr.count {
        if arr[i] % 2 == 0 && arr[i] < smallestEven {
            smallestEven = arr[i]
            smallestIndex = i
        }
    }
    return [smallestEven, smallestIndex]
}
// }}}

// {{{
// Task:
// Given an array representing a branch
 // XCTAssertTrue failed

func pluck(arr: [Int]) -> [Int] {
    if arr.count == 0 {
        return []
    }
    var minEven = Int.max
    var minEvenIndex = 0
    for i in 0..<arr.count {
        if arr[i] % 2 == 0 && arr[i] < minEven {
            minEven = arr[i]
            minEvenIndex = i
        }
    }
    return [minEven, minEvenIndex]
}
```swift
// "Given an array representing a branch of a tree that has non-negative integer nodes
// your task is to pluck one of the nodes and return it.
// The plucked node should be the node with the smallest even value.
// If multiple nodes with the same smallest even value are found return the node that has smallest index.
// The plucked node should be returned in an array, [ smalest_value, its index ],
// If there are no even values or the given array is empty, return [].
// Example 1:
// Explanation: 2 has the smallest even value, and 2 has the smallest index.
// Example 2:
// Explanation: 2 has the smallest even value, and 2 has the smallest index.
// Example 3:
// Example 4:
// Explanation: 0 is the smallest value, but  there are two zeros,
// so we will choose the first zero, which has the smallest index.
// Constraints:
// * 1 <= nodes.length <= 10000
// * 0 <= node.value
// pluck(arr: [4, 2, 3]) == [2, 1]
// pluck(arr: [1, 2, 3]) == [2, 1]
// pluck(arr: [] as [Int]) == [] as [Int]
// pluck(arr: [5, 0, 3, 0, 4, 2]) == [0, 1]
func pluck(arr: [Int]) -> [Int] {
    if arr.count == 0 {
        return []
    }
    var minEven = Int.max
    var minEvenIndex = 0
    for i in 0..<arr.count {
        if arr[i] % 2 == 0 && arr[i] < minEven {
            minEven = arr[i]
            minEvenIndex = i
        }
    }
    return [minEven, minEvenIndex]
}
// }}}

// {{{
// https://www.codewars.com/kata/563b40bd609f623a300005b7/train/swift
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
// 5 kyu
//
 // XCTAssertTrue failed

func pluck(arr: [Int]) -> [Int] {
    if arr.isEmpty {
        return []
    }
    let minEven = Int.min
    let minEvenIndex = 0
    for i in 0..<arr.count {
        if arr[i] % 2 == 0 && arr[i] < minEven {
            minEven = arr[i]
            minEvenIndex = i
        }
    }
    return [minEven, minEvenIndex]
}
```swift
// "Given an array representing a branch of a tree that has non-negative integer nodes
// your task is to pluck one of the nodes and return it.
// The plucked node should be the node with the smallest even value.
// If multiple nodes with the same smallest even value are found return the node that has smallest index.
// The plucked node should be returned in an array, [ smalest_value, its index ],
// If there are no even values or the given array is empty, return [].
// Example 1:
// Explanation: 2 has the smallest even value, and 2 has the smallest index.
// Example 2:
// Explanation: 2 has the smallest even value, and 2 has the smallest index.
// Example 3:
// Example 4:
// Explanation: 0 is the smallest value, but  there are two zeros,
// so we will choose the first zero, which has the smallest index.
// Constraints:
// * 1 <= nodes.length <= 10000
// * 0 <= node.value
// pluck(arr: [4, 2, 3]) == [2, 1]
// pluck(arr: [1, 2, 3]) == [2, 1]
// pluck(arr: [] as [Int]) == [] as [Int]
// pluck(arr: [5, 0, 3, 0, 4, 2]) == [0, 1]
func pluck(arr: [Int]) -> [Int] {
    if arr.isEmpty {
        return []
    }
    let minEven = Int.min
    let minEvenIndex = 0
    for i in 0..<arr.count {
        if arr[i] % 2 == 0 && arr[i] < minEven {
            minEven = arr[i]
            minEvenIndex = i
        }
    }
    return [minEven, minEvenIndex]
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ------------------------
minEven = arr[i] // cannot assign to value: 'minEven' is a 'let' constant
minEvenIndex = i // cannot assign to value: 'minEvenIndex' is a 'let' constant

func pluck(arr: [Int]) -> [Int] {
    var smallestEvenValue = 10000
    var smallestEvenIndex = 0
    var smallestEvenNode = 0
    for i in 0..<arr.count {
        if arr[i] % 2 == 0 && arr[i] < smallestEvenValue {
            smallestEvenValue = arr[i]
            smallestEvenIndex = i
            smallestEvenNode = arr[i]
        }
    }
    return [smallestEvenNode, smallestEvenIndex]
}
```swift
// "Given an array representing a branch of a tree that has non-negative integer nodes
// your task is to pluck one of the nodes and return it.
// The plucked node should be the node with the smallest even value.
// If multiple nodes with the same smallest even value are found return the node that has smallest index.
// The plucked node should be returned in an array, [ smalest_value, its index ],
// If there are no even values or the given array is empty, return [].
// Example 1:
// Explanation: 2 has the smallest even value, and 2 has the smallest index.
// Example 2:
// Explanation: 2 has the smallest even value, and 2 has the smallest index.
// Example 3:
// Example 4:
// Explanation: 0 is the smallest value, but  there are two zeros,
// so we will choose the first zero, which has the smallest index.
// Constraints:
// * 1 <= nodes.length <= 10000
// * 0 <= node.value
// pluck(arr: [4, 2, 3]) == [2, 1]
// pluck(arr: [1, 2, 3]) == [2, 1]
// pluck(arr: [] as [Int]) == [] as [Int]
// pluck(arr: [5, 0, 3, 0, 4, 2]) == [0, 1]
func pluck(arr: [Int]) -> [Int] {
    var smallestEvenValue = 10000
    var smallestEvenIndex = 0
    var smallestEvenNode = 0
    for i in 0..<arr.count {
        if arr[i] % 2 == 0 && arr[i] < smallestEvenValue {
            smallestEvenValue = arr[i]
            smallestEvenIndex = i
            smallestEvenNode = arr[i]
        }
    }
    return [smallestEvenNode, smallestEvenIndex]
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// ---
 // XCTAssertTrue failed

func pluck(arr: [Int]) -> [Int] {
    var smallestEvenValue = 0
    var smallestEvenIndex = 0
    var smallestEvenCount = 0
    for i in 0..<arr.count {
        if arr[i] % 2 == 0 {
            if smallestEvenValue == 0 {
                smallestEvenValue = arr[i]
                smallestEvenIndex = i
                smallestEvenCount = 1
            } else if arr[i] == smallestEvenValue {
                smallestEvenCount += 1
            } else if arr[i] < smallestEvenValue {
                smallestEvenValue = arr[i]
                smallestEvenIndex = i
                smallestEvenCount = 1
            }
        }
    }
    if smallestEvenValue == 0 {
        return []
    } else {
        return [smallestEvenValue, smallestEvenIndex]
    }
}

struct pluck_test {
    static let test_cases: [Any] = [
        [4, 2, 3],
        [1, 2, 3],
        [] as [Int],
        [5, 0, 3, 0, 4, 2],
    ]

    static func run() {
        for test_case in test_cases {
            print("pluck(\(test_case)) == \(pluck(test_case))")
        }
    }
}

import Cocoa

public class Solution {
    public static var result: Bool = false

    public static func hasPathSum(root: TreeNode?, sum: Int) -> Bool {
        if root == nil {
            return false
        }
        if root.left == nil && root.right == nil {
            return root.val == sum
        }
        if root.left != nil {
            hasPathSum(root.left, sum - root.val)
        }
        if root.right != nil {
            hasPathSum(root.right, sum - root.val)
        }
        return result
    }

    public static func run() {
        let root = TreeNode(val: 5)
        root.left = TreeNode(val: 4)
        root.right = TreeNode(val: 8)
        root.left.left = TreeNode(val: 11)
        root.left.left.left = TreeNode(val: 7)
        root.left.left.right = TreeNode(val: 2)
        root.right.left = TreeNode(val: 13)
        root.right.right = TreeNode(val: 4)
        root.right.right.right = TreeNode(val: 1)
        print(hasPathSum(root: root, sum: 22))
    }
}
```swift
// "Given an array representing a branch of a tree that has non-negative integer nodes
// your task is to pluck one of the nodes and return it.
// The plucked node should be the node with the smallest even value.
// If multiple nodes with the same smallest even value are found return the node that has smallest index.
// The plucked node should be returned in an array, [ smalest_value, its index ],
// If there are no even values or the given array is empty, return [].
// Example 1:
// Explanation: 2 has the smallest even value, and 2 has the smallest index.
// Example 2:
// Explanation: 2 has the smallest even value, and 2 has the smallest index.
// Example 3:
// Example 4:
// Explanation: 0 is the smallest value, but  there are two zeros,
// so we will choose the first zero, which has the smallest index.
// Constraints:
// * 1 <= nodes.length <= 10000
// * 0 <= node.value
// pluck(arr: [4, 2, 3]) == [2, 1]
// pluck(arr: [1, 2, 3]) == [2, 1]
// pluck(arr: [] as [Int]) == [] as [Int]
// pluck(arr: [5, 0, 3, 0, 4, 2]) == [0, 1]
func pluck(arr: [Int]) -> [Int] {
    var smallestEvenValue = 0
    var smallestEvenIndex = 0
    var smallestEvenCount = 0
    for i in 0..<arr.count {
        if arr[i] % 2 == 0 {
            if smallestEvenValue == 0 {
                smallestEvenValue = arr[i]
                smallestEvenIndex = i
                smallestEvenCount = 1
            } else if arr[i] == smallestEvenValue {
                smallestEvenCount += 1
            } else if arr[i] < smallestEvenValue {
                smallestEvenValue = arr[i]
                smallestEvenIndex = i
                smallestEvenCount = 1
            }
        }
    }
    if smallestEvenValue == 0 {
        return []
    } else {
        return [smallestEvenValue, smallestEvenIndex]
    }
}

struct pluck_test {
    static let test_cases: [Any] = [
        [4, 2, 3],
        [1, 2, 3],
        [] as [Int],
        [5, 0, 3, 0, 4, 2],
    ]

    static func run() {
        for test_case in test_cases {
            print("pluck(\(test_case)) == \(pluck(test_case))")
        }
    }
}

pluck_test.run()<|endoftext|>//
//  main.swift
//  112. Path Sum
//
//  Created by yuhua on 2020/12/13.
//

//https://leetcode.com/problems/path-sum/
//
//Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.
//
//Note: A leaf is a node with no children.
//
//Example:
//
//Given the below binary tree and sum = 22,
//
//      5
//     / \
//    4   8
//   /   / \
//  11  13  4
// /  \      \
//7    2      1
//return true, as there exist a root-to-leaf path 5->4->11->2 which sum is 22.

import Cocoa

public class Solution {
    public static var result: Bool = false

    public static func hasPathSum(root: TreeNode?, sum: Int) -> Bool {
        if root == nil {
            return false
        }
        if root.left == nil && root.right == nil {
            return root.val == sum
        }
        if root.left != nil {
            hasPathSum(root.left, sum - root.val)
        }
        if root.right != nil {
            hasPathSum(root.right, sum - root.val)
        }
        return result
    }

    public static func run() {
        let root = TreeNode(val: 5)
        root.left = TreeNode(val: 4)
        root.right = TreeNode(val: 8)
        root.left.left = TreeNode(val: 11)
        root.left.left.left = TreeNode(val: 7)
        root.left.left.right = TreeNode(val: 2)
        root.right.left = TreeNode(val: 13)
        root.right.right = TreeNode(val: 4)
        root.right.right.right = TreeNode(val: 1)
        print(hasPathSum(root: root, sum: 22))
    }
}

Solution.run()<|endoftext|>//
//  main.swift
//  104. Maximum Depth of Binary Tree
//
//  Created by yuhua on 2020/12/13.
//

//https://leetcode.com/problems/maximum-depth-of-binary-tree/
//
//Given a binary tree, find its maximum depth.
//
//The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
//
//Note: A leaf is
print("pluck(\(test_case)) == \(pluck(test_case))") // missing argument label 'arr:' in call
print("pluck(\(test_case)) == \(pluck(test_case))") // cannot convert value of type 'Any' to expected argument type '[Int]'
public static func hasPathSum(root: TreeNode?, sum: Int) -> Bool { // cannot find type 'TreeNode' in scope
let root = TreeNode(val: 5) // cannot find 'TreeNode' in scope
root.left = TreeNode(val: 4) // cannot find 'TreeNode' in scope
root.right = TreeNode(val: 8) // cannot find 'TreeNode' in scope
root.left.left = TreeNode(val: 11) // cannot find 'TreeNode' in scope
root.left.left.left = TreeNode(val: 7) // cannot find 'TreeNode' in scope
root.left.left.right = TreeNode(val: 2) // cannot find 'TreeNode' in scope
root.right.left = TreeNode(val: 13) // cannot find 'TreeNode' in scope
root.right.right = TreeNode(val: 4) // cannot find 'TreeNode' in scope
root.right.right.right = TreeNode(val: 1) // cannot find 'TreeNode' in scope

func pluck(arr: [Int]) -> [Int] {
    if arr.count == 0 {
        return []
    }
    var minEven = Int.max
    var minEvenIndex = 0
    for i in 0..<arr.count {
        if arr[i] % 2 == 0 && arr[i] < minEven {
            minEven = arr[i]
            minEvenIndex = i
        }
    }
    return [minEven, minEvenIndex]
}

struct PluckTests {
    static let allTests: [XCTest] = [
        PluckTests.test1,
        PluckTests.test2,
        PluckTests.test3,
        PluckTests.test4,
    ]

    static func test1() {
        let arr = [4, 2, 3]
        let expected = [2, 1]
        let actual = pluck(arr: arr)
        XCTAssertEqual(expected, actual)
    }

    static func test2() {
        let arr = [1, 2, 3]
        let expected = [2, 1]
        let actual = pluck(arr: arr)
        XCTAssertEqual(expected, actual)
    }

    static func test3() {
        let arr = []
        let expected = []
        let actual = pluck(arr: arr)
        XCTAssertEqual(expected, actual)
    }

    static func test4() {
        let arr = [5, 0, 3, 0, 4, 2]
        let expected = [0, 1]
        let actual = pluck(arr: arr)
        XCTAssertEqual(expected, actual)
    }
}

class PluckTestsRunner: XCTestCase {
    func testAll() {
        XCTestRunner.runAll(tests: PluckTests.allTests)
    }
}
```swift
// "Given an array representing a branch of a tree that has non-negative integer nodes
// your task is to pluck one of the nodes and return it.
// The plucked node should be the node with the smallest even value.
// If multiple nodes with the same smallest even value are found return the node that has smallest index.
// The plucked node should be returned in an array, [ smalest_value, its index ],
// If there are no even values or the given array is empty, return [].
// Example 1:
// Explanation: 2 has the smallest even value, and 2 has the smallest index.
// Example 2:
// Explanation: 2 has the smallest even value, and 2 has the smallest index.
// Example 3:
// Example 4:
// Explanation: 0 is the smallest value, but  there are two zeros,
// so we will choose the first zero, which has the smallest index.
// Constraints:
// * 1 <= nodes.length <= 10000
// * 0 <= node.value
// pluck(arr: [4, 2, 3]) == [2, 1]
// pluck(arr: [1, 2, 3]) == [2, 1]
// pluck(arr: [] as [Int]) == [] as [Int]
// pluck(arr: [5, 0, 3, 0, 4, 2]) == [0, 1]
func pluck(arr: [Int]) -> [Int] {
    if arr.count == 0 {
        return []
    }
    var minEven = Int.max
    var minEvenIndex = 0
    for i in 0..<arr.count {
        if arr[i] % 2 == 0 && arr[i] < minEven {
            minEven = arr[i]
            minEvenIndex = i
        }
    }
    return [minEven, minEvenIndex]
}

// -----------------------------------------------------------------------------

struct PluckTests {
    static let allTests: [XCTest] = [
        PluckTests.test1,
        PluckTests.test2,
        PluckTests.test3,
        PluckTests.test4,
    ]

    static func test1() {
        let arr = [4, 2, 3]
        let expected = [2, 1]
        let actual = pluck(arr: arr)
        XCTAssertEqual(expected, actual)
    }

    static func test2() {
        let arr = [1, 2, 3]
        let expected = [2, 1]
        let actual = pluck(arr: arr)
        XCTAssertEqual(expected, actual)
    }

    static func test3() {
        let arr = []
        let expected = []
        let actual = pluck(arr: arr)
        XCTAssertEqual(expected, actual)
    }

    static func test4() {
        let arr = [5, 0, 3, 0, 4, 2]
        let expected = [0, 1]
        let actual = pluck(arr: arr)
        XCTAssertEqual(expected, actual)
    }
}

// -----------------------------------------------------------------------------

class PluckTestsRunner: XCTestCase {
    func testAll() {
        XCTestRunner.runAll(tests: PluckTests.allTests)
    }
}

// -----------------------------------------------------------------------------

let runner = PluckTestsRunner()
runner.testAll()<|endoftext|>// -----------------------------------------------------------------------------
// 1. Write a function that takes an array of numbers and returns the sum of all the numbers.
// Example: sum([1, 2, 3]) == 6
// Example: sum([1, 2, 3, 4, 5]) == 15
// Example: sum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55
// Example: sum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120
// Example: sum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 180
// Example: sum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]) == 240
// Example: sum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == 300
// Example: sum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 
static let allTests: [XCTest] = [ // cannot find type 'XCTest' in scope
let arr = [] // empty collection literal requires an explicit type
let expected = [] // empty collection literal requires an explicit type
let actual = pluck(arr: arr) // cannot convert value of type '[Any]' to expected argument type '[Int]'
XCTAssertEqual(expected, actual) // type 'Any' cannot conform to 'Equatable'
XCTestRunner.runAll(tests: PluckTests.allTests) // cannot find 'XCTestRunner' in scope

func search(lst: [Int]) -> Int {
    var max = -1
    var maxCount = 0
    var count = 0
    for i in lst {
        if i > max {
            max = i
            maxCount = 1
            count = 1
        } else if i == max {
            count += 1
            maxCount = max(maxCount, count)
        }
    }
    return maxCount > max ? max : -1
}
```swift
// You are given a non-empty array of positive integers. Return the greatest integer that is greater than 
// zero, and has a frequency greater than or equal to the value of the integer itself. 
// The frequency of an integer is the number of times it appears in the array.
// If no such a value exist, return -1.
// Examples:
// search(lst: [4, 1, 2, 2, 3, 1]) == 2
// search(lst: [1, 2, 2, 3, 3, 3, 4, 4, 4]) == 3
// search(lst: [5, 5, 4, 4, 4]) == -1
func search(lst: [Int]) -> Int {
    var max = -1
    var maxCount = 0
    var count = 0
    for i in lst {
        if i > max {
            max = i
            maxCount = 1
            count = 1
        } else if i == max {
            count += 1
            maxCount = max(maxCount, count)
        }
    }
    return maxCount > max ? max : -1
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------------------------------------------------------------------------
maxCount = max(maxCount, count) // cannot call value of non-function type 'Int'

func search(lst: [Int]) -> Int {
    var max = -1
    var count = 0
    var dict = [Int: Int]()
    for i in lst {
        if dict[i] == nil {
            dict[i] = 1
        } else {
            dict[i] += 1
        }
    }
    for i in dict {
        if i.value > count {
            max = i.key
            count = i.value
        }
    }
    return max
}
```swift
// You are given a non-empty array of positive integers. Return the greatest integer that is greater than 
// zero, and has a frequency greater than or equal to the value of the integer itself. 
// The frequency of an integer is the number of times it appears in the array.
// If no such a value exist, return -1.
// Examples:
// search(lst: [4, 1, 2, 2, 3, 1]) == 2
// search(lst: [1, 2, 2, 3, 3, 3, 4, 4, 4]) == 3
// search(lst: [5, 5, 4, 4, 4]) == -1
func search(lst: [Int]) -> Int {
    var max = -1
    var count = 0
    var dict = [Int: Int]()
    for i in lst {
        if dict[i] == nil {
            dict[i] = 1
        } else {
            dict[i] += 1
        }
    }
    for i in dict {
        if i.value > count {
            max = i.key
            count = i.value
        }
    }
    return max
}

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ---------
dict[i] += 1 // value of optional type 'Int?' must be unwrapped to a value of type 'Int'

func search(lst: [Int]) -> Int {
    var result = -1
    var max = 0
    var dict = [Int: Int]()
    for i in lst {
        if dict[i] == nil {
            dict[i] = 1
        } else {
            dict[i] += 1
        }
        if dict[i] > max {
            max = dict[i]
        }
    }
    for i in dict {
        if i.value >= i.key {
            result = i.key
            break
        }
    }
    return result
}
```swift
// You are given a non-empty array of positive integers. Return the greatest integer that is greater than 
// zero, and has a frequency greater than or equal to the value of the integer itself. 
// The frequency of an integer is the number of times it appears in the array.
// If no such a value exist, return -1.
// Examples:
// search(lst: [4, 1, 2, 2, 3, 1]) == 2
// search(lst: [1, 2, 2, 3, 3, 3, 4, 4, 4]) == 3
// search(lst: [5, 5, 4, 4, 4]) == -1
func search(lst: [Int]) -> Int {
    var result = -1
    var max = 0
    var dict = [Int: Int]()
    for i in lst {
        if dict[i] == nil {
            dict[i] = 1
        } else {
            dict[i] += 1
        }
        if dict[i] > max {
            max = dict[i]
        }
    }
    for i in dict {
        if i.value >= i.key {
            result = i.key
            break
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------
dict[i] += 1 // value of optional type 'Int?' must be unwrapped to a value of type 'Int'
if dict[i] > max { // value of optional type 'Int?' must be unwrapped to a value of type 'Int'
max = dict[i] // value of optional type 'Int?' must be unwrapped to a value of type 'Int'

func search(lst: [Int]) -> Int {
    var max = 0
    var maxFreq = 0
    var dict = [Int: Int]()
    for i in lst {
        if dict[i] == nil {
            dict[i] = 1
        } else {
            dict[i] += 1
        }
        if dict[i] > maxFreq {
            maxFreq = dict[i]
            max = i
        }
    }
    if maxFreq >= max {
        return max
    } else {
        return -1
    }
}
```swift
// You are given a non-empty array of positive integers. Return the greatest integer that is greater than 
// zero, and has a frequency greater than or equal to the value of the integer itself. 
// The frequency of an integer is the number of times it appears in the array.
// If no such a value exist, return -1.
// Examples:
// search(lst: [4, 1, 2, 2, 3, 1]) == 2
// search(lst: [1, 2, 2, 3, 3, 3, 4, 4, 4]) == 3
// search(lst: [5, 5, 4, 4, 4]) == -1
func search(lst: [Int]) -> Int {
    var max = 0
    var maxFreq = 0
    var dict = [Int: Int]()
    for i in lst {
        if dict[i] == nil {
            dict[i] = 1
        } else {
            dict[i] += 1
        }
        if dict[i] > maxFreq {
            maxFreq = dict[i]
            max = i
        }
    }
    if maxFreq >= max {
        return max
    } else {
        return -1
    }
}

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------
dict[i] += 1 // value of optional type 'Int?' must be unwrapped to a value of type 'Int'
if dict[i] > maxFreq { // value of optional type 'Int?' must be unwrapped to a value of type 'Int'
maxFreq = dict[i] // value of optional type 'Int?' must be unwrapped to a value of type 'Int'

func search(lst: [Int]) -> Int {
    var max = -1
    var count = 0
    var lst = lst.sorted()
    for i in lst {
        if i > max {
            max = i
            count = 1
        } else if i == max {
            count += 1
        }
    }
    if count >= max {
        return max
    } else {
        return -1
    }
}
```swift
// You are given a non-empty array of positive integers. Return the greatest integer that is greater than 
// zero, and has a frequency greater than or equal to the value of the integer itself. 
// The frequency of an integer is the number of times it appears in the array.
// If no such a value exist, return -1.
// Examples:
// search(lst: [4, 1, 2, 2, 3, 1]) == 2
// search(lst: [1, 2, 2, 3, 3, 3, 4, 4, 4]) == 3
// search(lst: [5, 5, 4, 4, 4]) == -1
func search(lst: [Int]) -> Int {
    var max = -1
    var count = 0
    var lst = lst.sorted()
    for i in lst {
        if i > max {
            max = i
            count = 1
        } else if i == max {
            count += 1
        }
    }
    if count >= max {
        return max
    } else {
        return -1
    }
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
var lst = lst.sorted() // variable 'lst' was never mutated; consider changing to 'let' constant
 // XCTAssertTrue failed

func search(lst: [Int]) -> Int {
    var max = -1
    var maxCount = 0
    var count = 0
    for i in lst {
        if i > max {
            max = i
            maxCount = 1
        } else if i == max {
            maxCount += 1
        }
        if i > 0 {
            if i == count {
                count += 1
            } else {
                count = 1
            }
        }
    }
    if maxCount > count {
        return max
    } else {
        return -1
    }
}
```swift
// You are given a non-empty array of positive integers. Return the greatest integer that is greater than 
// zero, and has a frequency greater than or equal to the value of the integer itself. 
// The frequency of an integer is the number of times it appears in the array.
// If no such a value exist, return -1.
// Examples:
// search(lst: [4, 1, 2, 2, 3, 1]) == 2
// search(lst: [1, 2, 2, 3, 3, 3, 4, 4, 4]) == 3
// search(lst: [5, 5, 4, 4, 4]) == -1
func search(lst: [Int]) -> Int {
    var max = -1
    var maxCount = 0
    var count = 0
    for i in lst {
        if i > max {
            max = i
            maxCount = 1
        } else if i == max {
            maxCount += 1
        }
        if i > 0 {
            if i == count {
                count += 1
            } else {
                count = 1
            }
        }
    }
    if maxCount > count {
        return max
    } else {
        return -1
    }
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ------------
 // XCTAssertTrue failed

func search(lst: [Int]) -> Int {
    var max = -1
    var maxCount = 0
    for i in lst {
        var count = 0
        for j in lst {
            if i == j {
                count += 1
            }
        }
        if count > maxCount {
            maxCount = count
            max = i
        }
    }
    return max
}
```swift
// You are given a non-empty array of positive integers. Return the greatest integer that is greater than 
// zero, and has a frequency greater than or equal to the value of the integer itself. 
// The frequency of an integer is the number of times it appears in the array.
// If no such a value exist, return -1.
// Examples:
// search(lst: [4, 1, 2, 2, 3, 1]) == 2
// search(lst: [1, 2, 2, 3, 3, 3, 4, 4, 4]) == 3
// search(lst: [5, 5, 4, 4, 4]) == -1
func search(lst: [Int]) -> Int {
    var max = -1
    var maxCount = 0
    for i in lst {
        var count = 0
        for j in lst {
            if i == j {
                count += 1
            }
        }
        if count > maxCount {
            maxCount = count
            max = i
        }
    }
    return max
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ------------------------
 // XCTAssertTrue failed

func search(lst: [Int]) -> Int {
    var max = -1
    var maxCount = 0
    var maxFreq = 0
    var count = 0
    var freq = 0
    for i in lst {
        count = 0
        freq = 0
        for j in lst {
            if i == j {
                count += 1
            }
        }
        if count > maxCount {
            maxCount = count
            max = i
        }
        if count == maxCount {
            if i > max {
                max = i
            }
        }
        if count > maxFreq {
            maxFreq = count
        }
    }
    if maxFreq >= max {
        return max
    }
    return -1
}
```swift
// You are given a non-empty array of positive integers. Return the greatest integer that is greater than 
// zero, and has a frequency greater than or equal to the value of the integer itself. 
// The frequency of an integer is the number of times it appears in the array.
// If no such a value exist, return -1.
// Examples:
// search(lst: [4, 1, 2, 2, 3, 1]) == 2
// search(lst: [1, 2, 2, 3, 3, 3, 4, 4, 4]) == 3
// search(lst: [5, 5, 4, 4, 4]) == -1
func search(lst: [Int]) -> Int {
    var max = -1
    var maxCount = 0
    var maxFreq = 0
    var count = 0
    var freq = 0
    for i in lst {
        count = 0
        freq = 0
        for j in lst {
            if i == j {
                count += 1
            }
        }
        if count > maxCount {
            maxCount = count
            max = i
        }
        if count == maxCount {
            if i > max {
                max = i
            }
        }
        if count > maxFreq {
            maxFreq = count
        }
    }
    if maxFreq >= max {
        return max
    }
    return -1
}

print(search([4, 1, 2, 2, 3, 1]))
print(search([1, 2, 2, 3, 3, 3, 4, 4, 4]))
print(search([5, 5, 4, 4, 4]))
print(search([1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
var freq = 0 // variable 'freq' was written to, but never read
 // XCTAssertTrue failed

func search(lst: [Int]) -> Int {
    var max = -1
    var maxCount = 0
    var count = 0
    var maxFreq = 0
    for i in lst {
        if i > max {
            max = i
        }
        if i == max {
            count += 1
        }
        if i == maxCount {
            maxFreq += 1
        }
        if i > maxCount {
            maxCount = i
            maxFreq = 1
        }
    }
    if maxFreq > maxCount {
        return max
    }
    return maxCount
}
```swift
// You are given a non-empty array of positive integers. Return the greatest integer that is greater than 
// zero, and has a frequency greater than or equal to the value of the integer itself. 
// The frequency of an integer is the number of times it appears in the array.
// If no such a value exist, return -1.
// Examples:
// search(lst: [4, 1, 2, 2, 3, 1]) == 2
// search(lst: [1, 2, 2, 3, 3, 3, 4, 4, 4]) == 3
// search(lst: [5, 5, 4, 4, 4]) == -1
func search(lst: [Int]) -> Int {
    var max = -1
    var maxCount = 0
    var count = 0
    var maxFreq = 0
    for i in lst {
        if i > max {
            max = i
        }
        if i == max {
            count += 1
        }
        if i == maxCount {
            maxFreq += 1
        }
        if i > maxCount {
            maxCount = i
            maxFreq = 1
        }
    }
    if maxFreq > maxCount {
        return max
    }
    return maxCount
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

//
 // XCTAssertTrue failed

func search(lst: [Int]) -> Int {
    var max = -1
    var maxCount = 0
    var count = 0
    for i in lst {
        if i > max {
            max = i
            maxCount = 1
        } else if i == max {
            maxCount += 1
        }
        if i > 0 {
            count += 1
        }
    }
    if maxCount >= count {
        return max
    } else {
        return -1
    }
}
```swift
// You are given a non-empty array of positive integers. Return the greatest integer that is greater than 
// zero, and has a frequency greater than or equal to the value of the integer itself. 
// The frequency of an integer is the number of times it appears in the array.
// If no such a value exist, return -1.
// Examples:
// search(lst: [4, 1, 2, 2, 3, 1]) == 2
// search(lst: [1, 2, 2, 3, 3, 3, 4, 4, 4]) == 3
// search(lst: [5, 5, 4, 4, 4]) == -1
func search(lst: [Int]) -> Int {
    var max = -1
    var maxCount = 0
    var count = 0
    for i in lst {
        if i > max {
            max = i
            maxCount = 1
        } else if i == max {
            maxCount += 1
        }
        if i > 0 {
            count += 1
        }
    }
    if maxCount >= count {
        return max
    } else {
        return -1
    }
}

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
 // XCTAssertTrue failed

func strangeSortList(lst: [Int]) -> [Int] {
    if lst.isEmpty {
        return []
    }
    var result = [Int]()
    var sorted = lst.sorted()
    while !sorted.isEmpty {
        result.append(sorted.pop())
        result.append(sorted.pop())
    }
    return result
}
```swift
// Given array of integers, return array in strange order.
// Strange sorting, is when you start with the minimum value,
// then maximum of the remaining integers, then minimum and so on.
// Examples:
// strangeSortList(lst: [1, 2, 3, 4]) == [1, 4, 2, 3]
// strangeSortList(lst: [5, 5, 5, 5]) == [5, 5, 5, 5]
// strangeSortList(lst: [] as [Int]) == [] as [Int]
func strangeSortList(lst: [Int]) -> [Int] {
    if lst.isEmpty {
        return []
    }
    var result = [Int]()
    var sorted = lst.sorted()
    while !sorted.isEmpty {
        result.append(sorted.pop())
        result.append(sorted.pop())
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ------------------
result.append(sorted.pop()) // value of type '[Int]' has no member 'pop'
result.append(sorted.pop()) // value of type '[Int]' has no member 'pop'

func strangeSortList(lst: [Int]) -> [Int] {
    if lst.isEmpty {
        return []
    }
    var sorted = lst.sorted()
    var result = [Int]()
    while !sorted.isEmpty {
        result.append(sorted.pop())
        result.append(sorted.pop())
    }
    return result
}
```swift
// Given array of integers, return array in strange order.
// Strange sorting, is when you start with the minimum value,
// then maximum of the remaining integers, then minimum and so on.
// Examples:
// strangeSortList(lst: [1, 2, 3, 4]) == [1, 4, 2, 3]
// strangeSortList(lst: [5, 5, 5, 5]) == [5, 5, 5, 5]
// strangeSortList(lst: [] as [Int]) == [] as [Int]
func strangeSortList(lst: [Int]) -> [Int] {
    if lst.isEmpty {
        return []
    }
    var sorted = lst.sorted()
    var result = [Int]()
    while !sorted.isEmpty {
        result.append(sorted.pop())
        result.append(sorted.pop())
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// ---------------
result.append(sorted.pop()) // value of type '[Int]' has no member 'pop'
result.append(sorted.pop()) // value of type '[Int]' has no member 'pop'

func strangeSortList(lst: [Int]) -> [Int] {
    if lst.isEmpty {
        return []
    }
    var result = [Int]()
    var sorted = lst.sorted()
    while !sorted.isEmpty {
        result.append(sorted.pop())
        result.append(sorted.pop())
    }
    return result
}
```swift
// Given array of integers, return array in strange order.
// Strange sorting, is when you start with the minimum value,
// then maximum of the remaining integers, then minimum and so on.
// Examples:
// strangeSortList(lst: [1, 2, 3, 4]) == [1, 4, 2, 3]
// strangeSortList(lst: [5, 5, 5, 5]) == [5, 5, 5, 5]
// strangeSortList(lst: [] as [Int]) == [] as [Int]
func strangeSortList(lst: [Int]) -> [Int] {
    if lst.isEmpty {
        return []
    }
    var result = [Int]()
    var sorted = lst.sorted()
    while !sorted.isEmpty {
        result.append(sorted.pop())
        result.append(sorted.pop())
    }
    return result
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// ------------------------------------------
result.append(sorted.pop()) // value of type '[Int]' has no member 'pop'
result.append(sorted.pop()) // value of type '[Int]' has no member 'pop'

func strangeSortList(lst: [Int]) -> [Int] {
    if lst.isEmpty {
        return []
    }
    var sorted = lst.sorted()
    var result = [Int]()
    while !sorted.isEmpty {
        result.append(sorted.pop())
        result.append(sorted.pop())
    }
    return result
}
```swift
// Given array of integers, return array in strange order.
// Strange sorting, is when you start with the minimum value,
// then maximum of the remaining integers, then minimum and so on.
// Examples:
// strangeSortList(lst: [1, 2, 3, 4]) == [1, 4, 2, 3]
// strangeSortList(lst: [5, 5, 5, 5]) == [5, 5, 5, 5]
// strangeSortList(lst: [] as [Int]) == [] as [Int]
func strangeSortList(lst: [Int]) -> [Int] {
    if lst.isEmpty {
        return []
    }
    var sorted = lst.sorted()
    var result = [Int]()
    while !sorted.isEmpty {
        result.append(sorted.pop())
        result.append(sorted.pop())
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ------------------
result.append(sorted.pop()) // value of type '[Int]' has no member 'pop'
result.append(sorted.pop()) // value of type '[Int]' has no member 'pop'

func strangeSortList(lst: [Int]) -> [Int] {
    if lst.isEmpty {
        return []
    }
    var result = [Int]()
    var sorted = lst.sorted()
    while !sorted.isEmpty {
        result.append(sorted.pop())
        result.append(sorted.pop())
    }
    return result
}

public func strangeSortList<T: Comparable>(_ lst: [T]) -> [T] {
    if lst.isEmpty {
        return []
    }
    var result = [T]()
    var sorted = lst.sorted()
    while !sorted.isEmpty {
        result.append(sorted.pop())
        result.append(sorted.pop())
    }
    return result
}
```swift
// Given array of integers, return array in strange order.
// Strange sorting, is when you start with the minimum value,
// then maximum of the remaining integers, then minimum and so on.
// Examples:
// strangeSortList(lst: [1, 2, 3, 4]) == [1, 4, 2, 3]
// strangeSortList(lst: [5, 5, 5, 5]) == [5, 5, 5, 5]
// strangeSortList(lst: [] as [Int]) == [] as [Int]
func strangeSortList(lst: [Int]) -> [Int] {
    if lst.isEmpty {
        return []
    }
    var result = [Int]()
    var sorted = lst.sorted()
    while !sorted.isEmpty {
        result.append(sorted.pop())
        result.append(sorted.pop())
    }
    return result
}

// ----------------------------------------------------------------------------

public func strangeSortList<T: Comparable>(_ lst: [T]) -> [T] {
    if lst.isEmpty {
        return []
    }
    var result = [T]()
    var sorted = lst.sorted()
    while !sorted.isEmpty {
        result.append(sorted.pop())
        result.append(sorted.pop())
    }
    return result
}

// ----------------------------------------------------------------------------

public func strangeSortList<T: Comparable>(_ lst: [T]) -> [T] {
    if lst.isEmpty {
        return []
    }
    var result = [T]()
    var sorted = lst.sorted()
    while !sorted.isEmpty {
        result.append(sorted.pop())
        result.append(sorted.pop())
    }
    return result
}

// ----------------------------------------------------------------------------

public func strangeSortList<T: Comparable>(_ lst: [T]) -> [T] {
    if lst.isEmpty {
        return []
    }
    var result = [T]()
    var sorted = lst.sorted()
    while !sorted.isEmpty {
        result.append(sorted.pop())
        result.append(sorted.pop())
    }
    return result
}

// ----------------------------------------------------------------------------

public func strangeSortList<T: Comparable>(_ lst: [T]) -> [T] {
    if lst.isEmpty {
        return []
    }
    var result = [T]()
    var sorted = lst.sorted()
    while !sorted.isEmpty {
        result.append(sorted.pop())
        result.append(sorted.pop())
    }
    return result
}

// ----------------------------------------------------------------------------

public func strangeSortList<T: Comparable>(_ lst: [T]) -> [T] {
    if lst.isEmpty {
        return []
    }
    var result = [T]()
    var sorted = lst.sorted()
    while !sorted.isEmpty {
        result.append(sorted.pop())
        result.append(sorted.pop())
    }
    return result
}

// ----------------------------------------------------------------------------

public func strangeSortList<T: Comparable>(_ lst: [T]) -> [T] {
    if lst.isEmpty {
        return []
    }
    var result = [T]()
    var sorted = lst.sorted()
    while !sorted.isEmpty {
        result.append(sorted.pop())
        result.append(sorted.pop())
    }
    return result
}

// ----------------------------------------------------------------------------

public func strangeSortList<T: Comparable>(_ lst: [T]) -> [T] {
    if lst.isEmpty {
        return []
    }
    var result = [T]()
    var sorted = lst.sorted()
    while !sorted.isEmpty {
        result.append(sorted.pop())
        result.append(sorted.pop())
    }
    return result
}

// ----------------------------------------------------------------------------
result.append(sorted.pop()) // value of type '[Int]' has no member 'pop'
result.append(sorted.pop()) // value of type '[Int]' has no member 'pop'
result.append(sorted.pop()) // value of type '[T]' has no member 'pop'
result.append(sorted.pop()) // value of type '[T]' has no member 'pop'

func strangeSortList(lst: [Int]) -> [Int] {
    if lst.isEmpty {
        return []
    }
    var sorted = lst.sorted()
    var result = [Int]()
    while !sorted.isEmpty {
        result.append(sorted.pop())
        result.append(sorted.pop())
    }
    return result
}
```swift
// Given array of integers, return array in strange order.
// Strange sorting, is when you start with the minimum value,
// then maximum of the remaining integers, then minimum and so on.
// Examples:
// strangeSortList(lst: [1, 2, 3, 4]) == [1, 4, 2, 3]
// strangeSortList(lst: [5, 5, 5, 5]) == [5, 5, 5, 5]
// strangeSortList(lst: [] as [Int]) == [] as [Int]
func strangeSortList(lst: [Int]) -> [Int] {
    if lst.isEmpty {
        return []
    }
    var sorted = lst.sorted()
    var result = [Int]()
    while !sorted.isEmpty {
        result.append(sorted.pop())
        result.append(sorted.pop())
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ------------------
result.append(sorted.pop()) // value of type '[Int]' has no member 'pop'
result.append(sorted.pop()) // value of type '[Int]' has no member 'pop'

func strangeSortList(lst: [Int]) -> [Int] {
    var result = lst
    for i in 1...lst.count {
        result.sort()
        result.reverse()
    }
    return result
}
```swift
// Given array of integers, return array in strange order.
// Strange sorting, is when you start with the minimum value,
// then maximum of the remaining integers, then minimum and so on.
// Examples:
// strangeSortList(lst: [1, 2, 3, 4]) == [1, 4, 2, 3]
// strangeSortList(lst: [5, 5, 5, 5]) == [5, 5, 5, 5]
// strangeSortList(lst: [] as [Int]) == [] as [Int]
func strangeSortList(lst: [Int]) -> [Int] {
    var result = lst
    for i in 1...lst.count {
        result.sort()
        result.reverse()
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// ------------------------------
for i in 1...lst.count { // immutable value 'i' was never used; consider replacing with '_' or removing it
 // XCTAssertTrue failed

func strangeSortList(lst: [Int]) -> [Int] {
    if lst.isEmpty {
        return []
    }
    var result = [Int]()
    var sorted = lst.sorted()
    while !sorted.isEmpty {
        result.append(sorted.pop())
        result.append(sorted.pop())
    }
    return result
}
```swift
// Given array of integers, return array in strange order.
// Strange sorting, is when you start with the minimum value,
// then maximum of the remaining integers, then minimum and so on.
// Examples:
// strangeSortList(lst: [1, 2, 3, 4]) == [1, 4, 2, 3]
// strangeSortList(lst: [5, 5, 5, 5]) == [5, 5, 5, 5]
// strangeSortList(lst: [] as [Int]) == [] as [Int]
func strangeSortList(lst: [Int]) -> [Int] {
    if lst.isEmpty {
        return []
    }
    var result = [Int]()
    var sorted = lst.sorted()
    while !sorted.isEmpty {
        result.append(sorted.pop())
        result.append(sorted.pop())
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// ---------------
result.append(sorted.pop()) // value of type '[Int]' has no member 'pop'
result.append(sorted.pop()) // value of type '[Int]' has no member 'pop'

func strangeSortList(lst: [Int]) -> [Int] {
    if lst.isEmpty {
        return []
    }
    var sorted = lst.sorted()
    var result = [Int]()
    while !sorted.isEmpty {
        result.append(sorted.pop())
        result.append(sorted.pop())
    }
    return result
}
```swift
// Given array of integers, return array in strange order.
// Strange sorting, is when you start with the minimum value,
// then maximum of the remaining integers, then minimum and so on.
// Examples:
// strangeSortList(lst: [1, 2, 3, 4]) == [1, 4, 2, 3]
// strangeSortList(lst: [5, 5, 5, 5]) == [5, 5, 5, 5]
// strangeSortList(lst: [] as [Int]) == [] as [Int]
func strangeSortList(lst: [Int]) -> [Int] {
    if lst.isEmpty {
        return []
    }
    var sorted = lst.sorted()
    var result = [Int]()
    while !sorted.isEmpty {
        result.append(sorted.pop())
        result.append(sorted.pop())
    }
    return result
}

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------

// ------------------------------------------
result.append(sorted.pop()) // value of type '[Int]' has no member 'pop'
result.append(sorted.pop()) // value of type '[Int]' has no member 'pop'

func strangeSortList(lst: [Int]) -> [Int] {
    var result = lst
    for _ in 1...lst.count {
        result.sort()
        result.reverse()
    }
    return result
}
```swift
// Given array of integers, return array in strange order.
// Strange sorting, is when you start with the minimum value,
// then maximum of the remaining integers, then minimum and so on.
// Examples:
// strangeSortList(lst: [1, 2, 3, 4]) == [1, 4, 2, 3]
// strangeSortList(lst: [5, 5, 5, 5]) == [5, 5, 5, 5]
// strangeSortList(lst: [] as [Int]) == [] as [Int]
func strangeSortList(lst: [Int]) -> [Int] {
    var result = lst
    for _ in 1...lst.count {
        result.sort()
        result.reverse()
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// ------------------------------
 // XCTAssertTrue failed

func triangleArea(a: Int, b: Int, c: Int) -> Double {
    if a + b > c && b + c > a && c + a > b {
        let s = (a + b + c) / 2
        return sqrt(s * (s - a) * (s - b) * (s - c))
    } else {
        return -1
    }
}

func reverseString(str: String) -> String {
    return String(str.reversed())
}
```swift
// Given the lengths of the three sides of a triangle. Return the area of
// the triangle rounded to 2 decimal points if the three sides form a valid triangle. 
// Otherwise return -1
// Three sides make a valid triangle when the sum of any two sides is greater 
// than the third side.
// Example:
// triangleArea(a: 3, b: 4, c: 5) == 6.0
// triangleArea(a: 1, b: 2, c: 10) == -1
func triangleArea(a: Int, b: Int, c: Int) -> Double {
    if a + b > c && b + c > a && c + a > b {
        let s = (a + b + c) / 2
        return sqrt(s * (s - a) * (s - b) * (s - c))
    } else {
        return -1
    }
}

// -----------------------------------------------------------------------------
// 10. Write a function that takes a string as input and returns the string
// with all the letters in reverse order.
// Example:
// reverseString("hello") == "olleh"
func reverseString(str: String) -> String {
    return String(str.reversed())
}

// -----------------------------------------------------------------------------
// 11. Write a function that takes a string as input and returns the string
// with all the letters in reverse order.
// Example:
// reverseString("hello") == "olleh"
func reverseString(str: String) -> String {
    return String(str.reversed())
}

// -----------------------------------------------------------------------------
// 12. Write a function that takes a string as input and returns the string
// with all the letters in reverse order.
// Example:
// reverseString("hello") == "olleh"
func reverseString(str: String) -> String {
    return String(str.reversed())
}

// -----------------------------------------------------------------------------
// 13. Write a function that takes a string as input and returns the string
// with all the letters in reverse order.
// Example:
// reverseString("hello") == "olleh"
func reverseString(str: String) -> String {
    return String(str.reversed())
}

// -----------------------------------------------------------------------------
// 14. Write a function that takes a string as input and returns the string
// with all the letters in reverse order.
// Example:
// reverseString("hello") == "olleh"
func reverseString(str: String) -> String {
    return String(str.reversed())
}

// -----------------------------------------------------------------------------
// 15. Write a function that takes a string as input and returns the string
// with all the letters in reverse order.
// Example:
// reverseString("hello") == "olleh"
func reverseString(str: String) -> String {
    return String(str.reversed())
}

// -----------------------------------------------------------------------------
// 16. Write a function that takes a string as input and returns the string
// with all the letters in reverse order.
// Example:
// reverseString("hello") == "olleh"
func reverseString(str: String) -> String {
    return String(str.reversed())
}

// -----------------------------------------------------------------------------
// 17. Write a function that takes a string as input and returns the string
// with all the letters in reverse order.
// Example:
// reverseString("hello") == "olleh"
func reverseString(str: String) -> String {
    return String(str.reversed())
}

// -----------------------------------------------------------------------------
// 18. Write a function that takes a string as input and returns the string
// with all the letters in reverse order.
// Example:
// reverseString("hello") == "olleh"
func reverseString(str: String) -> String {
    return String(str.reversed())
}

// -----------------------------------------------------------------------------
return sqrt(s * (s - a) * (s - b) * (s - c)) // cannot convert value of type 'Int' to expected argument type 'Double'

func triangleArea(a: Int, b: Int, c: Int) -> Double {
    if a + b > c && b + c > a && c + a > b {
        let s = (a + b + c) / 2
        return sqrt(s * (s - a) * (s - b) * (s - c))
    } else {
        return -1
    }
}

func changeCase(str: String) -> String {
    let arr = str.split(separator: " ")
    var newArr = [String]()
    for i in arr {
        if i.isEmpty {
            continue
        }
        newArr.append(i.capitalized)
    }
    return newArr.joined(separator: " ")
}

func stringTimes(str: String, n: Int) -> String {
    var newStr = ""
    for i in 1...n {
        newStr += str
    }
    return newStr
}

func isPalindrome(str: String) -> Bool {
    var newStr = ""
    for i in str.reversed() {
        newStr += i
    }
    return newStr == str
}

func transform(str: String) -> String {
    var newStr = ""
    for i in str.split(separator: " ") {
        if i.isEmpty {
            continue
        }
        newStr += i.capitalized
    }
    return newStr
}

func difference(nums: [Int]) -> Int {
    var min = nums[0]
    var max = nums[0]
    for i in nums {
        if i < min {
            min = i
        }
        if i > max {
            max = i
        }
    }
    return max - min
}

func average(nums: [Int]) -> Double {
    var sum = 0
    for i in nums {
        sum += i
    }
    return Double(sum) / Double(nums.count)
}
```swift
// Given the lengths of the three sides of a triangle. Return the area of
// the triangle rounded to 2 decimal points if the three sides form a valid triangle. 
// Otherwise return -1
// Three sides make a valid triangle when the sum of any two sides is greater 
// than the third side.
// Example:
// triangleArea(a: 3, b: 4, c: 5) == 6.0
// triangleArea(a: 1, b: 2, c: 10) == -1
func triangleArea(a: Int, b: Int, c: Int) -> Double {
    if a + b > c && b + c > a && c + a > b {
        let s = (a + b + c) / 2
        return sqrt(s * (s - a) * (s - b) * (s - c))
    } else {
        return -1
    }
}

// 2. Given a string, return a new string that has transformed based on the input:
// Change case of every character, ie. lower case to upper case, upper case to lower case.
// Reverse the order of words from the input.
// Note: You will have to handle multiple spaces, and leading/trailing spaces.
// Example:
// "Example Input" ==> "iNPUT eXAMPLE"
// "   Hello Case    " ==> "hELLO cASE   "
// "     " ==> ""
func changeCase(str: String) -> String {
    let arr = str.split(separator: " ")
    var newArr = [String]()
    for i in arr {
        if i.isEmpty {
            continue
        }
        newArr.append(i.capitalized)
    }
    return newArr.joined(separator: " ")
}

// 3. Given a string and an integer, n, return a string that is n copies of the input string.
// Example:
// stringTimes("Hi", 2) == "HiHi"
// stringTimes("Hi", 3) == "HiHiHi"
// stringTimes("Hi", 1) == "Hi"
func stringTimes(str: String, n: Int) -> String {
    var newStr = ""
    for i in 1...n {
        newStr += str
    }
    return newStr
}

// 4. Given a string, return true if it is a palindrome.
// Example:
// isPalindrome("abba") == true
// isPalindrome("abcba") == true
// isPalindrome("peter") == false
func isPalindrome(str: String) -> Bool {
    var newStr = ""
    for i in str.reversed() {
        newStr += i
    }
    return newStr == str
}

// 5. Given a string, return a new string that has transformed based on the input:
// Change case of every character, ie. lower case to upper case, upper case to lower case.
// Reverse the order of words from the input.
// Note: You will have to handle multiple spaces, and leading/trailing spaces.
// Example:
// "Example Input" ==> "iNPUT eXAMPLE"
// "   Hello Case    " ==> "hELLO cASE   "
// "     " ==> ""
func transform(str: String) -> String {
    var newStr = ""
    for i in str.split(separator: " ") {
        if i.isEmpty {
            continue
        }
        newStr += i.capitalized
    }
    return newStr
}

// 6. Given an array of numbers, return the difference between the largest and smallest values.
// Example:
// difference([10, 15, 20, 2, 6]) == 18
// difference([-3, 4, -9, -1, -2, 15]) == 24
func difference(nums: [Int]) -> Int {
    var min = nums[0]
    var max = nums[0]
    for i in nums {
        if i < min {
            min = i
        }
        if i > max {
            max = i
        }
    }
    return max - min
}

// 7. Given an array of numbers, return the average number.
// Example:
// average([1, 5, 87, 45, 8, 8]) == 25
// average([9, 47, 23, 95, 16, 52]) == 40
func average(nums: [Int]) -> Double {
    var sum = 0
    for i in nums {
        sum += i
    }
    return Double(sum) / Double(nums.count)
}

// 8. Given
return sqrt(s * (s - a) * (s - b) * (s - c)) // cannot convert value of type 'Int' to expected argument type 'Double'
for i in 1...n { // immutable value 'i' was never used; consider replacing with '_' or removing it
newStr += i // cannot convert value of type 'String.Element' (aka 'Character') to expected argument type 'String'

func triangleArea(a: Int, b: Int, c: Int) -> Double {
    let s = (a + b + c) / 2
    return sqrt(s * (s - a) * (s - b) * (s - c))
}
```swift
// Given the lengths of the three sides of a triangle. Return the area of
// the triangle rounded to 2 decimal points if the three sides form a valid triangle. 
// Otherwise return -1
// Three sides make a valid triangle when the sum of any two sides is greater 
// than the third side.
// Example:
// triangleArea(a: 3, b: 4, c: 5) == 6.0
// triangleArea(a: 1, b: 2, c: 10) == -1
func triangleArea(a: Int, b: Int, c: Int) -> Double {
    let s = (a + b + c) / 2
    return sqrt(s * (s - a) * (s - b) * (s - c))
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ------------------------------------------
return sqrt(s * (s - a) * (s - b) * (s - c)) // cannot convert value of type 'Int' to expected argument type 'Double'

func triangleArea(a: Int, b: Int, c: Int) -> Double {
    if a + b > c && b + c > a && c + a > b {
        let s = (a + b + c) / 2
        return sqrt(s * (s - a) * (s - b) * (s - c))
    } else {
        return -1
    }
}

func reverseString(s: String) -> String {
    return String(s.reversed())
}

func numIdenticalPairs(nums: [Int]) -> Int {
    var count = 0
    for i in 0..<nums.count {
        for j in i+1..<nums.count {
            if nums[i] == nums[j] {
                count += 1
            }
        }
    }
    return count
}

func reversePairs(nums: [Int]) -> Int {
    var count = 0
    for i in 0..<nums.count {
        for j in i+1..<nums.count {
            if nums[i] > 2 * nums[j] {
                count += 1
            }
        }
    }
    return count
}
```swift
// Given the lengths of the three sides of a triangle. Return the area of
// the triangle rounded to 2 decimal points if the three sides form a valid triangle. 
// Otherwise return -1
// Three sides make a valid triangle when the sum of any two sides is greater 
// than the third side.
// Example:
// triangleArea(a: 3, b: 4, c: 5) == 6.0
// triangleArea(a: 1, b: 2, c: 10) == -1
func triangleArea(a: Int, b: Int, c: Int) -> Double {
    if a + b > c && b + c > a && c + a > b {
        let s = (a + b + c) / 2
        return sqrt(s * (s - a) * (s - b) * (s - c))
    } else {
        return -1
    }
}

// -----------------------------------------------------------------------------
// 1. Write a function that takes a string as input and returns the string reversed.
// Example:
// reverseString("hello") == "olleh"
func reverseString(s: String) -> String {
    return String(s.reversed())
}

// -----------------------------------------------------------------------------
// 2. Given an array of integers nums, return the number of good pairs.
// A pair (i, j) is called good if nums[i] == nums[j] and i < j.
// Example:
// nums = [1,2,3,1,1,3]
// Output: 4
// Explanation: There are 4 good pairs (0,3), (0,4), (3,4), (2,5) 0-indexed.
func numIdenticalPairs(nums: [Int]) -> Int {
    var count = 0
    for i in 0..<nums.count {
        for j in i+1..<nums.count {
            if nums[i] == nums[j] {
                count += 1
            }
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// 3. Given an integer array nums, return the number of reverse pairs in the array.
// A reverse pair is a pair (i, j) where 0 <= i < j < nums.length and nums[i] > 2 * nums[j].
// Example:
// nums = [1,3,2,3,1]
// Output: 2
// Explanation:
// There are 2 reverse pairs in nums:
// (1, 2) , (2, 4) .
func reversePairs(nums: [Int]) -> Int {
    var count = 0
    for i in 0..<nums.count {
        for j in i+1..<nums.count {
            if nums[i] > 2 * nums[j] {
                count += 1
            }
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// 4. Given an integer array nums, return the number of reverse pairs in the array.
// A reverse pair is a pair (i, j) where 0 <= i < j < nums.length and nums[i] > 2 * nums[j].
// Example:
// nums = [1,3,2,3,1]
// Output: 2
// Explanation:
// There are 2 reverse pairs in nums:
// (1, 2) , (2, 4) .
func reversePairs(nums: [Int]) -> Int {
    var count = 0
    for i in 0..<nums.count {
        for j in i+1..<nums.count {
            if nums[i] > 2 * nums[j] {
                count += 1
            }
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// 5. Given an integer array nums, return the number of reverse pairs in the array.
// A reverse pair is a pair (i, j) where 0 <= i < j < nums.length and nums[i] > 2 * nums[j].
// Example:
// nums = [1,3,2,3,1]
// Output: 2
// Explanation:
//
return sqrt(s * (s - a) * (s - b) * (s - c)) // cannot convert value of type 'Int' to expected argument type 'Double'

func triangleArea(a: Int, b: Int, c: Int) -> Double {
    let s = (a + b + c) / 2
    return sqrt(s * (s - a) * (s - b) * (s - c))
}
```swift
// Given the lengths of the three sides of a triangle. Return the area of
// the triangle rounded to 2 decimal points if the three sides form a valid triangle. 
// Otherwise return -1
// Three sides make a valid triangle when the sum of any two sides is greater 
// than the third side.
// Example:
// triangleArea(a: 3, b: 4, c: 5) == 6.0
// triangleArea(a: 1, b: 2, c: 10) == -1
func triangleArea(a: Int, b: Int, c: Int) -> Double {
    let s = (a + b + c) / 2
    return sqrt(s * (s - a) * (s - b) * (s - c))
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// ---------------------------------
return sqrt(s * (s - a) * (s - b) * (s - c)) // cannot convert value of type 'Int' to expected argument type 'Double'

func triangleArea(a: Int, b: Int, c: Int) -> Double {
    if a + b > c && b + c > a && c + a > b {
        let p = (a + b + c) / 2
        return sqrt(p * (p - a) * (p - b) * (p - c))
    } else {
        return -1
    }
}
```swift
// Given the lengths of the three sides of a triangle. Return the area of
// the triangle rounded to 2 decimal points if the three sides form a valid triangle. 
// Otherwise return -1
// Three sides make a valid triangle when the sum of any two sides is greater 
// than the third side.
// Example:
// triangleArea(a: 3, b: 4, c: 5) == 6.0
// triangleArea(a: 1, b: 2, c: 10) == -1
func triangleArea(a: Int, b: Int, c: Int) -> Double {
    if a + b > c && b + c > a && c + a > b {
        let p = (a + b + c) / 2
        return sqrt(p * (p - a) * (p - b) * (p - c))
    } else {
        return -1
    }
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ---------------------
return sqrt(p * (p - a) * (p - b) * (p - c)) // cannot convert value of type 'Int' to expected argument type 'Double'

func triangleArea(a: Int, b: Int, c: Int) -> Double {
    if a + b > c && b + c > a && c + a > b {
        let s = (a + b + c) / 2
        return sqrt(s * (s - a) * (s - b) * (s - c))
    } else {
        return -1
    }
}
```swift
// Given the lengths of the three sides of a triangle. Return the area of
// the triangle rounded to 2 decimal points if the three sides form a valid triangle. 
// Otherwise return -1
// Three sides make a valid triangle when the sum of any two sides is greater 
// than the third side.
// Example:
// triangleArea(a: 3, b: 4, c: 5) == 6.0
// triangleArea(a: 1, b: 2, c: 10) == -1
func triangleArea(a: Int, b: Int, c: Int) -> Double {
    if a + b > c && b + c > a && c + a > b {
        let s = (a + b + c) / 2
        return sqrt(s * (s - a) * (s - b) * (s - c))
    } else {
        return -1
    }
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// ------------------
return sqrt(s * (s - a) * (s - b) * (s - c)) // cannot convert value of type 'Int' to expected argument type 'Double'

func triangleArea(a: Int, b: Int, c: Int) -> Double {
    if a + b <= c || b + c <= a || c + a <= b {
        return -1
    }
    let s = (a + b + c) / 2
    return sqrt(s * (s - a) * (s - b) * (s - c))
}

func changeCase(input: String) -> String {
    var result = ""
    for char in input {
        if char == " " {
            result += " "
        } else {
            if char.isUpper {
                result += char.lower
            } else {
                result += char.upper
            }
        }
    }
    return result
}

func isPalindrome(input: String) -> Bool {
    var left = 0
    var right = input.length - 1
    while left < right {
        if input[left] != input[right] {
            return false
        }
        left += 1
        right -= 1
    }
    return true
}
```swift
// Given the lengths of the three sides of a triangle. Return the area of
// the triangle rounded to 2 decimal points if the three sides form a valid triangle. 
// Otherwise return -1
// Three sides make a valid triangle when the sum of any two sides is greater 
// than the third side.
// Example:
// triangleArea(a: 3, b: 4, c: 5) == 6.0
// triangleArea(a: 1, b: 2, c: 10) == -1
func triangleArea(a: Int, b: Int, c: Int) -> Double {
    if a + b <= c || b + c <= a || c + a <= b {
        return -1
    }
    let s = (a + b + c) / 2
    return sqrt(s * (s - a) * (s - b) * (s - c))
}

// -----------------------------------------------------------------------------
// 1.10.2
// Given a string, return a new string that has transformed based on the input:
// Change case of every character, ie. lower case to upper case, upper case to
// lower case. Reverse the order of words from the input.
// Note: You will have to handle multiple spaces, and leading/trailing spaces.
// Example:
// "Example Input" ==> "iNPUT eXAMPLE"
// "   Hello Case-Sensitive   " ==> "sENSEITaS eLCeH"
func changeCase(input: String) -> String {
    var result = ""
    for char in input {
        if char == " " {
            result += " "
        } else {
            if char.isUpper {
                result += char.lower
            } else {
                result += char.upper
            }
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.10.3
// Given a string, return the boolean True if it is a palindrome, and False
// otherwise.
// A palindrome is a word that's the same forwards and backwards.
// Example:
// isPalindrome("racecar") == True
// isPalindrome("hello") == False
func isPalindrome(input: String) -> Bool {
    var left = 0
    var right = input.length - 1
    while left < right {
        if input[left] != input[right] {
            return false
        }
        left += 1
        right -= 1
    }
    return true
}

// -----------------------------------------------------------------------------
// 1.10.4
// Given a string, return a new string that has transformed based on the input:
// Change case of every character, ie. lower case to upper case, upper case to
// lower case. Reverse the order of words from the input.
// Note: You will have to handle multiple spaces, and leading/trailing spaces.
// Example:
// "Example Input" ==> "iNPUT eXAMPLE"
// "   Hello Case-Sensitive   " ==> "sENSEITaS eLCeH"
func changeCase(input: String) -> String {
    var result = ""
    for char in input {
        if char == " " {
            result += " "
        } else {
            if char.isUpper {
                result += char.lower
            } else {
                result += char.upper
            }
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 1.10.5
// Given a string, return a new string that has transformed based on the input:
// Change case of every character, ie. lower case to upper case, upper case to
// lower case. Reverse the order of words from the input.
// Note: You will have to handle multiple spaces, and leading/trailing spaces.
// Example:
// "Example Input" ==> "iNPUT eXAMPLE"
// "   Hello Case-Sensitive   " ==> "sENSEITaS eLCeH"
func changeCase(input: String) -> String {
    var result = ""
    for char in input {
        if char == " " {
            result += " "
        } else {
            if char.isUpper {
                result += char.lower
            } else {
                result += char.upper
            }
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 
return sqrt(s * (s - a) * (s - b) * (s - c)) // cannot convert value of type 'Int' to expected argument type 'Double'
if char.isUpper { // value of type 'Character' has no member 'isUpper'
result += char.lower // value of type 'Character' has no member 'lower'
result += char.upper // value of type 'Character' has no member 'upper'
var right = input.length - 1 // value of type 'String' has no member 'length'

func triangleArea(a: Int, b: Int, c: Int) -> Double {
    if a + b > c && b + c > a && c + a > b {
        let s = (a + b + c) / 2
        return sqrt(s * (s - a) * (s - b) * (s - c))
    } else {
        return -1
    }
}

func reverseString(string: String) -> String {
    return string.reversed().join()
}

func isPalindrome(string: String) -> Bool {
    return string == string.reversed().join()
}

func reverseCharacters(string: String) -> String {
    return string.map(String.init).reversed().join()
}
```swift
// Given the lengths of the three sides of a triangle. Return the area of
// the triangle rounded to 2 decimal points if the three sides form a valid triangle. 
// Otherwise return -1
// Three sides make a valid triangle when the sum of any two sides is greater 
// than the third side.
// Example:
// triangleArea(a: 3, b: 4, c: 5) == 6.0
// triangleArea(a: 1, b: 2, c: 10) == -1
func triangleArea(a: Int, b: Int, c: Int) -> Double {
    if a + b > c && b + c > a && c + a > b {
        let s = (a + b + c) / 2
        return sqrt(s * (s - a) * (s - b) * (s - c))
    } else {
        return -1
    }
}

// -----------------------------------------------------------------------------
// 1.1.2
// Given a string, return the string reversed.
// Example:
// reverseString("hello") == "olleh"
func reverseString(string: String) -> String {
    return string.reversed().join()
}

// -----------------------------------------------------------------------------
// 1.1.3
// Given a string, return true if the string is a palindrome.
// A palindrome is a word, phrase, number, or other sequence of characters
// which reads the same backward as forward.
// Example:
// isPalindrome("racecar") == true
// isPalindrome("hello") == false
func isPalindrome(string: String) -> Bool {
    return string == string.reversed().join()
}

// -----------------------------------------------------------------------------
// 1.1.4
// Given a string, return a new string with the reversed order of characters.
// Example:
// reverseCharacters("hello") == "olleh"
func reverseCharacters(string: String) -> String {
    return string.map(String.init).reversed().join()
}

// -----------------------------------------------------------------------------
// 1.1.5
// Given a string, return a new string with the reversed order of characters.
// Example:
// reverseCharacters("hello") == "olleh"
func reverseCharacters(string: String) -> String {
    return string.map(String.init).reversed().join()
}

// -----------------------------------------------------------------------------
// 1.1.6
// Given a string, return a new string with the reversed order of characters.
// Example:
// reverseCharacters("hello") == "olleh"
func reverseCharacters(string: String) -> String {
    return string.map(String.init).reversed().join()
}

// -----------------------------------------------------------------------------
// 1.1.7
// Given a string, return a new string with the reversed order of characters.
// Example:
// reverseCharacters("hello") == "olleh"
func reverseCharacters(string: String) -> String {
    return string.map(String.init).reversed().join()
}

// -----------------------------------------------------------------------------
// 1.1.8
// Given a string, return a new string with the reversed order of characters.
// Example:
// reverseCharacters("hello") == "olleh"
func reverseCharacters(string: String) -> String {
    return string.map(String.init).reversed().join()
}

// -----------------------------------------------------------------------------
// 1.1.9
// Given a string, return a new string with the reversed order of characters.
// Example:
// reverseCharacters("hello") == "olleh"
func reverseCharacters(string: String) -> String {
    return string.map(String.init).reversed().join()
}

// -----------------------------------------------------------------------------
// 1.1.10
// Given a string, return a new string with the reversed order of characters.
// Example:
// reverse
return sqrt(s * (s - a) * (s - b) * (s - c)) // cannot convert value of type 'Int' to expected argument type 'Double'
return string.reversed().join() // reference to member 'join' cannot be resolved without a contextual type
return string == string.reversed().join() // reference to member 'join' cannot be resolved without a contextual type
return string.map(String.init).reversed().join() // reference to member 'join' cannot be resolved without a contextual type

func triangleArea(a: Int, b: Int, c: Int) -> Double {
    if a + b <= c || a + c <= b || b + c <= a {
        return -1
    } else {
        let s = (a + b + c) / 2
        return sqrt(s * (s - a) * (s - b) * (s - c))
    }
}

func sumNumbers(input: String) -> Int {
    var sum = 0
    var i = 0
    while i < input.count {
        if Character(input[i]).isDigit {
            var j = i + 1
            while j < input.count && Character(input[j]).isDigit {
                j += 1
            }
            sum += Int(input[i..<j])
            i = j
        } else {
            i += 1
        }
    }
    return sum
}
```swift
// Given the lengths of the three sides of a triangle. Return the area of
// the triangle rounded to 2 decimal points if the three sides form a valid triangle. 
// Otherwise return -1
// Three sides make a valid triangle when the sum of any two sides is greater 
// than the third side.
// Example:
// triangleArea(a: 3, b: 4, c: 5) == 6.0
// triangleArea(a: 1, b: 2, c: 10) == -1
func triangleArea(a: Int, b: Int, c: Int) -> Double {
    if a + b <= c || a + c <= b || b + c <= a {
        return -1
    } else {
        let s = (a + b + c) / 2
        return sqrt(s * (s - a) * (s - b) * (s - c))
    }
}

// -----------------------------------------------------------------------------
// 2. Given a string, return the sum of the numbers appearing in the string,
// ignoring all other characters. A number is a series of 1 or more digit
// characters in a row. (Note: Character.isDigit(char) tests if a char is one
// of the chars '0', '1', .. '9'. Integer.parseInt(string) converts a string to an
// int.)
// Example:
// sumNumbers("abc123xyz") == 123
// sumNumbers("aa11b33") == 44
// sumNumbers("7 11") == 18
func sumNumbers(input: String) -> Int {
    var sum = 0
    var i = 0
    while i < input.count {
        if Character(input[i]).isDigit {
            var j = i + 1
            while j < input.count && Character(input[j]).isDigit {
                j += 1
            }
            sum += Int(input[i..<j])
            i = j
        } else {
            i += 1
        }
    }
    return sum
}

// -----------------------------------------------------------------------------
// 3. Given a string, return the sum of the numbers appearing in the string,
// ignoring all other characters. A number is a series of 1 or more digit
// characters in a row. (Note: Character.isDigit(char) tests if a char is one
// of the chars '0', '1', .. '9'. Integer.parseInt(string) converts a string to an
// int.)
// Example:
// sumNumbers("abc123xyz") == 123
// sumNumbers("aa11b33") == 44
// sumNumbers("7 11") == 18
func sumNumbers(input: String) -> Int {
    var sum = 0
    var i = 0
    while i < input.count {
        if Character(input[i]).isDigit {
            var j = i + 1
            while j < input.count && Character(input[j]).isDigit {
                j += 1
            }
            sum += Int(input[i..<j])
            i = j
        } else {
            i += 1
        }
    }
    return sum
}

// -----------------------------------------------------------------------------
// 4. Given a string, return the sum of the numbers appearing in the string,
// ignoring all other characters. A number is a series of 1 or more digit
// characters in a row. (Note: Character.isDigit(char) tests if a char is one
// of the chars '0', '1', .. '9'. Integer.parseInt(string) converts a string to an
// int.)
// Example:
// sumNumbers("abc123xyz") == 123
// sumNumbers("aa11b33") == 44
// sumNumbers("7 11") == 18
func sumNumbers(input: String) -> Int {
    var sum = 0
    var i = 0
    while i < input.count {
        if Character(input[i]).isDigit {
            var j = i + 1
            while j < input.count && Character(input[j]).isDigit {
                j += 1
            }
            sum += Int(input[i..<j])
            i = j
        } else {
            i += 1
        }
return sqrt(s * (s - a) * (s - b) * (s - c)) // cannot convert value of type 'Int' to expected argument type 'Double'
if Character(input[i]).isDigit { // missing argument label 'extendedGraphemeClusterLiteral:' in call
if Character(input[i]).isDigit { // value of type 'Character' has no member 'isDigit'
while j < input.count && Character(input[j]).isDigit { // value of type 'Character' has no member 'isDigit'
while j < input.count && Character(input[j]).isDigit { // missing argument label 'extendedGraphemeClusterLiteral:' in call
sum += Int(input[i..<j]) // value of optional type 'Int?' must be unwrapped to a value of type 'Int'

func willItFly(q: [Int], w: Int) -> Bool {
    if q.count == 1 {
        return q[0] <= w
    }
    if q.count == 2 {
        return q[0] + q[1] <= w
    }
    if q.count == 3 {
        return q[0] + q[1] + q[2] <= w && q[0] + q[1] <= w
    }
    return false
}

func countCode(s: String) -> Int {
    var count = 0
    for i in 0..<s.count {
        if s[i..<i+3] == "code" {
            count += 1
        }
    }
    return count
}
```swift
// Write a function that returns true if the object q will fly, and false otherwise.
// The object q will fly if it's balanced (it is a palindromic array) and the sum of its elements is less than or equal the maximum possible weight w.
// Example:
// # 1+2 is less than the maximum possible weight, but it's unbalanced.
// # it's balanced, but 3+2+3 is more than the maximum possible weight.
// # 3+2+3 is less than the maximum possible weight, and it's balanced.
// # 3 is less than the maximum possible weight, and it's balanced.
// willItFly(q: [1, 2], w: 5) == false
// willItFly(q: [3, 2, 3], w: 1) == false
// willItFly(q: [3, 2, 3], w: 9) == true
// willItFly(q: [3], w: 5) == true
func willItFly(q: [Int], w: Int) -> Bool {
    if q.count == 1 {
        return q[0] <= w
    }
    if q.count == 2 {
        return q[0] + q[1] <= w
    }
    if q.count == 3 {
        return q[0] + q[1] + q[2] <= w && q[0] + q[1] <= w
    }
    return false
}

// 2.
// Write a function that returns the number of times the string "code" appears anywhere in the given string, except we'll accept any letter for the 'd', so "cope" and "cooe" count.
// Example:
// countCode("aaacodebbb") → 1
// countCode("codexxcode") → 2
// countCode("cozexxcope") → 2
func countCode(s: String) -> Int {
    var count = 0
    for i in 0..<s.count {
        if s[i..<i+3] == "code" {
            count += 1
        }
    }
    return count
}

// 3.
// Write a function that returns the number of times the string "code" appears anywhere in the given string, except we'll accept any letter for the 'd', so "cope" and "cooe" count.
// Example:
// countCode("aaacodebbb") → 1
// countCode("codexxcode") → 2
// countCode("cozexxcope") → 2
func countCode(s: String) -> Int {
    var count = 0
    for i in 0..<s.count {
        if s[i..<i+3] == "code" {
            count += 1
        }
    }
    return count
}

// 4.
// Write a function that returns the number of times the string "code" appears anywhere in the given string, except we'll accept any letter for the 'd', so "cope" and "cooe" count.
// Example:
// countCode("aaacodebbb") → 1
// countCode("codexxcode") → 2
// countCode("cozexxcope") → 2
func countCode(s: String) -> Int {
    var count = 0
    for i in 0..<s.count {
        if s[i..<i+3] == "code" {
            count += 1
        }
    }
    return count
}

// 5.
// Write a function that returns the number of times the string "code" appears anywhere in the given string, except we'll accept any letter for the 'd', so "cope" and "cooe" count.
// Example:
// countCode("aaacodebbb") → 1
// countCode("codexxcode") → 2
// countCode("cozexxcope") → 2
func countCode(s: String) -> Int {
    var count = 0
    for i in 0..<s.count {
        if s[i..<i+3] == "code" {
            count += 1
        }
    }
    return count
}

// 6.
// Write a function that returns the number of times the string "code" appears anywhere in the given string, except we'll accept any letter for the 'd', so "cope" and "cooe" count.
// Example:
// countCode("aaacodebbb") → 1
// countCode("codexxcode") → 2
// countCode("cozexxcope") → 2
func countCode(s: String) -> Int {
    var count = 0
    for i in 0..<s.count {
        if s[i..<i+3] == "code" {
            count += 1
        }
    }
    return count
}

// 7.
// Write a function that returns the number of times the string "code" appears anywhere in the given string, except we'll accept any letter for the 'd', so "cope" and "cooe" count.
if s[i..<i+3] == "code" { // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.

func willItFly(q: [Int], w: Int) -> Bool {
    var sum = 0
    for i in q {
        sum += i
    }
    if sum <= w {
        return true
    }
    var q2 = q.reversed()
    var sum2 = 0
    for i in q2 {
        sum2 += i
    }
    if sum2 <= w {
        return true
    }
    return false
}
```swift
// Write a function that returns true if the object q will fly, and false otherwise.
// The object q will fly if it's balanced (it is a palindromic array) and the sum of its elements is less than or equal the maximum possible weight w.
// Example:
// # 1+2 is less than the maximum possible weight, but it's unbalanced.
// # it's balanced, but 3+2+3 is more than the maximum possible weight.
// # 3+2+3 is less than the maximum possible weight, and it's balanced.
// # 3 is less than the maximum possible weight, and it's balanced.
// willItFly(q: [1, 2], w: 5) == false
// willItFly(q: [3, 2, 3], w: 1) == false
// willItFly(q: [3, 2, 3], w: 9) == true
// willItFly(q: [3], w: 5) == true
func willItFly(q: [Int], w: Int) -> Bool {
    var sum = 0
    for i in q {
        sum += i
    }
    if sum <= w {
        return true
    }
    var q2 = q.reversed()
    var sum2 = 0
    for i in q2 {
        sum2 += i
    }
    if sum2 <= w {
        return true
    }
    return false
}

// 2.
// Write a function that returns true if the object q will fly, and false otherwise.
// The object q will fly if it's balanced (it is a palindromic array) and the sum of its elements is less than or equal the maximum possible weight w.
// Example:
// # 1+2 is less than the maximum possible weight, but it's unbalanced.
// # it's balanced, but 3+2+3 is more than the maximum possible weight.
// # 3+2+3 is less than the maximum possible weight, and it's balanced.
// # 3 is less than the maximum possible weight, and it's balanced.
// willItFly(q: [1, 2], w: 5) == false
// willItFly(q: [3, 2, 3], w: 1) == false
// willItFly(q: [3, 2, 3], w: 9) == true
// willItFly(q: [3], w: 5) == true
func willItFly(q: [Int], w: Int) -> Bool {
    var sum = 0
    for i in q {
        sum += i
    }
    if sum <= w {
        return true
    }
    var q2 = q.reversed()
    var sum2 = 0
    for i in q2 {
        sum2 += i
    }
    if sum2 <= w {
        return true
    }
    return false
}

// 3.
// Write a function that returns true if the object q will fly, and false otherwise.
// The object q will fly if it's balanced (it is a palindromic array) and the sum of its elements is less than or equal the maximum possible weight w.
// Example:
// # 1+2 is less than the maximum possible weight, but it's unbalanced.
// # it's balanced, but 3+2+3 is more than the maximum possible weight.
// # 3+2+3 is less than the maximum possible weight, and it's balanced.
// # 3 is less than the maximum possible weight, and it's balanced.
// willItFly(q: [1, 2], w: 5) == false
// willItFly(q: [3, 2, 3], w: 1) == false
// willItFly(q: [3, 2, 3], w: 9) == true
// willItFly(q: [3], w: 5) == true
func willItFly(q: [Int], w: Int) -> Bool {
    var sum = 0
    for i in q {
        sum += i
    }
    if sum <= w {
        return true
    }
    var q2 = q.reversed()
    var sum2 = 0
    for i in q2 {
        sum2 += i
    }
    if sum2 <= w {
        return true
    }
    return false
}

// 4.
// Write a function that returns true if the object q will fly, and false otherwise.
// The object q will fly if it's balanced (it is a palindromic array) and the sum of its elements is less than or equal the maximum possible weight w.
// Example:
// # 1+2 is less than the maximum possible weight, but it's unbalanced.
// # it's balanced, but 3+2+3 is more than the maximum possible weight.
// # 3+2+3 is less than the maximum possible weight, and it's balanced.
// # 3 is less than the maximum possible weight, and it's balanced.
// willItFly(q: [1, 2], w: 5) == false
// willItFly(q: [3, 2, 3], w: 1) == false
// willItFly(q: [3,
var q2 = q.reversed() // variable 'q2' was never mutated; consider changing to 'let' constant
 // XCTAssertTrue failed

func willItFly(q: [Int], w: Int) -> Bool {
    return q.reduce(0, { (sum, element) -> Int in
        if sum + element > w {
            return sum
        } else {
            return sum + element
        }
    }) == 0
}

func sum(array: [Int]) -> Int {
    return array.reduce(0, { (sum, element) -> Int in
        return sum + element
    })
}
```swift
// Write a function that returns true if the object q will fly, and false otherwise.
// The object q will fly if it's balanced (it is a palindromic array) and the sum of its elements is less than or equal the maximum possible weight w.
// Example:
// # 1+2 is less than the maximum possible weight, but it's unbalanced.
// # it's balanced, but 3+2+3 is more than the maximum possible weight.
// # 3+2+3 is less than the maximum possible weight, and it's balanced.
// # 3 is less than the maximum possible weight, and it's balanced.
// willItFly(q: [1, 2], w: 5) == false
// willItFly(q: [3, 2, 3], w: 1) == false
// willItFly(q: [3, 2, 3], w: 9) == true
// willItFly(q: [3], w: 5) == true
func willItFly(q: [Int], w: Int) -> Bool {
    return q.reduce(0, { (sum, element) -> Int in
        if sum + element > w {
            return sum
        } else {
            return sum + element
        }
    }) == 0
}

// -----------------------------------------------------------------------------
// 10. Write a function that returns the sum of the elements of an array.
// Example:
// sum([1, 2, 3]) == 6
func sum(array: [Int]) -> Int {
    return array.reduce(0, { (sum, element) -> Int in
        return sum + element
    })
}

// -----------------------------------------------------------------------------
// 11. Write a function that returns the sum of the elements of an array.
// Example:
// sum([1, 2, 3]) == 6
func sum(array: [Int]) -> Int {
    return array.reduce(0, { (sum, element) -> Int in
        return sum + element
    })
}

// -----------------------------------------------------------------------------
// 12. Write a function that returns the sum of the elements of an array.
// Example:
// sum([1, 2, 3]) == 6
func sum(array: [Int]) -> Int {
    return array.reduce(0, { (sum, element) -> Int in
        return sum + element
    })
}

// -----------------------------------------------------------------------------
// 13. Write a function that returns the sum of the elements of an array.
// Example:
// sum([1, 2, 3]) == 6
func sum(array: [Int]) -> Int {
    return array.reduce(0, { (sum, element) -> Int in
        return sum + element
    })
}

// -----------------------------------------------------------------------------
// 14. Write a function that returns the sum of the elements of an array.
// Example:
// sum([1, 2, 3]) == 6
func sum(array: [Int]) -> Int {
    return array.reduce(0, { (sum, element) -> Int in
        return sum + element
    })
}

// -----------------------------------------------------------------------------
// 15. Write a function that returns the sum of the elements of an array.
// Example:
// sum([1, 2, 3]) == 6
func sum(array: [Int]) -> Int {
    return array.reduce(0, { (sum, element) -> Int in
        return sum + element
    })
}

// -----------------------------------------------------------------------------
// 16. Write a function that returns the sum of the elements of an array.
// Example:
// sum([1, 2, 3]) == 6
func sum(array: [Int]) -> Int {
    return array.reduce(0, { (sum, element) -> Int in
        return sum + element
    })
}

// -----------------------------------------------------------------------------
// 17. Write a function that returns the sum of the elements of an array.
// Example:
// sum([1, 2, 3]) == 6
func sum(array: [Int]) -> Int {
    return array.reduce(0, { (sum, element) -> Int in
        return sum + element
    })
}

// -----------------------------------------------------------------------------
// 18. Write a function that returns the sum of the elements of an array.
// Example:
// sum([1, 2, 3]) == 6
func sum(array: [Int]) -> Int {
    return array.reduce(0, {
 // XCTAssertTrue failed

func willItFly(q: [Int], w: Int) -> Bool {
    return q.count == 1 || q.count == 2 ? q.sum() <= w : q.count == 3 && q.sum() <= w && q.max() <= w
}

func sum(a: [Int]) -> Int {
    return a.count == 0 ? 0 : a.reduce(0, \(sum, x) { sum + x })
}
```swift
// Write a function that returns true if the object q will fly, and false otherwise.
// The object q will fly if it's balanced (it is a palindromic array) and the sum of its elements is less than or equal the maximum possible weight w.
// Example:
// # 1+2 is less than the maximum possible weight, but it's unbalanced.
// # it's balanced, but 3+2+3 is more than the maximum possible weight.
// # 3+2+3 is less than the maximum possible weight, and it's balanced.
// # 3 is less than the maximum possible weight, and it's balanced.
// willItFly(q: [1, 2], w: 5) == false
// willItFly(q: [3, 2, 3], w: 1) == false
// willItFly(q: [3, 2, 3], w: 9) == true
// willItFly(q: [3], w: 5) == true
func willItFly(q: [Int], w: Int) -> Bool {
    return q.count == 1 || q.count == 2 ? q.sum() <= w : q.count == 3 && q.sum() <= w && q.max() <= w
}

// 2.
// Write a function that returns the sum of the elements of the array a.
// If the array is empty, the function should return 0.
// Example:
// sum([1, 2, 3]) == 6
// sum([]) == 0
func sum(a: [Int]) -> Int {
    return a.count == 0 ? 0 : a.reduce(0, \(sum, x) { sum + x })
}

// 3.
// Write a function that returns the sum of the elements of the array a.
// If the array is empty, the function should return 0.
// Example:
// sum([1, 2, 3]) == 6
// sum([]) == 0
func sum(a: [Int]) -> Int {
    return a.count == 0 ? 0 : a.reduce(0, \(sum, x) { sum + x })
}

// 4.
// Write a function that returns the sum of the elements of the array a.
// If the array is empty, the function should return 0.
// Example:
// sum([1, 2, 3]) == 6
// sum([]) == 0
func sum(a: [Int]) -> Int {
    return a.count == 0 ? 0 : a.reduce(0, \(sum, x) { sum + x })
}

// 5.
// Write a function that returns the sum of the elements of the array a.
// If the array is empty, the function should return 0.
// Example:
// sum([1, 2, 3]) == 6
// sum([]) == 0
func sum(a: [Int]) -> Int {
    return a.count == 0 ? 0 : a.reduce(0, \(sum, x) { sum + x })
}

// 6.
// Write a function that returns the sum of the elements of the array a.
// If the array is empty, the function should return 0.
// Example:
// sum([1, 2, 3]) == 6
// sum([]) == 0
func sum(a: [Int]) -> Int {
    return a.count == 0 ? 0 : a.reduce(0, \(sum, x) { sum + x })
}

// 7.
// Write a function that returns the sum of the elements of the array a.
// If the array is empty, the function should return 0.
// Example:
// sum([1, 2, 3]) == 6
// sum([]) == 0
func sum(a: [Int]) -> Int {
    return a.count == 0 ? 0 : a.reduce(0, \(sum, x) { sum + x })
}

// 8.
// Write a function that returns the sum of the elements of the array a.
// If the array is empty, the function should return 0.
// Example:
// sum([1, 2, 3]) == 6
// sum([]) == 0
func sum(a: [Int]) -> Int {
    return a.count == 0 ? 0 : a.reduce(0, \(sum, x) { sum + x })
}

// 9.
// Write a function that returns the sum of the elements of the array a.
// If the array is empty, the function should return 0.
// Example:
// sum([1, 2, 3]) == 6
// sum([]) == 0
func sum(a: [Int]) -> Int {
    return a.count == 0 ? 0 : a.reduce(0, \(sum, x) { sum + x })
}

// 10.
// Write a function that returns the sum of the elements of the array a.
// If the array is empty, the function should return 0.
// Example:
// sum([1, 2, 3]) == 6
// sum([]) == 0
func sum(a: [Int]) -> Int {
    return a.count == 0 ? 0 : a.reduce(0
return q.count == 1 || q.count == 2 ? q.sum() <= w : q.count == 3 && q.sum() <= w && q.max() <= w // value of optional type 'Int?' must be unwrapped to a value of type 'Int'
return q.count == 1 || q.count == 2 ? q.sum() <= w : q.count == 3 && q.sum() <= w && q.max() <= w // value of type '[Int]' has no member 'sum'
return q.count == 1 || q.count == 2 ? q.sum() <= w : q.count == 3 && q.sum() <= w && q.max() <= w // value of type '[Int]' has no member 'sum'
return a.count == 0 ? 0 : a.reduce(0, \(sum, x) { sum + x }) // extra argument in call
return a.count == 0 ? 0 : a.reduce(0, \(sum, x) { sum + x }) // cannot convert value of type 'WritableKeyPath<_, _>' to expected argument type '(Int, Int) throws -> Int'
return a.count == 0 ? 0 : a.reduce(0, \(sum, x) { sum + x }) // string interpolation can only appear inside a string literal
return a.count == 0 ? 0 : a.reduce(0, \(sum, x) { sum + x }) // cannot find 'x' in scope
return a.count == 0 ? 0 : a.reduce(0, \(sum, x) { sum + x }) // expected ',' separator
return a.count == 0 ? 0 : a.reduce(0, \(sum, x) { sum + x }) // cannot find 'x' in scope

func willItFly(q: [Int], w: Int) -> Bool {
    if q.count == 1 {
        return q[0] <= w
    }
    var sum = 0
    for i in q {
        sum += i
    }
    if sum > w {
        return false
    }
    return isPalindromic(q)
}

func isPalindromic(_ q: [Int]) -> Bool {
    var i = 0
    var j = q.count - 1
    while i < j {
        if q[i] != q[j] {
            return false
        }
        i += 1
        j -= 1
    }
    return true
}

import Foundation
```swift
// Write a function that returns true if the object q will fly, and false otherwise.
// The object q will fly if it's balanced (it is a palindromic array) and the sum of its elements is less than or equal the maximum possible weight w.
// Example:
// # 1+2 is less than the maximum possible weight, but it's unbalanced.
// # it's balanced, but 3+2+3 is more than the maximum possible weight.
// # 3+2+3 is less than the maximum possible weight, and it's balanced.
// # 3 is less than the maximum possible weight, and it's balanced.
// willItFly(q: [1, 2], w: 5) == false
// willItFly(q: [3, 2, 3], w: 1) == false
// willItFly(q: [3, 2, 3], w: 9) == true
// willItFly(q: [3], w: 5) == true
func willItFly(q: [Int], w: Int) -> Bool {
    if q.count == 1 {
        return q[0] <= w
    }
    var sum = 0
    for i in q {
        sum += i
    }
    if sum > w {
        return false
    }
    return isPalindromic(q)
}

func isPalindromic(_ q: [Int]) -> Bool {
    var i = 0
    var j = q.count - 1
    while i < j {
        if q[i] != q[j] {
            return false
        }
        i += 1
        j -= 1
    }
    return true
}<|endoftext|>//
//  main.swift
//  111
//
//  Created by 임현석 on 2022/02/03.
//

import Foundation

// 111. 최대 증가 부분 수열
// https://www.acmicpc.net/problem/11053

let input = try! readLine()!
let n = Int(input)

let arr = [0] + [Int(c)! for c in readLine()!.split(separator: " ")]

let dp = [0] * (n + 1)

for i in 1...n {
    for j in 1...i {
        if arr[j] < arr[i] {
            dp[i] = max(dp[i], dp[j] + 1)
        }
    }
}

print(max(dp))<|endoftext|>//
//  main.swift
//  110
//
//  Created by 임현석 on 2022/02/03.
//

import Foundation

// 110. 최대 증가 부분 수열
// https://www.acmicpc.net/problem/11053

let input = try! readLine()!
let n = Int(input)

let arr = [Int(c)! for c in readLine()!.split(separator: " ")]

var dp = [1] * n

for i in 1...n {
    for j in 1...i {
        if arr[j - 1] < arr[i] {
            dp[i] = max(dp[i], dp[j - 1] + 1)
        }
    }
}

print(max(dp))<|endoftext|>//
//  main.swift
//  111
//
//  Created by 임현석 on 2022/02/03.
//

import Foundation

// 111. 최대 증가 부분 수열
// https://www.acmicpc.net/problem/11053

let input = try! readLine()!
let n = Int(input)

let arr = [Int(c)! for c in readLine()!.split(separator: " ")]

var dp = [1] * n

for i in 1...n {
    for j in 1...i {
        if arr[j - 1] < arr[i] {
            dp[i] = max(dp[i], dp[j - 1] + 1)
        }
    }
}

print(max(dp))<|endoftext|>//
//  main.swift
//  111
//
//  Created by 임현석 on 2022/02/03.
//

import Foundation

// 111. 최대 증가 부분 수열
// https://www.acmicpc.net/problem/11053

let input = try! readLine()!
let n = Int(input)

let arr = [Int(c)

func willItFly(q: [Int], w: Int) -> Bool {
    var sum = 0
    for i in q {
        sum += i
    }
    if sum > w {
        return false
    }
    var left = 0
    var right = q.count - 1
    while left < right {
        if q[left] == q[right] {
            left += 1
            right -= 1
        } else {
            return false
        }
    }
    return true
}

import Foundation
```swift
// Write a function that returns true if the object q will fly, and false otherwise.
// The object q will fly if it's balanced (it is a palindromic array) and the sum of its elements is less than or equal the maximum possible weight w.
// Example:
// # 1+2 is less than the maximum possible weight, but it's unbalanced.
// # it's balanced, but 3+2+3 is more than the maximum possible weight.
// # 3+2+3 is less than the maximum possible weight, and it's balanced.
// # 3 is less than the maximum possible weight, and it's balanced.
// willItFly(q: [1, 2], w: 5) == false
// willItFly(q: [3, 2, 3], w: 1) == false
// willItFly(q: [3, 2, 3], w: 9) == true
// willItFly(q: [3], w: 5) == true
func willItFly(q: [Int], w: Int) -> Bool {
    var sum = 0
    for i in q {
        sum += i
    }
    if sum > w {
        return false
    }
    var left = 0
    var right = q.count - 1
    while left < right {
        if q[left] == q[right] {
            left += 1
            right -= 1
        } else {
            return false
        }
    }
    return true
}<|endoftext|>//
//  main.swift
//  1206
//
//  Created by 임명호 on 2021/09/09.
//

import Foundation

var input = Array(UInt8(readLine()!)!)

var result = 0

for i in input {
    if i == 49 {
        result += 1
    }
}

print(result)<|endoftext|>//
//  main.swift
//  1208
//
//  Created by 임명호 on 2021/09/09.
//

import Foundation

var input = Array(UInt8(readLine()!)!)

var result = 0

for i in input {
    if i == 49 {
        result += 1
    }
}

print(result)<|endoftext|>//
//  main.swift
//  1209
//
//  Created by 임명호 on 2021/09/09.
//

import Foundation

var input = Array(UInt8(readLine()!)!)

var result = 0

for i in input {
    if i == 49 {
        result += 1
    }
}

print(result)<|endoftext|>//
//  main.swift
//  1210
//
//  Created by 임명호 on 2021/09/09.
//

import Foundation

var input = Array(UInt8(readLine()!)!)

var result = 0

for i in input {
    if i == 49 {
        result += 1
    }
}

print(result)<|endoftext|>//
//  main.swift
//  1211
//
//  Created by 임명호 on 2021/09/09.
//

import Foundation

var input = Array(UInt8(readLine()!)!)

var result = 0

for i in input {
    if i == 49 {
        result += 1
    }
}

print(result)<|endoftext|>//
//  main.swift
//  1212
//
//  Created by 임명호 on 2021/09/09.
//

import Foundation

var input = Array(UInt8(readLine()!)!)

var result = 0

for i in input {
    if i == 49 {
        result += 1
    }
}

print(result)<|endoftext|>//
//  main.swift
//  1213
//
//  Created by 임명호 on 2021/09/09.
//

import Foundation

var input = Array(UInt8(readLine()!)!)

var result = 0

for i in input {
    if i == 49 {
        result += 1
    }
}

print(result)<|endoftext|>//
//  main.swift
//  1214
//
//  Created by 임명호 on 2021/09/09.
//

import Foundation

var input = Array(UInt8(readLine()!)!)

var result = 0

for i in input {
    if i == 49 {
        result += 1
    }
}

print(result)<|endoftext|>

func willItFly(q: [Int], w: Int) -> Bool {
    if q.count == 1 {
        return q[0] <= w
    }
    var sum = 0
    for i in q {
        sum += i
    }
    if sum > w {
        return false
    }
    var left = 0
    var right = q.count - 1
    var leftSum = 0
    var rightSum = 0
    while left < right {
        leftSum += q[left]
        rightSum += q[right]
        left += 1
        right -= 1
    }
    if leftSum == rightSum {
        return true
    }
    return false
}
```swift
// Write a function that returns true if the object q will fly, and false otherwise.
// The object q will fly if it's balanced (it is a palindromic array) and the sum of its elements is less than or equal the maximum possible weight w.
// Example:
// # 1+2 is less than the maximum possible weight, but it's unbalanced.
// # it's balanced, but 3+2+3 is more than the maximum possible weight.
// # 3+2+3 is less than the maximum possible weight, and it's balanced.
// # 3 is less than the maximum possible weight, and it's balanced.
// willItFly(q: [1, 2], w: 5) == false
// willItFly(q: [3, 2, 3], w: 1) == false
// willItFly(q: [3, 2, 3], w: 9) == true
// willItFly(q: [3], w: 5) == true
func willItFly(q: [Int], w: Int) -> Bool {
    if q.count == 1 {
        return q[0] <= w
    }
    var sum = 0
    for i in q {
        sum += i
    }
    if sum > w {
        return false
    }
    var left = 0
    var right = q.count - 1
    var leftSum = 0
    var rightSum = 0
    while left < right {
        leftSum += q[left]
        rightSum += q[right]
        left += 1
        right -= 1
    }
    if leftSum == rightSum {
        return true
    }
    return false
}

// 2.
// Given a string s, find the length of the longest substring without repeating characters.
// Example 1:
// Input: s = "abcabcbb"
// Output: 3
// Explanation: The answer is "abc", with the length of 3.
// Example 2:
// Input: s = "bbbbb"
// Output: 1
// Explanation: The answer is "b", with the length of 1.
// Example 3:
// Input: s = "pwwkew"
// Output: 3
// Explanation: The answer is "wke", with the length of 3.
// Notice that the answer must be a substring, "pwke" is a subsequence and not a substring.
// Example 4:
// Input: s = ""
// Output: 0
// Constraints:
// 0 <= s.length <= 5 * 104
// s consists of English letters, digits, symbols and spaces.

// 3.
// Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
// You may assume that each input would have exactly one solution, and you may not use the same element twice.
// You can return the answer in any order.
// Example 1:
// Input: nums = [2,7,11,15], target = 9
// Output: [0,1]
// Explanation: Because nums[0] + nums[1] == 9, we return [0, 1].
// Example 2:
// Input: nums = [3,2,4], target = 6
// Output: [1,2]
// Example 3:
// Input: nums = [3,3], target = 6
// Output: [0,1]
// Constraints:
// 2 <= nums.length <= 104
// -109 <= nums[i] <= 109
// -109 <= target <= 109
// Only one valid answer exists.
// Follow-up: Can you come up with an algorithm that is less than O(n2) time complexity?

// 4.
// Given an integer array nums, return the length of the longest strictly increasing subsequence.
// A subsequence is a sequence that can be derived from an array by deleting some or no elements without changing the order of the remaining elements. For example, [3,6,2,7] is a subsequence of the array [0,3,1,6,2,2,7].
// Example 1:
// Input: nums = [10,9,2,5,3,7,101,18]
// Output: 4
// Explanation: The longest increasing subsequence is [2,3,7,101], therefore the length is 4.
// Example 2:
// Input: nums = [0,1,0,3,2,3]
// Output: 4
// Example 3:
// Input: nums = [7,7,7,7,7,7,7]
// Output: 1
// Constraints:
// 1 <= nums.length <= 2500
// -104 <= nums[i] <= 104
// Follow up:
// Could you come up with the O(n2) solution?
// Could you come up with the O(n log(n)) solution using only constant space complexity?

// 5.
// Given an integer array nums, return the length of the longest strictly increasing subsequence.
// A subsequence is a sequence that can be derived from an array by deleting some or

func willItFly(q: [Int], w: Int) -> Bool {
    if q.count == 1 {
        return q[0] <= w
    }
    var sum = 0
    for i in q {
        sum += i
    }
    if sum > w {
        return false
    }
    return isPalindromic(q)
}

func isPalindromic(q: [Int]) -> Bool {
    var i = 0
    var j = q.count - 1
    while i < j {
        if q[i] != q[j] {
            return false
        }
        i += 1
        j -= 1
    }
    return true
}

import Foundation

func solution(n: Int) -> Int {
    var answer = 0
    var arr = [Int]()
    for i in 1...n {
        arr.append(i)
    }
    for i in 1...n {
        var sum = 0
        for j in 1...n {
            sum += arr[j-1]
            if sum > n {
                break
            }
            if sum == n {
                answer += 1
                break
            }
        }
    }
    return answer
}
```swift
// Write a function that returns true if the object q will fly, and false otherwise.
// The object q will fly if it's balanced (it is a palindromic array) and the sum of its elements is less than or equal the maximum possible weight w.
// Example:
// # 1+2 is less than the maximum possible weight, but it's unbalanced.
// # it's balanced, but 3+2+3 is more than the maximum possible weight.
// # 3+2+3 is less than the maximum possible weight, and it's balanced.
// # 3 is less than the maximum possible weight, and it's balanced.
// willItFly(q: [1, 2], w: 5) == false
// willItFly(q: [3, 2, 3], w: 1) == false
// willItFly(q: [3, 2, 3], w: 9) == true
// willItFly(q: [3], w: 5) == true
func willItFly(q: [Int], w: Int) -> Bool {
    if q.count == 1 {
        return q[0] <= w
    }
    var sum = 0
    for i in q {
        sum += i
    }
    if sum > w {
        return false
    }
    return isPalindromic(q)
}

func isPalindromic(q: [Int]) -> Bool {
    var i = 0
    var j = q.count - 1
    while i < j {
        if q[i] != q[j] {
            return false
        }
        i += 1
        j -= 1
    }
    return true
}<|endoftext|>//
//  main.swift
//  11000
//
//  Created by 윤승현 on 2021/04/17.
//

import Foundation

func solution(n: Int) -> Int {
    var answer = 0
    var arr = [Int]()
    for i in 1...n {
        arr.append(i)
    }
    for i in 1...n {
        var sum = 0
        for j in 1...n {
            sum += arr[j-1]
            if sum > n {
                break
            }
            if sum == n {
                answer += 1
                break
            }
        }
    }
    return answer
}

print(solution(15))<|endoftext|>//
//  main.swift
//  11000
//
//  Created by 윤승현 on 2021/04/17.
//

import Foundation

func solution(n: Int) -> Int {
    var answer = 0
    var arr = [Int]()
    for i in 1...n {
        arr.append(i)
    }
    for i in 1...n {
        var sum = 0
        for j in 1...n {
            sum += arr[j-1]
            if sum > n {
                break
            }
            if sum == n {
                answer += 1
                break
            }
        }
    }
    return answer
}

print(solution(15))<|endoftext|>//
//  main.swift
//  11000
//
//  Created by 윤승현 on 2021/04/17.
//

import Foundation

func solution(n: Int) -> Int {
    var answer = 0
    var arr = [Int]()
    for i in 1...n {
        arr.append(i)
    }
    for i in 1...n {
        var sum = 0
        for j in 1...n {
            sum += arr[j-1]
            if sum > n {
                break
            }
            if sum == n {
                answer += 1
                break
            }
        }
    }
    return answer
}

print(solution(15))<|endoftext|>//
//  main.swift
//  11000
//
//  Created by 윤승현 on 2021/04/17.
//

import Foundation

func solution(n: Int) -> Int {
    var answer = 0
    var arr = [Int]()
    for i in 1...n {
        arr.append(i)
    }
    for i in 1...n {
        var sum = 0
        for j in 1...n {
            sum += arr[j-1]
            if sum > n {
                break
            }
            if sum == n {
                answer += 1
                break
            }
        }
    }
    return answer
}

print(solution(15))<|endoftext|>//
//  main.swift
//  11000
//
//  Created by 윤승현 on 2021/04/17.
//

return isPalindromic(q) // missing argument label 'q:' in call
for i in 1...n { // immutable value 'i' was never used; consider replacing with '_' or removing it

func willItFly(q: [Int], w: Int) -> Bool {
    if q.count == 1 {
        return q[0] <= w
    }
    return q.reduce(0, { $0 + $1 }) <= w && isPalindromic(q)
}

func isPalindromic(_ q: [Int]) -> Bool {
    return q.reversed() == q
}

func countCode(s: String) -> Int {
    var count = 0
    for i in 0..<s.count {
        if s[i..<i+3] == "code" {
            count += 1
        }
    }
    return count
}

func equalIsNot(s: String) -> Bool {
    return s.count("is") == s.count("not")
}

func sumNumbers(s: String) -> Int {
    var sum = 0
    for c in s {
        if Character.isDigit(c) {
            sum += Int(c)
        }
    }
    return sum
}

func stringBits(s: String) -> String {
    var result = ""
    for i in 0..<s.count {
        if i % 2 == 0 {
            result += s[i]
        }
    }
    return result
}
```swift
// Write a function that returns true if the object q will fly, and false otherwise.
// The object q will fly if it's balanced (it is a palindromic array) and the sum of its elements is less than or equal the maximum possible weight w.
// Example:
// # 1+2 is less than the maximum possible weight, but it's unbalanced.
// # it's balanced, but 3+2+3 is more than the maximum possible weight.
// # 3+2+3 is less than the maximum possible weight, and it's balanced.
// # 3 is less than the maximum possible weight, and it's balanced.
// willItFly(q: [1, 2], w: 5) == false
// willItFly(q: [3, 2, 3], w: 1) == false
// willItFly(q: [3, 2, 3], w: 9) == true
// willItFly(q: [3], w: 5) == true
func willItFly(q: [Int], w: Int) -> Bool {
    if q.count == 1 {
        return q[0] <= w
    }
    return q.reduce(0, { $0 + $1 }) <= w && isPalindromic(q)
}

func isPalindromic(_ q: [Int]) -> Bool {
    return q.reversed() == q
}

// -----------------------------------------------------------------------------
// 2. Write a function that returns the number of times the string "code" appears anywhere in the given string, except we'll accept any letter for the 'd', so "cope" and "cooe" count.
// Example:
// countCode("aaacodebbb") → 1
// countCode("codexxcode") → 2
// countCode("cozexxcope") → 2
func countCode(s: String) -> Int {
    var count = 0
    for i in 0..<s.count {
        if s[i..<i+3] == "code" {
            count += 1
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// 3. Given a string, return true if the number of appearances of "is" anywhere in the string is equal to the number of appearances of "not" anywhere in the string (case sensitive).
// Example:
// equalIsNot("This is not") → false
// equalIsNot("This is notnot") → true
// equalIsNot("noisxxnotyynotxisi") → true
func equalIsNot(s: String) -> Bool {
    return s.count("is") == s.count("not")
}

// -----------------------------------------------------------------------------
// 4. Given a string, return the sum of the numbers appearing in the string, ignoring all other characters. A number is a series of 1 or more digit chars in a row. (Note: Character.isDigit(char) tests if a char is one of the chars '0', '1', .. '9'. Integer.parseInt(string) converts a string to an int.)
// Example:
// sumNumbers("abc123xyz") → 123
// sumNumbers("aa11b33") → 44
// sumNumbers("7 11") → 18
func sumNumbers(s: String) -> Int {
    var sum = 0
    for c in s {
        if Character.isDigit(c) {
            sum += Int(c)
        }
    }
    return sum
}

// -----------------------------------------------------------------------------
// 5. Given a string, return a new string made of every other char starting with the first, so "Hello" yields "Hlo".
// Example:
// stringBits("Hello") → "Hlo"
// stringBits("Hi") → "H"
// stringBits("Heeololeo") → "Hello"
func stringBits(s: String) -> String {
    var result = ""
    for i in 0..<s.count {
        if i % 2 == 0 {
            result += s[i]
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// 6. Given a non-empty string like "Code" return a string like "CCoCodCode".
// Example:
// stringSplosion("Code") → "CCoCodCode"
// stringSplosion("abc") → "aababc"
// stringSplosion("ab") → "aab"
func stringSplosion(s: String) -> String {
    var result = ""
    for i in 0..<s.count {
        result += s[0..<i+1]
    }
if s[i..<i+3] == "code" { // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.
return s.count("is") == s.count("not") // cannot call value of non-function type 'Int'
return s.count("is") == s.count("not") // cannot call value of non-function type 'Int'
if Character.isDigit(c) { // type 'Character' has no member 'isDigit'
sum += Int(c) // no exact matches in call to initializer
result += s[i] // no exact matches in call to subscript

func willItFly(q: [Int], w: Int) -> Bool {
    var sum = 0
    for i in q {
        sum += i
    }
    if sum > w {
        return false
    }
    var left = 0
    var right = q.count - 1
    while left < right {
        if q[left] == q[right] {
            left += 1
            right -= 1
        } else {
            return false
        }
    }
    return true
}

func sum(arr: [Int]) -> Int {
    var sum = 0
    for i in arr {
        sum += i
    }
    return sum
}
```swift
// Write a function that returns true if the object q will fly, and false otherwise.
// The object q will fly if it's balanced (it is a palindromic array) and the sum of its elements is less than or equal the maximum possible weight w.
// Example:
// # 1+2 is less than the maximum possible weight, but it's unbalanced.
// # it's balanced, but 3+2+3 is more than the maximum possible weight.
// # 3+2+3 is less than the maximum possible weight, and it's balanced.
// # 3 is less than the maximum possible weight, and it's balanced.
// willItFly(q: [1, 2], w: 5) == false
// willItFly(q: [3, 2, 3], w: 1) == false
// willItFly(q: [3, 2, 3], w: 9) == true
// willItFly(q: [3], w: 5) == true
func willItFly(q: [Int], w: Int) -> Bool {
    var sum = 0
    for i in q {
        sum += i
    }
    if sum > w {
        return false
    }
    var left = 0
    var right = q.count - 1
    while left < right {
        if q[left] == q[right] {
            left += 1
            right -= 1
        } else {
            return false
        }
    }
    return true
}

// 10. Write a function that returns the sum of the elements of an array of integers.
// Example:
// sum([1, 2, 3]) == 6
// sum([1, 2, 3, 4, 5]) == 15
func sum(arr: [Int]) -> Int {
    var sum = 0
    for i in arr {
        sum += i
    }
    return sum
}

// 11. Write a function that returns the sum of the elements of an array of integers.
// Example:
// sum([1, 2, 3]) == 6
// sum([1, 2, 3, 4, 5]) == 15
func sum(arr: [Int]) -> Int {
    var sum = 0
    for i in arr {
        sum += i
    }
    return sum
}

// 12. Write a function that returns the sum of the elements of an array of integers.
// Example:
// sum([1, 2, 3]) == 6
// sum([1, 2, 3, 4, 5]) == 15
func sum(arr: [Int]) -> Int {
    var sum = 0
    for i in arr {
        sum += i
    }
    return sum
}

// 13. Write a function that returns the sum of the elements of an array of integers.
// Example:
// sum([1, 2, 3]) == 6
// sum([1, 2, 3, 4, 5]) == 15
func sum(arr: [Int]) -> Int {
    var sum = 0
    for i in arr {
        sum += i
    }
    return sum
}

// 14. Write a function that returns the sum of the elements of an array of integers.
// Example:
// sum([1, 2, 3]) == 6
// sum([1, 2, 3, 4, 5]) == 15
func sum(arr: [Int]) -> Int {
    var sum = 0
    for i in arr {
        sum += i
    }
    return sum
}

// 15. Write a function that returns the sum of the elements of an array of integers.
// Example:
// sum([1, 2, 3]) == 6
// sum([1, 2, 3, 4, 5]) == 15
func sum(arr: [Int]) -> Int {
    var sum = 0
    for i in arr {
        sum += i
    }
    return sum
}

// 16. Write a function that returns the sum of the elements of an array of integers.
// Example:
// sum([1, 2, 3]) == 6
// sum([1, 2, 3, 4, 5]) == 15
func sum(arr: [Int]) -> Int {
    var sum = 0
    for i in arr {
        sum += i
    }
    return sum
}

// 17. Write a function that returns the sum of the elements of an array of integers.
// Example:
// sum([1, 2, 3]) == 6
// sum([1, 2, 3, 4, 5]) == 15
func sum(arr: [Int]) -> Int {
    var sum = 0
    for i in arr {
        sum += i
    }
    return sum
}

// 18. Write a function that returns the sum of the elements of an array of integers.
// Example:
// sum([1, 2, 3]) == 6
// sum([1, 2, 3, 4, 5]) == 15
func sum(arr: [Int]) -> Int {
    var sum = 0
    

func smallestChange(arr: [Int]) -> Int {
    var min = Int.max
    for i in 0..<arr.count {
        for j in 0..<arr.count {
            if i != j {
                var temp = arr[i]
                arr[i] = arr[j]
                arr[j] = temp
                var count = 0
                for k in 0..<arr.count / 2 {
                    if arr[k] != arr[arr.count - 1 - k] {
                        count += 1
                    }
                }
                min = min < count ? min : count
                temp = arr[i]
                arr[i] = arr[j]
                arr[j] = temp
            }
        }
    }
    return min
}

func sumOfPositives(arr: [Int]) -> Int {
    var sum = 0
    for i in 0..<arr.count {
        if arr[i] > 0 {
            sum += arr[i]
        }
    }
    return sum
}

func differenceMaxMin(arr: [Int]) -> Int {
    var max = arr[0]
    var min = arr[0]
    for i in 0..<arr.count {
        if arr[i] > max {
            max = arr[i]
        }
        if arr[i] < min {
            min = arr[i]
        }
    }
    return max - min
}

func checkForZero(arr: [Int]) -> Bool {
    for i in 0..<arr.count {
        if arr[i] == 0 {
            for j in i..<arr.count {
                if arr[j] == 1 {
                    return true
                }
            }
        }
    }
    return false
}
```swift
// Given an array arr of integers, find the minimum number of elements that
// need to be changed to make the array palindromic. A palindromic array is an array that
// is read the same backwards and forwards. In one change, you can change one element to any other element.
// For example:
// smallestChange(arr: [1, 2, 3, 5, 4, 7, 9, 6]) == 4
// smallestChange(arr: [1, 2, 3, 4, 3, 2, 2]) == 1
// smallestChange(arr: [1, 2, 3, 2, 1]) == 0
func smallestChange(arr: [Int]) -> Int {
    var min = Int.max
    for i in 0..<arr.count {
        for j in 0..<arr.count {
            if i != j {
                var temp = arr[i]
                arr[i] = arr[j]
                arr[j] = temp
                var count = 0
                for k in 0..<arr.count / 2 {
                    if arr[k] != arr[arr.count - 1 - k] {
                        count += 1
                    }
                }
                min = min < count ? min : count
                temp = arr[i]
                arr[i] = arr[j]
                arr[j] = temp
            }
        }
    }
    return min
}

// 14. Given an array of integers, return the sum of all the positive integers in the array.
// For example:
// sumOfPositives([1, 2, 3, -1, 5]) == 9
// sumOfPositives([-1, 2, 3, -1, 5]) == 10
// sumOfPositives([-1, -2, 3, -1, 5]) == 10
// sumOfPositives([-1, 2, 3, -1, -5]) == 0
func sumOfPositives(arr: [Int]) -> Int {
    var sum = 0
    for i in 0..<arr.count {
        if arr[i] > 0 {
            sum += arr[i]
        }
    }
    return sum
}

// 15. Given an array of integers, return the difference between the largest and smallest integers in the array.
// For example:
// differenceMaxMin([10, 4, 1, 4, -10, -50, 32, 21]) == 82
// differenceMaxMin([44, 32, 86, 19]) == 67
func differenceMaxMin(arr: [Int]) -> Int {
    var max = arr[0]
    var min = arr[0]
    for i in 0..<arr.count {
        if arr[i] > max {
            max = arr[i]
        }
        if arr[i] < min {
            min = arr[i]
        }
    }
    return max - min
}

// 16. Given an array of integers, return true if the array contains a 0 with a 1 somewhere later in the array.
// For example:
// checkForZero([1, 1, 1, 0, 1, 1, 1]) == true
// checkForZero([1, 1, 1, 1, 1]) == false
// checkForZero([1, 0, 1, 1, 1]) == true
// checkForZero([1, 1, 1]) == false
func checkForZero(arr: [Int]) -> Bool {
    for i in 0..<arr.count {
        if arr[i] == 0 {
            for j in i..<arr.count {
                if arr[j] == 1 {
                    return true
                }
            }
        }
    }
    return false
}

// 17. Given an array of integers, return the difference between the largest and smallest integers in the array.
// However, the larger of the two differences is not allowed to be less than 10.
// For example:
// LargestDifference([1, 2, 3, 4, 5, 10, 11]) == 9
// LargestDifference([1, 5, 10, 14]) == 13
// LargestDifference([1, 2]) == 1
// LargestDifference([1, 2, 3, 4, 100]) == 96
// LargestDifference([1, 2, 3, 4, 9, 10]) == 9
// LargestDifference([1, 2, 3, 4, 9, 10, 11]) == 9
// LargestDifference([1, 2, 3, 
arr[i] = arr[j] // cannot assign through subscript: 'arr' is a 'let' constant
arr[j] = temp // cannot assign through subscript: 'arr' is a 'let' constant
arr[i] = arr[j] // cannot assign through subscript: 'arr' is a 'let' constant
arr[j] = temp // cannot assign through subscript: 'arr' is a 'let' constant

func smallestChange(arr: [Int]) -> Int {
    var count = 0
    for i in 0..<arr.count/2 {
        if arr[i] != arr[arr.count - 1 - i] {
            count += 1
        }
    }
    return count
}

func sumOfPositives(arr: [Int]) -> Int {
    var sum = 0
    for i in arr {
        if i > 0 {
            sum += i
        }
    }
    return sum
}

func difference(arr: [Int]) -> Int {
    var max = arr[0]
    var min = arr[0]
    for i in arr {
        if i > max {
            max = i
        }
        if i < min {
            min = i
        }
    }
    return max - min
}
```swift
// Given an array arr of integers, find the minimum number of elements that
// need to be changed to make the array palindromic. A palindromic array is an array that
// is read the same backwards and forwards. In one change, you can change one element to any other element.
// For example:
// smallestChange(arr: [1, 2, 3, 5, 4, 7, 9, 6]) == 4
// smallestChange(arr: [1, 2, 3, 4, 3, 2, 2]) == 1
// smallestChange(arr: [1, 2, 3, 2, 1]) == 0
func smallestChange(arr: [Int]) -> Int {
    var count = 0
    for i in 0..<arr.count/2 {
        if arr[i] != arr[arr.count - 1 - i] {
            count += 1
        }
    }
    return count
}

// 2. Given an array of integers, return the sum of all the positive integers in the array.
// For example:
// sumOfPositives([1, 2, 3, -1, 5]) == 10
// sumOfPositives([-1, 2, 3, -1, 5]) == 10
// sumOfPositives([-1, 2, 3, -1, -2]) == 0
func sumOfPositives(arr: [Int]) -> Int {
    var sum = 0
    for i in arr {
        if i > 0 {
            sum += i
        }
    }
    return sum
}

// 3. Given an array of integers, return the difference between the largest and smallest integers in the array.
// For example:
// difference([1, 2, 3, 4, 5]) == 4
// difference([1, 2, 3, -4, 5]) == 9
// difference([1, 2, 3, -4, -5]) == 9
// difference([-5, -1, -7, -2]) == 13
func difference(arr: [Int]) -> Int {
    var max = arr[0]
    var min = arr[0]
    for i in arr {
        if i > max {
            max = i
        }
        if i < min {
            min = i
        }
    }
    return max - min
}

// 4. Given an array of integers, return the mean (average) of the integers.
// For example:
// mean([1, 2, 3, 4, 5]) == 3
// mean([1, 2, 3, 4, 5, 6]) == 3.5
// mean([1, 2, 3, 4, 5, 6, 7]) == 4
// mean([1, 2, 3, 4, 5, 6, 7, 8]) == 5
// mean([1, 2, 3, 4, 5, 6, 7, 8, 9]) == 6
// mean([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 7
// mean([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 8
// mean([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 9
// mean([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == 10
// mean([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 11
// mean([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 12
// mean([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 13
// mean([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]) == 14
// mean([1, 2, 3, 4, 5, 6, 7, 8, 9, 10,

func smallestChange(arr: [Int]) -> Int {
    var count = 0
    var left = 0
    var right = arr.count - 1
    while left < right {
        if arr[left] != arr[right] {
            count += 1
            if arr[left] < arr[right] {
                right -= 1
            } else {
                left += 1
            }
        } else {
            left += 1
            right -= 1
        }
    }
    return count
}

func firstRecurringCharacter(s: String) -> String? {
    var seen = [Character]()
    for c in s {
        if seen.contains(c) {
            return String(c)
        } else {
            seen.append(c)
        }
    }
    return nil
}

func sumOfPositives(arr: [Int]) -> Int {
    var sum = 0
    for i in arr {
        if i > 0 {
            sum += i
        }
    }
    return sum
}

func difference(arr: [Int]) -> Int {
    var max = arr[0]
    var min = arr[0]
    for i in arr {
        if i > max {
            max = i
        }
        if i < min {
            min = i
        }
    }
    return max - min
}

func has33(arr: [Int]) -> Bool {
    for i in arr {
        if i == 3 {
            if arr.contains(3) {
                return true
            }
        }
    }
    return false
}
```swift
// Given an array arr of integers, find the minimum number of elements that
// need to be changed to make the array palindromic. A palindromic array is an array that
// is read the same backwards and forwards. In one change, you can change one element to any other element.
// For example:
// smallestChange(arr: [1, 2, 3, 5, 4, 7, 9, 6]) == 4
// smallestChange(arr: [1, 2, 3, 4, 3, 2, 2]) == 1
// smallestChange(arr: [1, 2, 3, 2, 1]) == 0
func smallestChange(arr: [Int]) -> Int {
    var count = 0
    var left = 0
    var right = arr.count - 1
    while left < right {
        if arr[left] != arr[right] {
            count += 1
            if arr[left] < arr[right] {
                right -= 1
            } else {
                left += 1
            }
        } else {
            left += 1
            right -= 1
        }
    }
    return count
}

// 2. Given a string, return the first recurring character in it, or null if there is no recurring
// character.
// For example:
// firstRecurringCharacter("abcd") == null
// firstRecurringCharacter("abcdabcd") == "d"
// firstRecurringCharacter("abcdabcde") == "d"
// firstRecurringCharacter("abcde") == null
func firstRecurringCharacter(s: String) -> String? {
    var seen = [Character]()
    for c in s {
        if seen.contains(c) {
            return String(c)
        } else {
            seen.append(c)
        }
    }
    return nil
}

// 3. Given an array of integers, return the sum of all the positive integers in the array.
// For example:
// sumOfPositives([1, 2, 3, -1, 5]) == 9
// sumOfPositives([-1, 2, 3, -1, 5]) == 10
// sumOfPositives([-1, 2, 3, -1, -2]) == 0
func sumOfPositives(arr: [Int]) -> Int {
    var sum = 0
    for i in arr {
        if i > 0 {
            sum += i
        }
    }
    return sum
}

// 4. Given an array of integers, return the difference between the largest and smallest integers in the array.
// For example:
// difference([1, 2, 3, 4, 5]) == 4
// difference([1, 2, 3, -4, 5]) == 7
// difference([1, 2, 3, -4, -5]) == 8
// difference([-1, -2, -3, -4, -5]) == 8
// difference([1, 2, 3, 4, 5, 6]) == 5
// difference([1, 2, 3, 4, 5, 0]) == 5
// difference([1, 2, 3, 4, 5, -6]) == 11
func difference(arr: [Int]) -> Int {
    var max = arr[0]
    var min = arr[0]
    for i in arr {
        if i > max {
            max = i
        }
        if i < min {
            min = i
        }
    }
    return max - min
}

// 5. Given an array of integers, return true if the array contains a 3 next to a 3 somewhere.
// For example:
// has33([1, 3, 3]) == true
// has33([1, 3, 1, 3]) == true
// has33([3, 2, 5, 3]) == true
// has33([3, 2, 1, 3]) == false
// has33([3, 2, 3, 7]) == false
// has33([3, 3, 8, 3]) == false
func has33(arr: [Int]) -> Bool {
    for i in arr {
        if i == 3 {
            if arr.contains(3) {
                return true
            }
        }
    }
    return false
}

// 6. Given an array of ints, return true if the sequence of numbers 1, 2, 3 appears in the array somewhere.
// For example:
// array123([1, 2, 3, 1, 2, 3]) == true
// array123([1, 1, 2, 3, 1, 2, 3]) == true
// array123([1, 1, 2, 4, 1,
 // XCTAssertTrue failed

func smallestChange(arr: [Int]) -> Int {
    var min = Int.max
    for i in 0..<arr.count {
        var count = 0
        for j in 0..<arr.count {
            if i != j {
                if arr[i] != arr[j] {
                    count += 1
                }
            }
        }
        if count < min {
            min = count
        }
    }
    return min
}

func sumNumbers(s: String) -> Int {
    var sum = 0
    for c in s {
        if Character.isDigit(c) {
            sum += Int(c)
        }
    }
    return sum
}

func arrayFront9(nums: [Int]) -> Bool {
    for i in 0..<nums.count {
        if nums[i] == 9 {
            return true
        }
        if i >= 3 {
            break
        }
    }
    return false
}

func array123(nums: [Int]) -> Bool {
    for i in 0..<nums.count {
        if nums[i] == 1 {
            if i + 2 >= nums.count {
                return false
            }
            if nums[i + 1] == 2 && nums[i + 2] == 3 {
                return true
            }
        }
    }
    return false
}
```swift
// Given an array arr of integers, find the minimum number of elements that
// need to be changed to make the array palindromic. A palindromic array is an array that
// is read the same backwards and forwards. In one change, you can change one element to any other element.
// For example:
// smallestChange(arr: [1, 2, 3, 5, 4, 7, 9, 6]) == 4
// smallestChange(arr: [1, 2, 3, 4, 3, 2, 2]) == 1
// smallestChange(arr: [1, 2, 3, 2, 1]) == 0
func smallestChange(arr: [Int]) -> Int {
    var min = Int.max
    for i in 0..<arr.count {
        var count = 0
        for j in 0..<arr.count {
            if i != j {
                if arr[i] != arr[j] {
                    count += 1
                }
            }
        }
        if count < min {
            min = count
        }
    }
    return min
}

// ----------------------------------------------------------------------------------------------------------------------

// 10. Given a string, return the sum of the numbers appearing in the string, ignoring all other characters. A number is a series of 1 or more digit chars in a row. (Note: Character.isDigit(char) tests if a char is one of the chars '0' to '9'. String.charAt(int) returns the char at the given index.)
// sumNumbers("abc123xyz") → 123
// sumNumbers("aa11b33") → 44
// sumNumbers("7 11") → 18
func sumNumbers(s: String) -> Int {
    var sum = 0
    for c in s {
        if Character.isDigit(c) {
            sum += Int(c)
        }
    }
    return sum
}

// ----------------------------------------------------------------------------------------------------------------------

// 11. Given an array of ints, return true if one of the first 4 elements in the array is a 9. The array length may be less than 4.
// arrayFront9([1, 2, 9, 3, 4]) → true
// arrayFront9([1, 2, 3, 4, 9]) → false
// arrayFront9([1, 2, 3, 4, 5]) → false
func arrayFront9(nums: [Int]) -> Bool {
    for i in 0..<nums.count {
        if nums[i] == 9 {
            return true
        }
        if i >= 3 {
            break
        }
    }
    return false
}

// ----------------------------------------------------------------------------------------------------------------------

// 12. Given an array of ints, return true if the sequence of numbers 1, 2, 3 appears in the array somewhere.
// array123([1, 1, 2, 3, 1]) → true
// array123([1, 1, 2, 4, 1]) → false
// array123([1, 1, 2, 1, 2, 3]) → true
func array123(nums: [Int]) -> Bool {
    for i in 0..<nums.count {
        if nums[i] == 1 {
            if i + 2 >= nums.count {
                return false
            }
            if nums[i + 1] == 2 && nums[i + 2] == 3 {
                return true
            }
        }
    }
    return false
}

// ----------------------------------------------------------------------------------------------------------------------

// 13. Given 2 strings, a and b, return the number of the positions where they contain the same length 2 substring. So "xxcaazz" and "xxbaaz" yields 3, since the "xx", "aa", and "az" substrings appear in the same place in both strings.
// stringMatch("xxcaazz", "xxbaaz") → 3
// stringMatch("abc", "abc") → 2
// stringMatch("abc", "axc") → 0
func stringMatch(a: String, b: String)
if Character.isDigit(c) { // type 'Character' has no member 'isDigit'
sum += Int(c) // no exact matches in call to initializer

func smallestChange(arr: [Int]) -> Int {
    var count = 0
    var left = 0
    var right = arr.count - 1
    while left < right {
        if arr[left] != arr[right] {
            count += 1
            if arr[left] < arr[right] {
                right -= 1
            } else {
                left += 1
            }
        } else {
            left += 1
            right -= 1
        }
    }
    return count
}
```swift
// Given an array arr of integers, find the minimum number of elements that
// need to be changed to make the array palindromic. A palindromic array is an array that
// is read the same backwards and forwards. In one change, you can change one element to any other element.
// For example:
// smallestChange(arr: [1, 2, 3, 5, 4, 7, 9, 6]) == 4
// smallestChange(arr: [1, 2, 3, 4, 3, 2, 2]) == 1
// smallestChange(arr: [1, 2, 3, 2, 1]) == 0
func smallestChange(arr: [Int]) -> Int {
    var count = 0
    var left = 0
    var right = arr.count - 1
    while left < right {
        if arr[left] != arr[right] {
            count += 1
            if arr[left] < arr[right] {
                right -= 1
            } else {
                left += 1
            }
        } else {
            left += 1
            right -= 1
        }
    }
    return count
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // XCTAssertTrue failed

func smallestChange(arr: [Int]) -> Int {
    var count = 0
    var left = 0
    var right = arr.count - 1
    while left < right {
        if arr[left] != arr[right] {
            count += 1
        }
        left += 1
        right -= 1
    }
    return count
}
```swift
// Given an array arr of integers, find the minimum number of elements that
// need to be changed to make the array palindromic. A palindromic array is an array that
// is read the same backwards and forwards. In one change, you can change one element to any other element.
// For example:
// smallestChange(arr: [1, 2, 3, 5, 4, 7, 9, 6]) == 4
// smallestChange(arr: [1, 2, 3, 4, 3, 2, 2]) == 1
// smallestChange(arr: [1, 2, 3, 2, 1]) == 0
func smallestChange(arr: [Int]) -> Int {
    var count = 0
    var left = 0
    var right = arr.count - 1
    while left < right {
        if arr[left] != arr[right] {
            count += 1
        }
        left += 1
        right -= 1
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------

// 1.1
// Given two strings, write a method to decide if one is a permutation of the other.
// A permutation is defined as a string that is formed by rearranging the characters of a different string.
// For example, "abc" and "cba" are permutations of each other, but "abc" and "cbd" are not.
// Assume the strings are case-sensitive.
// Assume the strings only contain letters.
// Assume the strings are ASCII.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
// Assume the strings are not empty.
// Assume the strings are not null.
//

func smallestChange(arr: [Int]) -> Int {
    var count = 0
    var left = 0
    var right = arr.count - 1
    while left < right {
        if arr[left] != arr[right] {
            count += 1
            if arr[left] < arr[right] {
                right -= 1
            } else {
                left += 1
            }
        } else {
            left += 1
            right -= 1
        }
    }
    return count
}
```swift
// Given an array arr of integers, find the minimum number of elements that
// need to be changed to make the array palindromic. A palindromic array is an array that
// is read the same backwards and forwards. In one change, you can change one element to any other element.
// For example:
// smallestChange(arr: [1, 2, 3, 5, 4, 7, 9, 6]) == 4
// smallestChange(arr: [1, 2, 3, 4, 3, 2, 2]) == 1
// smallestChange(arr: [1, 2, 3, 2, 1]) == 0
func smallestChange(arr: [Int]) -> Int {
    var count = 0
    var left = 0
    var right = arr.count - 1
    while left < right {
        if arr[left] != arr[right] {
            count += 1
            if arr[left] < arr[right] {
                right -= 1
            } else {
                left += 1
            }
        } else {
            left += 1
            right -= 1
        }
    }
    return count
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // XCTAssertTrue failed

func smallestChange(arr: [Int]) -> Int {
    var count = 0
    var left = 0
    var right = arr.count - 1
    while left < right {
        if arr[left] != arr[right] {
            count += 1
            if arr[left] < arr[right] {
                right -= 1
            } else {
                left += 1
            }
        } else {
            left += 1
            right -= 1
        }
    }
    return count
}

func longestSubarrayOfSumZero(arr: [Int]) -> Int {
    var count = 0
    var left = 0
    var right = 0
    var sum = 0
    while right < arr.count {
        sum += arr[right]
        while sum > 0 {
            sum -= arr[left]
            left += 1
        }
        count = max(count, right - left + 1)
        right += 1
    }
    return count
}

func longestSubarrayOfSameElements(arr: [Int]) -> Int {
    var count = 0
    var left = 0
    var right = 0
    var prev = 0
    while right < arr.count {
        if arr[right] != prev {
            count = max(count, right - left)
            left = right
        }
        prev = arr[right]
        right += 1
    }
    return max(count, right - left)
}

func longestSubarrayInAscendingOrder(arr: [Int]) -> Int {
    var count = 0
    var left = 0
    var right = 0
    var prev = 0
    while right < arr.count {
        if arr[right] < prev {
            count = max(count, right - left)
            left = right
        }
        prev = arr[right]
        right += 1
    }
    return max(count, right - left)
}
```swift
// Given an array arr of integers, find the minimum number of elements that
// need to be changed to make the array palindromic. A palindromic array is an array that
// is read the same backwards and forwards. In one change, you can change one element to any other element.
// For example:
// smallestChange(arr: [1, 2, 3, 5, 4, 7, 9, 6]) == 4
// smallestChange(arr: [1, 2, 3, 4, 3, 2, 2]) == 1
// smallestChange(arr: [1, 2, 3, 2, 1]) == 0
func smallestChange(arr: [Int]) -> Int {
    var count = 0
    var left = 0
    var right = arr.count - 1
    while left < right {
        if arr[left] != arr[right] {
            count += 1
            if arr[left] < arr[right] {
                right -= 1
            } else {
                left += 1
            }
        } else {
            left += 1
            right -= 1
        }
    }
    return count
}

// 2. Given an array of integers, find the length of the longest subarray where the sum of all the elements in the subarray is equal to zero.
// For example:
// longestSubarrayOfSumZero([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5
// longestSubarrayOfSumZero([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 11
// longestSubarrayOfSumZero([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 12
func longestSubarrayOfSumZero(arr: [Int]) -> Int {
    var count = 0
    var left = 0
    var right = 0
    var sum = 0
    while right < arr.count {
        sum += arr[right]
        while sum > 0 {
            sum -= arr[left]
            left += 1
        }
        count = max(count, right - left + 1)
        right += 1
    }
    return count
}

// 3. Given an array of integers, find the length of the longest subarray where all the elements in the subarray are the same.
// For example:
// longestSubarrayOfSameElements([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1
// longestSubarrayOfSameElements([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 1
// longestSubarrayOfSameElements([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 12
func longestSubarrayOfSameElements(arr: [Int]) -> Int {
    var count = 0
    var left = 0
    var right = 0
    var prev = 0
    while right < arr.count {
        if arr[right] != prev {
            count = max(count, right - left)
            left = right
        }
        prev = arr[right]
        right += 1
    }
    return max(count, right - left)
}

// 4. Given an array of integers, find the length of the longest subarray where all the elements in the subarray are in ascending order.
// For example:
// longestSubarrayInAscendingOrder([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1
// longestSubarrayInAscendingOrder([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 1
// longestSubarrayInAscendingOrder([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 12
func longestSubarrayInAscendingOrder(arr: [Int]) -> Int {
    var count = 0
    var left = 0
    var right = 0
    var prev = 0
    while right < arr.count {
        if arr[right] < prev {
            count = max(count, right - left)
            left = right
        }
        prev = arr[right]
        right += 1
    }
    return max(count, right - left)
}

// 5. Given an array of integers, find the length of the longest subarray
 // XCTAssertTrue failed

func smallestChange(arr: [Int]) -> Int {
    var count = 0
    var left = 0
    var right = arr.count - 1
    while left < right {
        if arr[left] != arr[right] {
            count += 1
            if arr[left] < arr[right] {
                right -= 1
            } else {
                left += 1
            }
        } else {
            left += 1
            right -= 1
        }
    }
    return count
}
```swift
// Given an array arr of integers, find the minimum number of elements that
// need to be changed to make the array palindromic. A palindromic array is an array that
// is read the same backwards and forwards. In one change, you can change one element to any other element.
// For example:
// smallestChange(arr: [1, 2, 3, 5, 4, 7, 9, 6]) == 4
// smallestChange(arr: [1, 2, 3, 4, 3, 2, 2]) == 1
// smallestChange(arr: [1, 2, 3, 2, 1]) == 0
func smallestChange(arr: [Int]) -> Int {
    var count = 0
    var left = 0
    var right = arr.count - 1
    while left < right {
        if arr[left] != arr[right] {
            count += 1
            if arr[left] < arr[right] {
                right -= 1
            } else {
                left += 1
            }
        } else {
            left += 1
            right -= 1
        }
    }
    return count
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // XCTAssertTrue failed

func smallestChange(arr: [Int]) -> Int {
    let sortedArr = arr.sorted()
    var count = 0
    for i in 0..<sortedArr.count/2 {
        if sortedArr[i] != sortedArr[sortedArr.count-1-i] {
            count += 1
        }
    }
    return count
}

func sumOfPositives(arr: [Int]) -> Int {
    var sum = 0
    for i in arr {
        if i > 0 {
            sum += i
        }
    }
    return sum
}

func difference(arr: [Int]) -> Int? {
    if arr.count == 0 {
        return nil
    }
    var min = arr[0]
    var max = arr[0]
    for i in arr {
        if i < min {
            min = i
        }
        if i > max {
            max = i
        }
    }
    return max - min
}
```swift
// Given an array arr of integers, find the minimum number of elements that
// need to be changed to make the array palindromic. A palindromic array is an array that
// is read the same backwards and forwards. In one change, you can change one element to any other element.
// For example:
// smallestChange(arr: [1, 2, 3, 5, 4, 7, 9, 6]) == 4
// smallestChange(arr: [1, 2, 3, 4, 3, 2, 2]) == 1
// smallestChange(arr: [1, 2, 3, 2, 1]) == 0
func smallestChange(arr: [Int]) -> Int {
    let sortedArr = arr.sorted()
    var count = 0
    for i in 0..<sortedArr.count/2 {
        if sortedArr[i] != sortedArr[sortedArr.count-1-i] {
            count += 1
        }
    }
    return count
}

// 2. Given an array of integers, return the sum of all the positive integers in the array.
// For example:
// sumOfPositives([1, 2, 3, -1, 5]) == 9
// sumOfPositives([-1, 2, 3, -1, 5]) == 10
// sumOfPositives([-1, -2, 3, -1, 5]) == 10
// sumOfPositives([]) == 0
func sumOfPositives(arr: [Int]) -> Int {
    var sum = 0
    for i in arr {
        if i > 0 {
            sum += i
        }
    }
    return sum
}

// 3. Given an array of integers, return the difference between the largest and smallest integers in the array.
// For example:
// difference([1, 2, 3, 4, 5]) == 4
// difference([1, 2, 3, -4, 5]) == 10
// difference([1, 2, 3, -4, 5, 0]) == 10
// difference([1, 2, 3, -4, 5, 0, 5]) == 10
// difference([1, -2, 3, -4, 5, 0, 5]) == 10
// difference([1, 2, 3, 4, 5, 10]) == 9
// difference([-1, -2, -3, -4, -5]) == 1
// difference([]) == nil
func difference(arr: [Int]) -> Int? {
    if arr.count == 0 {
        return nil
    }
    var min = arr[0]
    var max = arr[0]
    for i in arr {
        if i < min {
            min = i
        }
        if i > max {
            max = i
        }
    }
    return max - min
}

// 4. Given an array of integers, return the sum of all the positive integers in the array.
// For example:
// sumOfPositives([1, 2, 3, -1, 5]) == 9
// sumOfPositives([-1, 2, 3, -1, 5]) == 10
// sumOfPositives([-1, -2, 3, -1, 5]) == 10
// sumOfPositives([]) == 0
func sumOfPositives(arr: [Int]) -> Int {
    var sum = 0
    for i in arr {
        if i > 0 {
            sum += i
        }
    }
    return sum
}

// 5. Given an array of integers, return the sum of all the positive integers in the array.
// For example:
// sumOfPositives([1, 2, 3, -1, 5]) == 9
// sumOfPositives([-1, 2, 3, -1, 5]) == 10
// sumOfPositives([-1, -2, 3, -1, 5]) == 10
// sumOfPositives([]) == 0
func sumOfPositives(arr: [Int]) -> Int {
    var sum = 0
    for i in arr {
        if i > 0 {
            sum += i
        }
    }
    return sum
}

// 6. Given an array of integers, return the sum of all the positive integers in the array.
// For example:
// sumOfPositives([1, 2, 3, -1, 5]) == 9
// sumOfPositives([-1, 2, 3, -1, 5]) == 10
// sumOfPositives([-1, -2, 3, -1, 5]) == 10
// sumOfPositives([]) == 0
func sumOfPositives(arr: [Int]) -> Int {
 // XCTAssertTrue failed

func totalMatch(lst1: [String], lst2: [String]) -> [String] {
    var total = 0
    for i in lst1 {
        total += i.count
    }
    var result = []
    for i in lst2 {
        if i.count < total {
            result.append(i)
        }
    }
    return result
}
```swift
// Write a function that accepts two arrays of strings and returns the array that has 
// total number of chars in the all strings of the array less than the other array.
// if the two arrays have the same number of chars, return the first array.
// Examples
// totalMatch(lst1: [] as [String], lst2: [] as [String]) == [] as [String]
// totalMatch(lst1: ["hi", "admin"], lst2: ["hI", "Hi"]) == ["hI", "Hi"]
// totalMatch(lst1: ["hi", "admin"], lst2: ["hi", "hi", "admin", "project"]) == ["hi", "admin"]
// totalMatch(lst1: ["hi", "admin"], lst2: ["hI", "hi", "hi"]) == ["hI", "hi", "hi"]
// totalMatch(lst1: ["4"], lst2: ["1", "2", "3", "4", "5"]) == ["4"]
func totalMatch(lst1: [String], lst2: [String]) -> [String] {
    var total = 0
    for i in lst1 {
        total += i.count
    }
    var result = []
    for i in lst2 {
        if i.count < total {
            result.append(i)
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
var result = [] // empty collection literal requires an explicit type
return result // cannot convert return expression of type '[Any]' to return type '[String]'

func totalMatch(lst1: [String], lst2: [String]) -> [String] {
    var result = lst1
    for i in lst2 {
        if !result.contains(i) {
            result.append(i)
        }
    }
    return result
}

func sum(numbers: [Int]) -> Int {
    return numbers.reduce(0, { (sum, number) -> Int in
        return sum + number
    })
}

func avg(numbers: [Int]) -> Int {
    return sum(numbers) / numbers.count
}

func highest(numbers: [Int]) -> Int {
    return numbers.max() ?? 0
}

func lowest(numbers: [Int]) -> Int {
    return numbers.min() ?? 0
}

func smallest(numbers: [Int]) -> Int {
    return lowest(numbers)
}

func largest(numbers: [Int]) -> Int {
    return highest(numbers)
}

func secondLargest(numbers: [Int]) -> Int {
    return numbers.sorted().last!
}

func secondSmallest(numbers: [Int]) -> Int {
    return numbers.sorted().first!
}

func smallest(numbers: [Int]) -> Int {
    return numbers.sorted().first!
}

func largest(numbers: [Int]) -> Int {
    return numbers.sorted().last!
}
```swift
// Write a function that accepts two arrays of strings and returns the array that has 
// total number of chars in the all strings of the array less than the other array.
// if the two arrays have the same number of chars, return the first array.
// Examples
// totalMatch(lst1: [] as [String], lst2: [] as [String]) == [] as [String]
// totalMatch(lst1: ["hi", "admin"], lst2: ["hI", "Hi"]) == ["hI", "Hi"]
// totalMatch(lst1: ["hi", "admin"], lst2: ["hi", "hi", "admin", "project"]) == ["hi", "admin"]
// totalMatch(lst1: ["hi", "admin"], lst2: ["hI", "hi", "hi"]) == ["hI", "hi", "hi"]
// totalMatch(lst1: ["4"], lst2: ["1", "2", "3", "4", "5"]) == ["4"]
func totalMatch(lst1: [String], lst2: [String]) -> [String] {
    var result = lst1
    for i in lst2 {
        if !result.contains(i) {
            result.append(i)
        }
    }
    return result
}

// 2. Write a function that accepts an array of numbers and returns the sum of the numbers.
// If the array is empty, it should return 0.
// Examples
// sum([1, 2, 3]) == 6
// sum([]) == 0
func sum(numbers: [Int]) -> Int {
    return numbers.reduce(0, { (sum, number) -> Int in
        return sum + number
    })
}

// 3. Write a function that accepts an array of numbers and returns the average of the numbers.
// If the array is empty, it should return 0.
// Examples
// avg([1, 2, 3]) == 2
// avg([]) == 0
func avg(numbers: [Int]) -> Int {
    return sum(numbers) / numbers.count
}

// 4. Write a function that accepts an array of numbers and returns the highest number.
// If the array is empty, it should return 0.
// Examples
// highest([1, 2, 3]) == 3
// highest([]) == 0
func highest(numbers: [Int]) -> Int {
    return numbers.max() ?? 0
}

// 5. Write a function that accepts an array of numbers and returns the lowest number.
// If the array is empty, it should return 0.
// Examples
// lowest([1, 2, 3]) == 1
// lowest([]) == 0
func lowest(numbers: [Int]) -> Int {
    return numbers.min() ?? 0
}

// 6. Write a function that accepts an array of numbers and returns the smallest number.
// If the array is empty, it should return 0.
// Examples
// smallest([1, 2, 3]) == 1
// smallest([]) == 0
func smallest(numbers: [Int]) -> Int {
    return lowest(numbers)
}

// 7. Write a function that accepts an array of numbers and returns the largest number.
// If the array is empty, it should return 0.
// Examples
// largest([1, 2, 3]) == 3
// largest([]) == 0
func largest(numbers: [Int]) -> Int {
    return highest(numbers)
}

// 8. Write a function that accepts an array of numbers and returns the second largest number.
// If the array is empty, it should return 0.
// Examples
// secondLargest([1, 2, 3]) == 2
// secondLargest([]) == 0
func secondLargest(numbers: [Int]) -> Int {
    return numbers.sorted().last!
}

// 9. Write a function that accepts an array of numbers and returns the second smallest number.
// If the array is empty, it should return 0.
// Examples
// secondSmallest([1, 2, 3]) == 1
// secondSmallest([]) == 0
func secondSmallest(numbers: [Int]) -> Int {
    return numbers.sorted().first!
}

// 10. Write a function that accepts an array of numbers and returns the smallest number.
// If the array is empty, it should return 0.
// Examples
// smallest([1, 2, 3]) == 1
// smallest([]) == 0
func smallest(numbers: [Int]) -> Int {
    return numbers.sorted().first!
}

// 11. Write a function that accepts an array of numbers and returns the largest number.
// If the array is empty, it should return 0.
// Examples
// largest([1, 2, 3]) == 3
// largest([]) == 0
func largest(numbers: [Int]) -> Int {
    return numbers.sorted().last!
}

// 12. Write a function that accepts an array of numbers and returns the second largest number.
// If the array is empty, it should return 0.
// Examples
// secondLargest([1, 2, 3]) == 2
// secondLargest([]) == 0
func secondLargest(numbers: [
return sum(numbers) / numbers.count // missing argument label 'numbers:' in call
return lowest(numbers) // missing argument label 'numbers:' in call
return highest(numbers) // missing argument label 'numbers:' in call
func smallest(numbers: [Int]) -> Int { // invalid redeclaration of 'smallest(numbers:)'
func largest(numbers: [Int]) -> Int { // invalid redeclaration of 'largest(numbers:)'

func totalMatch(lst1: [String], lst2: [String]) -> [String] {
    var result = lst1
    for i in lst2 {
        if result.count < lst2.count {
            result.append(i)
        }
    }
    return result
}
```swift
// Write a function that accepts two arrays of strings and returns the array that has 
// total number of chars in the all strings of the array less than the other array.
// if the two arrays have the same number of chars, return the first array.
// Examples
// totalMatch(lst1: [] as [String], lst2: [] as [String]) == [] as [String]
// totalMatch(lst1: ["hi", "admin"], lst2: ["hI", "Hi"]) == ["hI", "Hi"]
// totalMatch(lst1: ["hi", "admin"], lst2: ["hi", "hi", "admin", "project"]) == ["hi", "admin"]
// totalMatch(lst1: ["hi", "admin"], lst2: ["hI", "hi", "hi"]) == ["hI", "hi", "hi"]
// totalMatch(lst1: ["4"], lst2: ["1", "2", "3", "4", "5"]) == ["4"]
func totalMatch(lst1: [String], lst2: [String]) -> [String] {
    var result = lst1
    for i in lst2 {
        if result.count < lst2.count {
            result.append(i)
        }
    }
    return result
}

// 2. Write a function that accepts an array of numbers and returns the sum of all the numbers.
// Examples
// sum([1, 2, 3, 4, 5]) == 15
// sum([1, 2, 3, 4, 5, 6]) == 21
// sum([1, 2, 3, 4, 5, 6, 7]) == 28
// sum([1, 2, 3, 4, 5, 6, 7, 8]) == 36
// sum([1, 2, 3, 4, 5, 6, 7, 8, 9]) == 45
// sum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55
// sum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 66
// sum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 78
// sum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == 91
// sum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 105
// sum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120
// sum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 136
// sum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]) == 153
// sum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == 170
// sum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 187
// sum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 204
// sum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == 221
// sum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 
 // XCTAssertTrue failed

func totalMatch(lst1: [String], lst2: [String]) -> [String] {
    var count = 0
    var count2 = 0
    for i in lst1 {
        count += i.count
    }
    for i in lst2 {
        count2 += i.count
    }
    if count == count2 {
        return lst1
    } else if count < count2 {
        return lst1
    } else {
        return lst2
    }
}
```swift
// Write a function that accepts two arrays of strings and returns the array that has 
// total number of chars in the all strings of the array less than the other array.
// if the two arrays have the same number of chars, return the first array.
// Examples
// totalMatch(lst1: [] as [String], lst2: [] as [String]) == [] as [String]
// totalMatch(lst1: ["hi", "admin"], lst2: ["hI", "Hi"]) == ["hI", "Hi"]
// totalMatch(lst1: ["hi", "admin"], lst2: ["hi", "hi", "admin", "project"]) == ["hi", "admin"]
// totalMatch(lst1: ["hi", "admin"], lst2: ["hI", "hi", "hi"]) == ["hI", "hi", "hi"]
// totalMatch(lst1: ["4"], lst2: ["1", "2", "3", "4", "5"]) == ["4"]
func totalMatch(lst1: [String], lst2: [String]) -> [String] {
    var count = 0
    var count2 = 0
    for i in lst1 {
        count += i.count
    }
    for i in lst2 {
        count2 += i.count
    }
    if count == count2 {
        return lst1
    } else if count < count2 {
        return lst1
    } else {
        return lst2
    }
}

// 2. Write a function that accepts two arrays of numbers and returns the array with the
// largest sum. If the sums are equal, return the first array.
// Examples
// largestSum(lst1: [] as [Int], lst2: [] as [Int]) == [] as [Int]
// largestSum(lst1: [1, 2, 3], lst2: [1, 2, 3]) == [1, 2, 3]
// largestSum(lst1: [1, 2, 3], lst2: [1, 2, 3, 4]) == [1, 2, 3, 4]
// largestSum(lst1: [1, 2, 3], lst2: [1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5]
// largestSum(lst1: [1, 2, 3], lst2: [1, 2, 3, 4, 5, 6]) == [1, 2, 3, 4, 5, 6]
// largestSum(lst1: [1, 2, 3], lst2: [1, 2, 3, 4, 5, 6, 7]) == [1, 2, 3, 4, 5, 6, 7]
// largestSum(lst1: [1, 2, 3, 4, 5, 6, 7], lst2: [1, 2, 3, 4, 5, 6, 7]) == [1, 2, 3, 4, 5, 6, 7]
// largestSum(lst1: [1, 2, 3, 4, 5, 6, 7], lst2: [1, 2, 3, 4, 5, 6, 7, 8]) == [1, 2, 3, 4, 5, 6, 7, 8]
// largestSum(lst1: [1, 2, 3, 4, 5, 6, 7], lst2: [1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, 2, 3, 4, 5, 6, 7, 8, 9]
// largestSum(lst1: [1, 2, 3, 4, 5, 6, 7], lst2: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
// largestSum(lst1: [1, 2, 3, 4, 5, 6, 7], lst2: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
// largestSum(lst1: [1, 2, 3, 4, 5, 6, 7], lst2: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
// largestSum(lst1: [1, 2, 3, 4, 5, 6,

func totalMatch(lst1: [String], lst2: [String]) -> [String] {
    var result = lst1
    for i in lst2 {
        if !result.contains(i) {
            result.append(i)
        }
    }
    return result
}
```swift
// Write a function that accepts two arrays of strings and returns the array that has 
// total number of chars in the all strings of the array less than the other array.
// if the two arrays have the same number of chars, return the first array.
// Examples
// totalMatch(lst1: [] as [String], lst2: [] as [String]) == [] as [String]
// totalMatch(lst1: ["hi", "admin"], lst2: ["hI", "Hi"]) == ["hI", "Hi"]
// totalMatch(lst1: ["hi", "admin"], lst2: ["hi", "hi", "admin", "project"]) == ["hi", "admin"]
// totalMatch(lst1: ["hi", "admin"], lst2: ["hI", "hi", "hi"]) == ["hI", "hi", "hi"]
// totalMatch(lst1: ["4"], lst2: ["1", "2", "3", "4", "5"]) == ["4"]
func totalMatch(lst1: [String], lst2: [String]) -> [String] {
    var result = lst1
    for i in lst2 {
        if !result.contains(i) {
            result.append(i)
        }
    }
    return result
}

// 2. Write a function that accepts a string and returns the number (count) of vowels contained within.
// Valid vowels are: a, e, i, o, u.
// A function can be implemented either using selection or iteration, but not both.
// Examples
// vowelCount("ciao") == 2
// vowelCount("vowel") == 2
// vowelCount("zodiac") == 1
// vowelCount("strength") == 2
// vowelCount("mischta") == 2
// vowelCount("") == 0
// vowelCount("aeiou") == 5
// vowelCount("why") == 0
// vowelCount("abracadabra") == 5
// vowelCount("bcd") == 0
// vowelCount("aeiouAEIOU") == 5
// vowelCount("12345") == 0
// vowelCount("🤟") == 0
//
// 3. Write a function that accepts a string and returns true if the string is a valid number (isNum).
// A valid number is a string that represents a positive integer or a positive floating-point number.
// Valid numbers include:
// 1. Numbers with no letters (e.g. 1, 2, 3, 4, 5, 6, 7, 8, 9, 0)
// 2. Numbers with a single decimal point (e.g. 1.0, 2.5, 3.14159, 4.0000000001)
// 3. Numbers with a single exponent (e.g. 1e10, 2e-10, 3.14159e+3, 4.0000000001e-10)
// 4. Numbers with multiple decimal points (e.g. 1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
 // XCTAssertTrue failed

func totalMatch(lst1: [String], lst2: [String]) -> [String] {
    var total = 0
    for i in lst1 {
        total += i.count
    }
    var result = []
    for i in lst2 {
        if i.count < total {
            result.append(i)
        }
    }
    return result
}
```swift
// Write a function that accepts two arrays of strings and returns the array that has 
// total number of chars in the all strings of the array less than the other array.
// if the two arrays have the same number of chars, return the first array.
// Examples
// totalMatch(lst1: [] as [String], lst2: [] as [String]) == [] as [String]
// totalMatch(lst1: ["hi", "admin"], lst2: ["hI", "Hi"]) == ["hI", "Hi"]
// totalMatch(lst1: ["hi", "admin"], lst2: ["hi", "hi", "admin", "project"]) == ["hi", "admin"]
// totalMatch(lst1: ["hi", "admin"], lst2: ["hI", "hi", "hi"]) == ["hI", "hi", "hi"]
// totalMatch(lst1: ["4"], lst2: ["1", "2", "3", "4", "5"]) == ["4"]
func totalMatch(lst1: [String], lst2: [String]) -> [String] {
    var total = 0
    for i in lst1 {
        total += i.count
    }
    var result = []
    for i in lst2 {
        if i.count < total {
            result.append(i)
        }
    }
    return result
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
var result = [] // empty collection literal requires an explicit type
return result // cannot convert return expression of type '[Any]' to return type '[String]'

func totalMatch(lst1: [String], lst2: [String]) -> [String] {
    var total = 0
    var result = [] as [String]
    for i in lst1 {
        total += i.count
    }
    for i in lst2 {
        total += i.count
    }
    if total == lst1.count * lst2.count {
        return lst1
    } else if total == lst2.count * lst1.count {
        return lst2
    } else {
        for i in lst1 {
            if i.count < lst2.count {
                result.append(i)
            }
        }
        return result
    }
}
```swift
// Write a function that accepts two arrays of strings and returns the array that has 
// total number of chars in the all strings of the array less than the other array.
// if the two arrays have the same number of chars, return the first array.
// Examples
// totalMatch(lst1: [] as [String], lst2: [] as [String]) == [] as [String]
// totalMatch(lst1: ["hi", "admin"], lst2: ["hI", "Hi"]) == ["hI", "Hi"]
// totalMatch(lst1: ["hi", "admin"], lst2: ["hi", "hi", "admin", "project"]) == ["hi", "admin"]
// totalMatch(lst1: ["hi", "admin"], lst2: ["hI", "hi", "hi"]) == ["hI", "hi", "hi"]
// totalMatch(lst1: ["4"], lst2: ["1", "2", "3", "4", "5"]) == ["4"]
func totalMatch(lst1: [String], lst2: [String]) -> [String] {
    var total = 0
    var result = [] as [String]
    for i in lst1 {
        total += i.count
    }
    for i in lst2 {
        total += i.count
    }
    if total == lst1.count * lst2.count {
        return lst1
    } else if total == lst2.count * lst1.count {
        return lst2
    } else {
        for i in lst1 {
            if i.count < lst2.count {
                result.append(i)
            }
        }
        return result
    }
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // XCTAssertTrue failed

func totalMatch(lst1: [String], lst2: [String]) -> [String] {
    var result = lst1
    for i in lst2 {
        if result.count < lst2.count {
            result.append(i)
        }
    }
    return result
}

func removeVowels(input: String) -> String {
    var result = ""
    for i in input {
        if i != "a" && i != "e" && i != "i" && i != "o" && i != "u" && i != "A" && i != "E" && i != "I" && i != "O" && i != "U" {
            result += i
        }
    }
    return result
}
```swift
// Write a function that accepts two arrays of strings and returns the array that has 
// total number of chars in the all strings of the array less than the other array.
// if the two arrays have the same number of chars, return the first array.
// Examples
// totalMatch(lst1: [] as [String], lst2: [] as [String]) == [] as [String]
// totalMatch(lst1: ["hi", "admin"], lst2: ["hI", "Hi"]) == ["hI", "Hi"]
// totalMatch(lst1: ["hi", "admin"], lst2: ["hi", "hi", "admin", "project"]) == ["hi", "admin"]
// totalMatch(lst1: ["hi", "admin"], lst2: ["hI", "hi", "hi"]) == ["hI", "hi", "hi"]
// totalMatch(lst1: ["4"], lst2: ["1", "2", "3", "4", "5"]) == ["4"]
func totalMatch(lst1: [String], lst2: [String]) -> [String] {
    var result = lst1
    for i in lst2 {
        if result.count < lst2.count {
            result.append(i)
        }
    }
    return result
}

// 2. Write a function that accepts a string and returns a new string with all vowels removed.
// Examples
// removeVowels("I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
// removeVowels("abracadabra") == "brcrdbrkr"
// removeVowels("pear tree") == " pr t"
// removeVowels("hello") == " hll"
// removeVowels("cucumber") == " cmbtr"
// removeVowels("") == ""
// removeVowels("a") == ""
// removeVowels("aeiou") == ""
// removeVowels("AEIOU") == ""
// removeVowels("12345") == "12345"
// removeVowels("😀😁😂🤣😃😄😅😆😉😊😋😌😍😘😙😚😛😜😝😞😟😠😡😢😣😤😥😦😧😨😩😪😫😬😭😮😯😰😱😲😳😴😵😶😷😸😹😺😻😼😽😾😿🙀🙁🙃🙄🙅🙆🙇🙈🙉🙊🙋🙌🙍🙎🙏🙐🙑🙒🙓🙔🙕🙖🙗🙘🙙🙚🙛🙜🙝🙞🙟🙠🙡🙢🙣🙤🙥🙦🙧🙨🙩🙪🙫🙬🙭🙮🙯") == ""
func removeVowels(input: String) -> String {
    var result = ""
    for i in input {
        if i != "a" && i != "e" && i != "i" && i != "o" && i != "u" && i != "A" && i != "E" && i != "I" && i != "O" && i != "U" {
            result += i
        }
    }
    return result
}

// 3. Write a function that accepts a string and a single character, and returns an integer of how many times that character is found in the string.
// Examples
// strCount("Hello", "o") == 1
// strCount("Hello", "l") == 2
// strCount("Hello", "e") == 1
// strCount("Hello", "H") == 1
// strCount("Hello", "ll") == 2
// strCount("Hello", "He") == 1
// strCount("Hello", "eo") == 1
// strCount("Hello", "eHello") == 1
// strCount("Hello", "oHellllooo") == 3
// strCount("Hello", "oHelllloo") == 4
result += i // cannot convert value of type 'Character' to expected argument type 'String'

func totalMatch(lst1: [String], lst2: [String]) -> [String] {
    var total = 0
    for i in lst1 {
        total += i.count
    }
    var total2 = 0
    for i in lst2 {
        total2 += i.count
    }
    if total == total2 {
        return lst1
    } else if total > total2 {
        return lst1
    } else {
        return lst2
    }
}
```swift
// Write a function that accepts two arrays of strings and returns the array that has 
// total number of chars in the all strings of the array less than the other array.
// if the two arrays have the same number of chars, return the first array.
// Examples
// totalMatch(lst1: [] as [String], lst2: [] as [String]) == [] as [String]
// totalMatch(lst1: ["hi", "admin"], lst2: ["hI", "Hi"]) == ["hI", "Hi"]
// totalMatch(lst1: ["hi", "admin"], lst2: ["hi", "hi", "admin", "project"]) == ["hi", "admin"]
// totalMatch(lst1: ["hi", "admin"], lst2: ["hI", "hi", "hi"]) == ["hI", "hi", "hi"]
// totalMatch(lst1: ["4"], lst2: ["1", "2", "3", "4", "5"]) == ["4"]
func totalMatch(lst1: [String], lst2: [String]) -> [String] {
    var total = 0
    for i in lst1 {
        total += i.count
    }
    var total2 = 0
    for i in lst2 {
        total2 += i.count
    }
    if total == total2 {
        return lst1
    } else if total > total2 {
        return lst1
    } else {
        return lst2
    }
}

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ------------------------------
 // XCTAssertTrue failed

func totalMatch(lst1: [String], lst2: [String]) -> [String] {
    var result = lst1
    for i in lst2 {
        if result.count < lst2.count {
            result.append(i)
        }
    }
    return result
}
```swift
// Write a function that accepts two arrays of strings and returns the array that has 
// total number of chars in the all strings of the array less than the other array.
// if the two arrays have the same number of chars, return the first array.
// Examples
// totalMatch(lst1: [] as [String], lst2: [] as [String]) == [] as [String]
// totalMatch(lst1: ["hi", "admin"], lst2: ["hI", "Hi"]) == ["hI", "Hi"]
// totalMatch(lst1: ["hi", "admin"], lst2: ["hi", "hi", "admin", "project"]) == ["hi", "admin"]
// totalMatch(lst1: ["hi", "admin"], lst2: ["hI", "hi", "hi"]) == ["hI", "hi", "hi"]
// totalMatch(lst1: ["4"], lst2: ["1", "2", "3", "4", "5"]) == ["4"]
func totalMatch(lst1: [String], lst2: [String]) -> [String] {
    var result = lst1
    for i in lst2 {
        if result.count < lst2.count {
            result.append(i)
        }
    }
    return result
}

// 2. Write a function that accepts an array of numbers and returns the sum of all the numbers.
// Examples
// sum([1, 2, 3]) == 6
// sum([1, 2, 3, 4, 5]) == 15
// sum([-1, 2, 3]) == 2
// sum([]) == 0
// sum([-1, -2, -3]) == -6
// sum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55
// sum([-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == -55
// sum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120
// sum([-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15]) == -120
// sum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 120
// sum([-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16]) == -120
// sum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]) == 120
// sum([-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17]) == -120
// sum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == 120
// sum([-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18]) == -120
// sum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 120
// sum([-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19]) == -120
// sum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 120
// sum([-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11,
 // XCTAssertTrue failed

func isMultiplyPrime(a: Int) -> Bool {
    var count = 0
    for i in 1...a {
        if isPrime(i) {
            count += 1
        }
    }
    return count == 3
}

func sumOfLowest3Numbers(numbers: [Int]) -> Int {
    var lowest = numbers[0]
    var secondLowest = numbers[1]
    var thirdLowest = numbers[2]
    var fourthLowest = numbers[3]
    var sum = lowest + secondLowest + thirdLowest
    for i in numbers {
        if i < lowest {
            lowest = i
        }
        if i < secondLowest {
            secondLowest = i
        }
        if i < thirdLowest {
            thirdLowest = i
        }
        if i < fourthLowest {
            fourthLowest = i
        }
    }
    sum += lowest
    return sum
}

func firstNonRepeatingChar(s: String) -> Int {
    for i in s {
        if s.count(for: i) == 1 {
            return s.firstIndex(for: i)!
        }
    }
    return -1
}
```swift
// Write a function that returns true if the given number is the multiplication of 3 prime numbers
// and false otherwise.
// Knowing that (a) is less then 100. 
// Example:
// 30 = 2 * 3 * 5
// isMultiplyPrime(a: 30) == true
func isMultiplyPrime(a: Int) -> Bool {
    var count = 0
    for i in 1...a {
        if isPrime(i) {
            count += 1
        }
    }
    return count == 3
}

// 2. Write a function that takes a number and returns the sum of the two lowest positive
// numbers given an array of minimum 4 positive integers.
// For example, when an array is passed like [19, 5, 42, 2, 77], the output should be 7.
// [10, 343445353, 3453445, 3453545353453] should return 3453455.
// Note: All array values are positive and will always be valid.
// Flags:
// 1. The array's length will always be at least 4.
// 2. Set a variable to hold the lowest number.
// 3. Set a variable to hold the second lowest number.
// 4. Set a variable to hold the third lowest number.
// 5. Set a variable to hold the fourth lowest number.
// 6. Set a variable to hold the sum of the lowest 3 numbers.
// 7. Loop through the array.
// 8. If the number is less than the lowest number, set the lowest number to the number.
// 9. If the number is less than the second lowest number, set the second lowest number to the number.
// 10. If the number is less than the third lowest number, set the third lowest number to the number.
// 11. If the number is less than the fourth lowest number, set the fourth lowest number to the number.
// 12. Add the lowest number to the sum of the lowest 3 numbers.
// 13. Return the sum of the lowest 3 numbers.
func sumOfLowest3Numbers(numbers: [Int]) -> Int {
    var lowest = numbers[0]
    var secondLowest = numbers[1]
    var thirdLowest = numbers[2]
    var fourthLowest = numbers[3]
    var sum = lowest + secondLowest + thirdLowest
    for i in numbers {
        if i < lowest {
            lowest = i
        }
        if i < secondLowest {
            secondLowest = i
        }
        if i < thirdLowest {
            thirdLowest = i
        }
        if i < fourthLowest {
            fourthLowest = i
        }
    }
    sum += lowest
    return sum
}

// 3. Given a string, find the first non-repeating character in it and return it's index.
// If it doesn't exist, return -1.
// Examples:
// s = "leetcode"
// return 0.
// s = "loveleetcode"
// return 2.
// Note: You may assume the string contain only lowercase letters.
// Flags:
// 1. Loop through the string.
// 2. If the character is not in the string, return the index.
// 3. If the character is in the string, return -1.
func firstNonRepeatingChar(s: String) -> Int {
    for i in s {
        if s.count(for: i) == 1 {
            return s.firstIndex(for: i)!
        }
    }
    return -1
}

// 4. Given a string, find the first character that is not repeated in it.
// If it doesn't exist, return -1.
// Examples:
// s = "leetcode"
// return 0.
// s = "loveleetcode"
// return 2.
// Note: You may assume the string contain only lowercase letters.
// Flags:
// 1. Loop through the string.
// 2. If the character is not in the string, return the index.
// 3. If the character is in the string, return -1.
func firstNonRepeatingChar(s: String) -> Int {
    for i in s {
        if s.count(for: i) == 1 {
            return s.firstIndex(for: i)!
        }
    }
    return -1
}

// 5. Given a string, find the first character that is
if isPrime(i) { // cannot find 'isPrime' in scope
if s.count(for: i) == 1 { // cannot call value of non-function type 'Int'
return s.firstIndex(for: i)! // cannot convert return expression of type 'String.Index' to return type 'Int'
return s.firstIndex(for: i)! // incorrect argument label in call (have 'for:', expected 'of:')

func isMultiplyPrime(a: Int) -> Bool {
    var count = 0
    var i = 2
    while i < 100 {
        if a % i == 0 {
            count += 1
        }
        i += 1
    }
    if count == 3 {
        return true
    } else {
        return false
    }
}

func sumDigits(a: Int) -> Int {
    var sum = 0
    var i = 0
    while i < a {
        sum += a % 10
        a /= 10
        i += 1
    }
    return sum
}

func factorial(a: Int) -> Int {
    var sum = 1
    var i = 1
    while i <= a {
        sum *= i
        i += 1
    }
    return sum
}

func sumDivisors(a: Int) -> Int {
    var sum = 0
    var i = 1
    while i < a {
        if a % i == 0 {
            sum += i
        }
        i += 1
    }
    return sum
}
```swift
// Write a function that returns true if the given number is the multiplication of 3 prime numbers
// and false otherwise.
// Knowing that (a) is less then 100. 
// Example:
// 30 = 2 * 3 * 5
// isMultiplyPrime(a: 30) == true
func isMultiplyPrime(a: Int) -> Bool {
    var count = 0
    var i = 2
    while i < 100 {
        if a % i == 0 {
            count += 1
        }
        i += 1
    }
    if count == 3 {
        return true
    } else {
        return false
    }
}

// 2. Write a function that takes a number and returns the sum of its digits.
// Example:
// sumDigits(10) == 1
func sumDigits(a: Int) -> Int {
    var sum = 0
    var i = 0
    while i < a {
        sum += a % 10
        a /= 10
        i += 1
    }
    return sum
}

// 3. Write a function that takes a number and returns the factorial of that number.
// Example:
// factorial(5) == 120
func factorial(a: Int) -> Int {
    var sum = 1
    var i = 1
    while i <= a {
        sum *= i
        i += 1
    }
    return sum
}

// 4. Write a function that takes a number and returns the sum of all its divisors except itself.
// Example:
// sumDivisors(12) == 1 + 2 + 3 + 4 + 6 + 12 == 30
func sumDivisors(a: Int) -> Int {
    var sum = 0
    var i = 1
    while i < a {
        if a % i == 0 {
            sum += i
        }
        i += 1
    }
    return sum
}

// 5. Write a function that takes a number and returns the sum of all its divisors except itself.
// Example:
// sumDivisors(12) == 1 + 2 + 3 + 4 + 6 + 12 == 30
func sumDivisors(a: Int) -> Int {
    var sum = 0
    var i = 1
    while i < a {
        if a % i == 0 {
            sum += i
        }
        i += 1
    }
    return sum
}

// 6. Write a function that takes a number and returns the sum of all its divisors except itself.
// Example:
// sumDivisors(12) == 1 + 2 + 3 + 4 + 6 + 12 == 30
func sumDivisors(a: Int) -> Int {
    var sum = 0
    var i = 1
    while i < a {
        if a % i == 0 {
            sum += i
        }
        i += 1
    }
    return sum
}

// 7. Write a function that takes a number and returns the sum of all its divisors except itself.
// Example:
// sumDivisors(12) == 1 + 2 + 3 + 4 + 6 + 12 == 30
func sumDivisors(a: Int) -> Int {
    var sum = 0
    var i = 1
    while i < a {
        if a % i == 0 {
            sum += i
        }
        i += 1
    }
    return sum
}

// 8. Write a function that takes a number and returns the sum of all its divisors except itself.
// Example:
// sumDivisors(12) == 1 + 2 + 3 + 4 + 6 + 12 == 30
func sumDivisors(a: Int) -> Int {
    var sum = 0
    var i = 1
    while i < a {
        if a % i == 0 {
            sum += i
        }
        i += 1
    }
    return sum
}

// 9. Write a function that takes a number and returns the sum of all its divisors except itself.
// Example:
// sumDivisors(12) == 1 + 2 + 3 + 4 + 6 + 12 == 30
func sumDivisors(a: Int) -> Int {
    var sum = 0
    var i = 1
    while i < a {
        if a % i == 0 {
            sum += i
a /= 10 // left side of mutating operator isn't mutable: 'a' is a 'let' constant

func isMultiplyPrime(a: Int) -> Bool {
    let primes = [2, 3, 5]
    let factors = []
    for i in 0..<primes.count {
        if a % primes[i] == 0 {
            factors.append(primes[i])
        }
    }
    if factors.count == 3 {
        return true
    } else {
        return false
    }
}

func sumLowest(numbers: [Int]) -> Int {
    let sortedNumbers = numbers.sorted()
    return sortedNumbers[0] + sortedNumbers[1]
}

func maxProduct(numbers: [Int]) -> Int {
    var maxProduct = 0
    for i in 0..<numbers.count - 1 {
        let product = numbers[i] * numbers[i + 1]
        if product > maxProduct {
            maxProduct = product
        }
    }
    return maxProduct
}

func maxProduct3(numbers: [Int]) -> Int {
    var maxProduct = 0
    for i in 0..<numbers.count - 2 {
        let product = numbers[i] * numbers[i + 1] * numbers[i + 2]
        if product > maxProduct {
            maxProduct = product
        }
    }
    return maxProduct
}
```swift
// Write a function that returns true if the given number is the multiplication of 3 prime numbers
// and false otherwise.
// Knowing that (a) is less then 100. 
// Example:
// 30 = 2 * 3 * 5
// isMultiplyPrime(a: 30) == true
func isMultiplyPrime(a: Int) -> Bool {
    let primes = [2, 3, 5]
    let factors = []
    for i in 0..<primes.count {
        if a % primes[i] == 0 {
            factors.append(primes[i])
        }
    }
    if factors.count == 3 {
        return true
    } else {
        return false
    }
}

// 2. Write a function that takes a number and returns the sum of the two lowest positive numbers
// given an array of minimum 4 positive integers.
// 4 means that there are at least 4 positive integers.
// Example:
// [19, 5, 42, 2, 77] => 7
// [10, 343445353, 3453445, 3453545353453] => 34534555
func sumLowest(numbers: [Int]) -> Int {
    let sortedNumbers = numbers.sorted()
    return sortedNumbers[0] + sortedNumbers[1]
}

// 3. Given an array of integers , Find the maximum product you can get from multiplying 2 adjacent numbers in the array.
// Notes
//     Array/list size is at least 2.
//     Array/list numbers could be a mixture of positives, negatives also zeroes .
// Example
//   [1, 2, 3] => 6
//   [1, 2, 3, 4] => 8
//   [3, 4, 5, 3, 1] => 24
//   [-10, -3, -1, 2] => 30

func maxProduct(numbers: [Int]) -> Int {
    var maxProduct = 0
    for i in 0..<numbers.count - 1 {
        let product = numbers[i] * numbers[i + 1]
        if product > maxProduct {
            maxProduct = product
        }
    }
    return maxProduct
}

// 4. Given an array of integers , Find the maximum product you can get from multiplying 3 adjacent numbers in the array.
// Notes
//     Array/list size is at least 3.
//     Array/list numbers could be a mixture of positives, negatives also zeroes .
// Example
//   [1, 2, 3, 4, 3, 2, 1, 1, 2, 3, 1, 2, 3, 4]
//   The maximum product can be found when multiplying 3 consecutive numbers: 1,2,3,4,3,2,1
//   Example solution:
//   // Write your code here
//   return 12
//   The maximum product can be found when multiplying 3 consecutive numbers: 1,2,3,4,3,2,1
func maxProduct3(numbers: [Int]) -> Int {
    var maxProduct = 0
    for i in 0..<numbers.count - 2 {
        let product = numbers[i] * numbers[i + 1] * numbers[i + 2]
        if product > maxProduct {
            maxProduct = product
        }
    }
    return maxProduct
}

// 5. Given an array/list [] of integers , Find the Nth smallest element in this array of integers
// Notes
//     Array/list size is at least 6 .
//     Array/list's numbers could be a mixture of positives , negatives and zeros .
//     Repetition of numbers in the array/list could occur , So (duplications) .
//     Input >> Output Examples
//     nthSmallest({34, 15, 88, 2} ,2) ==> return 15
//     nthSmallest({15, 88, 2, 34, 15, 34} ,2) ==> return 2
//     nthSmallest({34, 15, 88, 2, 15, 34, 2} ,1) ==> return 2
//     nthSmallest({27, 19, 42, 2, 10, 48, 27, 19} 
let factors = [] // empty collection literal requires an explicit type
factors.append(primes[i]) // cannot use mutating member on immutable value: 'factors' is a 'let' constant

func isMultiplyPrime(a: Int) -> Bool {
    if a < 100 {
        var count = 0
        for i in 1...a {
            if isPrime(i) {
                count += 1
            }
        }
        if count >= 3 {
            return true
        }
    }
    return false
}

func countDigits(n: Int) -> Int {
    return String(n).count
}

func toBinary(a: Int) -> Int {
    return Int(a).toBinary()
}
```swift
// Write a function that returns true if the given number is the multiplication of 3 prime numbers
// and false otherwise.
// Knowing that (a) is less then 100. 
// Example:
// 30 = 2 * 3 * 5
// isMultiplyPrime(a: 30) == true
func isMultiplyPrime(a: Int) -> Bool {
    if a < 100 {
        var count = 0
        for i in 1...a {
            if isPrime(i) {
                count += 1
            }
        }
        if count >= 3 {
            return true
        }
    }
    return false
}

// 2. Write a function that returns the number of digits of given integer.
// Example:
// countDigits(n: 1234) == 4
func countDigits(n: Int) -> Int {
    return String(n).count
}

// 3. Convert a given number from base 10 to base 2.
// Example:
// toBinary(a: 10) == 1010
func toBinary(a: Int) -> Int {
    return Int(a).toBinary()
}

// 4. Convert a given number from base 10 to base 2.
// Example:
// toBinary(a: 10) == 1010
func toBinary(a: Int) -> Int {
    return Int(a).toBinary()
}

// 5. Convert a given number from base 10 to base 2.
// Example:
// toBinary(a: 10) == 1010
func toBinary(a: Int) -> Int {
    return Int(a).toBinary()
}

// 6. Convert a given number from base 10 to base 2.
// Example:
// toBinary(a: 10) == 1010
func toBinary(a: Int) -> Int {
    return Int(a).toBinary()
}

// 7. Convert a given number from base 10 to base 2.
// Example:
// toBinary(a: 10) == 1010
func toBinary(a: Int) -> Int {
    return Int(a).toBinary()
}

// 8. Convert a given number from base 10 to base 2.
// Example:
// toBinary(a: 10) == 1010
func toBinary(a: Int) -> Int {
    return Int(a).toBinary()
}

// 9. Convert a given number from base 10 to base 2.
// Example:
// toBinary(a: 10) == 1010
func toBinary(a: Int) -> Int {
    return Int(a).toBinary()
}

// 10. Convert a given number from base 10 to base 2.
// Example:
// toBinary(a: 10) == 1010
func toBinary(a: Int) -> Int {
    return Int(a).toBinary()
}

// 11. Convert a given number from base 10 to base 2.
// Example:
// toBinary(a: 10) == 1010
func toBinary(a: Int) -> Int {
    return Int(a).toBinary()
}

// 12. Convert a given number from base 10 to base 2.
// Example:
// toBinary(a: 10) == 1010
func toBinary(a: Int) -> Int {
    return Int(a).toBinary()
}

// 13. Convert a given number from base 10 to base 2.
// Example:
// toBinary(a: 10) == 1010
func toBinary(a: Int) -> Int {
    return Int(a).toBinary()
}

// 14. Convert a given number from base 10 to base 2.
// Example:
// toBinary(a: 10) == 1010
func toBinary(a: Int) -> Int {
    return Int(a).toBinary()
}

// 15. Convert a given number from base 10 to base 2.
// Example:
// toBinary(a: 10) == 1010
func toBinary(a: Int) -> Int {
    return Int(a).toBinary()
}

// 16. Convert a given number from base 10 to base 2.
if isPrime(i) { // cannot find 'isPrime' in scope
return Int(a).toBinary() // value of type 'Int' has no member 'toBinary'

func isMultiplyPrime(a: Int) -> Bool {
    let primes = [2, 3, 5]
    let count = 0
    for i in 0..<a {
        if a % i == 0 {
            primes.append(i)
            count += 1
        }
    }
    if count == 3 {
        return true
    } else {
        return false
    }
}
```swift
// Write a function that returns true if the given number is the multiplication of 3 prime numbers
// and false otherwise.
// Knowing that (a) is less then 100. 
// Example:
// 30 = 2 * 3 * 5
// isMultiplyPrime(a: 30) == true
func isMultiplyPrime(a: Int) -> Bool {
    let primes = [2, 3, 5]
    let count = 0
    for i in 0..<a {
        if a % i == 0 {
            primes.append(i)
            count += 1
        }
    }
    if count == 3 {
        return true
    } else {
        return false
    }
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ------------------------------------------------
primes.append(i) // cannot use mutating member on immutable value: 'primes' is a 'let' constant
count += 1 // left side of mutating operator isn't mutable: 'count' is a 'let' constant

func isMultiplyPrime(a: Int) -> Bool {
    var count = 0
    var i = 2
    while i < 100 {
        if a % i == 0 {
            count += 1
        }
        i += 1
    }
    if count == 3 {
        return true
    } else {
        return false
    }
}

func sumDigits(a: Int) -> Int {
    var sum = 0
    var i = 0
    while i < a {
        sum += a % 10
        a = a / 10
        i += 1
    }
    return sum
}

func gcd(a: Int, b: Int) -> Int {
    var i = 1
    while i <= a && i <= b {
        if a % i == 0 && b % i == 0 {
            var gcd = i
        }
        i += 1
    }
    return gcd
}

func sumDivisors(a: Int) -> Int {
    var sum = 0
    var i = 1
    while i < a {
        if a % i == 0 {
            sum += i
        }
        i += 1
    }
    return sum
}
```swift
// Write a function that returns true if the given number is the multiplication of 3 prime numbers
// and false otherwise.
// Knowing that (a) is less then 100. 
// Example:
// 30 = 2 * 3 * 5
// isMultiplyPrime(a: 30) == true
func isMultiplyPrime(a: Int) -> Bool {
    var count = 0
    var i = 2
    while i < 100 {
        if a % i == 0 {
            count += 1
        }
        i += 1
    }
    if count == 3 {
        return true
    } else {
        return false
    }
}

// 2. Write a function that takes a number and returns the sum of its digits.
// Example:
// sumDigits(10) == 1
func sumDigits(a: Int) -> Int {
    var sum = 0
    var i = 0
    while i < a {
        sum += a % 10
        a = a / 10
        i += 1
    }
    return sum
}

// 3. Write a function that takes two numbers and returns the Greatest Common Divisor.
// Example:
// gcd(20, 30) == 10
func gcd(a: Int, b: Int) -> Int {
    var i = 1
    while i <= a && i <= b {
        if a % i == 0 && b % i == 0 {
            var gcd = i
        }
        i += 1
    }
    return gcd
}

// 4. Write a function that takes a number and returns the sum of all its divisors except itself.
// Example:
// sumDivisors(12) == 1 + 2 + 3 + 4 + 6 + 12 == 30
func sumDivisors(a: Int) -> Int {
    var sum = 0
    var i = 1
    while i < a {
        if a % i == 0 {
            sum += i
        }
        i += 1
    }
    return sum
}

// 5. Write a function that takes a number and returns the sum of all its divisors except itself.
// Example:
// sumDivisors(12) == 1 + 2 + 3 + 4 + 6 + 12 == 30
func sumDivisors(a: Int) -> Int {
    var sum = 0
    var i = 1
    while i < a {
        if a % i == 0 {
            sum += i
        }
        i += 1
    }
    return sum
}

// 6. Write a function that takes a number and returns the sum of all its divisors except itself.
// Example:
// sumDivisors(12) == 1 + 2 + 3 + 4 + 6 + 12 == 30
func sumDivisors(a: Int) -> Int {
    var sum = 0
    var i = 1
    while i < a {
        if a % i == 0 {
            sum += i
        }
        i += 1
    }
    return sum
}

// 7. Write a function that takes a number and returns the sum of all its divisors except itself.
// Example:
// sumDivisors(12) == 1 + 2 + 3 + 4 + 6 + 12 == 30
func sumDivisors(a: Int) -> Int {
    var sum = 0
    var i = 1
    while i < a {
        if a % i == 0 {
            sum += i
        }
        i += 1
    }
    return sum
}

// 8. Write a function that takes a number and returns the sum of all its divisors except itself.
// Example:
// sumDivisors(12) == 1 + 2 + 3 + 4 + 6 + 12 == 30
func sumDivisors(a: Int) -> Int {
    var sum = 0
    var i = 1
    while i < a {
        if a % i == 0 {
            sum += i
        }
        i += 1
    }
    return sum
}

// 9. Write a function that takes a number and returns the sum of all its divisors except itself.
// Example:
// sumDivisors(12) == 1 + 2 + 3 + 4 + 6 + 12 == 30
func sumDivisors(a: Int) -> Int {
    var sum = 0
    var
a = a / 10 // cannot assign to value: 'a' is a 'let' constant
return gcd // cannot convert return expression of type '(Int, Int) -> Int' to return type 'Int'

func isMultiplyPrime(a: Int) -> Bool {
    var count = 0
    for i in 2...a {
        if isPrime(i) {
            count += 1
            if count == 3 {
                return true
            }
        }
    }
    return false
}

func number_of_digits(n: Int) -> Int {
    return String(n).count
}

func numberToWords(num: Int) -> String {
    var result = ""
    var nums = ["Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"]
    var tens = ["Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"]
    var tens2 = ["Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"]
    var num = num
    if num >= 1000000000 {
        result += nums[num / 1000000000] + " Billion "
        num %= 1000000000
    }
    if num >= 1000000 {
        result += nums[num / 1000000] + " Million "
        num %= 1000000
    }
    if num >= 1000 {
        result += nums[num / 1000] + " Thousand "
        num %= 1000
    }
    if num >= 100 {
        result += nums[num / 100] + " Hundred "
        num %= 100
    }
    if num >= 20 {
        if num >= 10 {
            result += tens2[num / 10 - 2] + " "
        }
        result += nums[num % 10]
    } else if num > 0 {
        result += tens[num]
    }
    return result.trim()
}

func firstUniqChar(s: String) -> Int {
    var result = -1
    var count = [Int](repeating: 0, count: 26)
    for i in s {
        count[i - "a"] += 1
    }
    for i in s {
        if count[i - "a"] == 1 {
            result = s.firstIndex(of: i)!
            break
        }
    }
    return result
}
```swift
// Write a function that returns true if the given number is the multiplication of 3 prime numbers
// and false otherwise.
// Knowing that (a) is less then 100. 
// Example:
// 30 = 2 * 3 * 5
// isMultiplyPrime(a: 30) == true
func isMultiplyPrime(a: Int) -> Bool {
    var count = 0
    for i in 2...a {
        if isPrime(i) {
            count += 1
            if count == 3 {
                return true
            }
        }
    }
    return false
}

// 2. Write a function that returns the number of digits of given integer.
// Example:
// number_of_digits(n: 348678) == 6
func number_of_digits(n: Int) -> Int {
    return String(n).count
}

// 3. Convert a non-negative integer num to its English words representation.
// Example:
// numberToWords(num: 123) == "One Hundred Twenty Three"
func numberToWords(num: Int) -> String {
    var result = ""
    var nums = ["Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"]
    var tens = ["Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"]
    var tens2 = ["Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"]
    var num = num
    if num >= 1000000000 {
        result += nums[num / 1000000000] + " Billion "
        num %= 1000000000
    }
    if num >= 1000000 {
        result += nums[num / 1000000] + " Million "
        num %= 1000000
    }
    if num >= 1000 {
        result += nums[num / 1000] + " Thousand "
        num %= 1000
    }
    if num >= 100 {
        result += nums[num / 100] + " Hundred "
        num %= 100
    }
    if num >= 20 {
        if num >= 10 {
            result += tens2[num / 10 - 2] + " "
        }
        result += nums[num % 10]
    } else if num > 0 {
        result += tens[num]
    }
    return result.trim()
}

// 4. Given a string s, find the first non-repeating character in it and return its index.
// If it does not exist, return -1.
// Example:
// firstUniqChar(s: "leetcode") == 0
// firstUniqChar(s: "loveleetcode") == 2
func firstUniqChar(s: String) -> Int {
    var result = -1
    var count = [Int](repeating: 0, count: 26)
    for i in s {
        count[i - "a"] += 1
    }
    for i in s {
        if count[i - "a"] == 1 {
            result = s.firstIndex(of: i)!
            break
        }
    }
    return result
}

// 5. Given a string s, find the first non-repeating character in it and return its index.
// If it does not exist, return -1.
// Example:
// firstUniqChar(s: "leetcode") == 0
// firstUniqChar(s: "loveleetcode") == 2
func firstUniqChar(s: String) -> Int {
    var result = -1
    var count = [Int](repeating: 0, count: 26)
    for i in s {
        count[i - "a"] += 1
    }
    for i in s {
        if count[i - "a"] == 1 {
            result = s.firstIndex(of
if isPrime(i) { // cannot find 'isPrime' in scope
return result.trim() // value of type 'String' has no member 'trim'
count[i - "a"] += 1 // binary operator '-' cannot be applied to two 'Character' operands
if count[i - "a"] == 1 { // binary operator '-' cannot be applied to two 'Character' operands
result = s.firstIndex(of: i)! // cannot assign value of type 'String.Index' to type 'Int'

func isMultiplyPrime(a: Int) -> Bool {
    var count = 0
    for i in 2..<a {
        if a % i == 0 {
            count += 1
        }
    }
    if count == 2 {
        return true
    } else {
        return false
    }
}
```swift
// Write a function that returns true if the given number is the multiplication of 3 prime numbers
// and false otherwise.
// Knowing that (a) is less then 100. 
// Example:
// 30 = 2 * 3 * 5
// isMultiplyPrime(a: 30) == true
func isMultiplyPrime(a: Int) -> Bool {
    var count = 0
    for i in 2..<a {
        if a % i == 0 {
            count += 1
        }
    }
    if count == 2 {
        return true
    } else {
        return false
    }
}

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// 
 // XCTAssertTrue failed

func isMultiplyPrime(a: Int) -> Bool {
    var count = 0
    for i in 2...a {
        if isPrime(i) {
            count += 1
        }
        if count == 3 {
            return true
        }
    }
    return false
}

func sumTwoSmallestNumbers(numbers: [Int]) -> Int {
    var min1 = Int.max
    var min2 = Int.max
    for number in numbers {
        if number < min1 {
            min2 = min1
            min1 = number
        } else if number < min2 {
            min2 = number
        }
    }
    return min1 + min2
}

func findOdd(array: [Int]) -> Int {
    var count = 0
    for number in array {
        for i in array {
            if number == i {
                count += 1
            }
        }
        if count % 2 != 0 {
            return number
        }
        count = 0
    }
    return 0
}

func findOdd2(array: [Int]) -> Int {
    var count = 0
    for number in array {
        for i in array {
            if number == i {
                count += 1
            }
        }
        if count % 2 != 0 {
            return number
        }
        count = 0
    }
    return 0
}
```swift
// Write a function that returns true if the given number is the multiplication of 3 prime numbers
// and false otherwise.
// Knowing that (a) is less then 100. 
// Example:
// 30 = 2 * 3 * 5
// isMultiplyPrime(a: 30) == true
func isMultiplyPrime(a: Int) -> Bool {
    var count = 0
    for i in 2...a {
        if isPrime(i) {
            count += 1
        }
        if count == 3 {
            return true
        }
    }
    return false
}

// 2. Write a function that takes a number and returns the sum of the two lowest positive
// numbers given an array of minimum 4 positive integers.
// For example, when an array is passed like [19, 5, 42, 2, 77], the output should be 7.
// [10, 343445353, 3453445, 3453545353453] should return 3453455.
// Note: All array values are positive and will always be valid.
// Multiples of 2 or 3 should not be counted as multipliers.
// Examples:
// sumTwoSmallestNumbers([5, 8, 12, 18, 22]) == 13
// sumTwoSmallestNumbers([7, 15, 12, 18, 22]) == 19
// sumTwoSmallestNumbers([25, 4, 2, 6, 10]) == 8
// sumTwoSmallestNumbers([15, 4, 10, 18, 22]) == 13
func sumTwoSmallestNumbers(numbers: [Int]) -> Int {
    var min1 = Int.max
    var min2 = Int.max
    for number in numbers {
        if number < min1 {
            min2 = min1
            min1 = number
        } else if number < min2 {
            min2 = number
        }
    }
    return min1 + min2
}

// 3. Given an array of integers, find the one that appears an odd number of times.
// There will always be only one integer that appears an odd number of times.
// Examples
// [7] should return 7, because it occurs 1 time (which is odd).
// [0] should return 0, because it occurs 1 time (which is odd).
// [1,1,2] should return 2, because it occurs 1 time (which is odd).
// [0,1,0,1,0] should return 0, because it occurs 3 times (which is odd).
// [1,2,2,3,3,3,4,3,3,3,2,2,1] should return 4, because it appears 1 time (which is odd).
func findOdd(array: [Int]) -> Int {
    var count = 0
    for number in array {
        for i in array {
            if number == i {
                count += 1
            }
        }
        if count % 2 != 0 {
            return number
        }
        count = 0
    }
    return 0
}

// 4. Given an array of integers, find the one that appears an odd number of times.
// There will always be only one integer that appears an odd number of times.
// Examples
// [7] should return 7, because it occurs 1 time (which is odd).
// [0] should return 0, because it occurs 1 time (which is odd).
// [1,1,2] should return 2, because it occurs 1 time (which is odd).
// [0,1,0,1,0] should return 0, because it occurs 3 times (which is odd).
// [1,2,2,3,3,3,4,3,3,3,2,2,1] should return 4, because it appears 1 time (which is odd).
func findOdd2(array: [Int]) -> Int {
    var count = 0
    for number in array {
        for i in array {
            if number == i {
                count += 1
            }
        }
        if count % 2 != 0 {
            return number
        }
        count = 0
    }
    return 0
}

// 5. Given an array of integers, find the one that appears an odd number of times.
// There will
if isPrime(i) { // cannot find 'isPrime' in scope

func isMultiplyPrime(a: Int) -> Bool {
    if a < 100 {
        let primeNumbers = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
        var isPrime = true
        for i in 0..<primeNumbers.count {
            if primeNumbers[i] == a {
                isPrime = true
                break
            } else {
                isPrime = false
            }
        }
        return isPrime
    } else {
        return false
    }
}
```swift
// Write a function that returns true if the given number is the multiplication of 3 prime numbers
// and false otherwise.
// Knowing that (a) is less then 100. 
// Example:
// 30 = 2 * 3 * 5
// isMultiplyPrime(a: 30) == true
func isMultiplyPrime(a: Int) -> Bool {
    if a < 100 {
        let primeNumbers = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
        var isPrime = true
        for i in 0..<primeNumbers.count {
            if primeNumbers[i] == a {
                isPrime = true
                break
            } else {
                isPrime = false
            }
        }
        return isPrime
    } else {
        return false
    }
}

print(isMultiplyPrime(a: 30))

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
 // XCTAssertTrue failed

func isSimplePower(x: Int, n: Int) -> Bool {
    return Int(x) == pow(n, Int(x))
}
```swift
// Your task is to write a function that returns true if a number x is a simple
// power of n and false in other cases.
// x is a simple power of n if n**int=x
// For example:
// isSimplePower(x: 1, n: 4) == true
// isSimplePower(x: 2, n: 2) == true
// isSimplePower(x: 8, n: 2) == true
// isSimplePower(x: 3, n: 2) == false
// isSimplePower(x: 3, n: 1) == false
// isSimplePower(x: 5, n: 3) == false
func isSimplePower(x: Int, n: Int) -> Bool {
    return Int(x) == pow(n, Int(x))
}

// -----------------------------------------------------------------------------
// 10. Write a function that takes a string and returns the number of vowels
//     in the string.
//     Vowels are the letters "a", "e", "i", "o", and "u".
//     The input string will only consist of lower case letters and/or spaces.
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 11. Write a function that takes a string and returns the number of vowels
//     in the string.
//     Vowels are the letters "a", "e", "i", "o", and "u".
//     The input string will only consist of lower case letters and/or spaces.
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 12. Write a function that takes a string and returns the number of vowels
//     in the string.
//     Vowels are the letters "a", "e", "i", "o", and "u".
//     The input string will only consist of lower case letters and/or spaces.
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 13. Write a function that takes a string and returns the number of vowels
//     in the string.
//     Vowels are the letters "a", "e", "i", "o", and "u".
//     The input string will only consist of lower case letters and/or spaces.
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 14. Write a function that takes a string and returns the number of vowels
//     in the string.
//     Vowels are the letters "a", "e", "i", "o", and "u".
//     The input string will only consist of lower case letters and/or spaces.
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 15. Write a function that takes a string and returns the number of vowels
//     in the string.
//     Vowels are the letters "a", "e", "i", "o", and "u".
//     The input string will only consist of lower case letters and/or spaces.
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 16. Write a function that takes a string and returns the number of vowels
//     in the string.
//     Vowels are the letters "a", "e", "i", "o", and "u".
//     The input string will only consist of lower case letters and/or spaces.
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// 17. Write a function that takes a string and returns the number of vowels
//     in the string.
//     Vowels are the letters "a
return Int(x) == pow(n, Int(x)) // cannot convert value of type 'Int' to expected argument type 'Decimal'
return Int(x) == pow(n, Int(x)) // operator function '==' requires that 'Decimal' conform to 'BinaryInteger'

func isSimplePower(x: Int, n: Int) -> Bool {
    return Int(x).isPowerOf(n)
}

func add(x: String, y: String) -> Int {
    return Int(x) + Int(y)
}

func vowelCount(s: String) -> Int {
    return s.count(.vowel)
}

func isPalindrome(s: String) -> Bool {
    return s.isPalindrome()
}

func countString(s: String, sub: String) -> Int {
    return s.count(sub)
}

func countStringIgnoreCase(s: String, sub: String) -> Int {
    return s.countIgnoreCase(sub)
}

func countStringIgnoreCaseAndPunctuation(s: String, sub: String) -> Int {
    return s.countIgnoreCaseAndPunctuation(sub)
}
```swift
// Your task is to write a function that returns true if a number x is a simple
// power of n and false in other cases.
// x is a simple power of n if n**int=x
// For example:
// isSimplePower(x: 1, n: 4) == true
// isSimplePower(x: 2, n: 2) == true
// isSimplePower(x: 8, n: 2) == true
// isSimplePower(x: 3, n: 2) == false
// isSimplePower(x: 3, n: 1) == false
// isSimplePower(x: 5, n: 3) == false
func isSimplePower(x: Int, n: Int) -> Bool {
    return Int(x).isPowerOf(n)
}

// -----------------------------------------------------------------------------
// 11. Write a function that returns the sum of two numbers.
//     The two numbers are passed in as strings.
//     Example: add("123", "321") // returns 444
// -----------------------------------------------------------------------------
func add(x: String, y: String) -> Int {
    return Int(x) + Int(y)
}

// -----------------------------------------------------------------------------
// 12. Write a function that takes a string and returns the number of
//     vowels in the string.
//     You should ignore case.
//     The vowels are 'a', 'e', 'i', 'o', and 'u'.
//     Example: vowelCount("Hello") // returns 2
// -----------------------------------------------------------------------------
func vowelCount(s: String) -> Int {
    return s.count(.vowel)
}

// -----------------------------------------------------------------------------
// 13. Write a function that takes a string and returns true if the string
//     is a palindrome and false otherwise.
//     A palindrome is a word that is spelled the same forwards and backwards.
//     Example: isPalindrome("racecar") // returns true
// -----------------------------------------------------------------------------
func isPalindrome(s: String) -> Bool {
    return s.isPalindrome()
}

// -----------------------------------------------------------------------------
// 14. Write a function that takes a string and returns the number of times
//     that string appears in the string.
//     Example: countString("Hello", "l") // returns 2
// -----------------------------------------------------------------------------
func countString(s: String, sub: String) -> Int {
    return s.count(sub)
}

// -----------------------------------------------------------------------------
// 15. Write a function that takes a string and returns the number of times
//     that string appears in the string, ignoring case.
//     Example: countStringIgnoreCase("Hello", "l") // returns 2
// -----------------------------------------------------------------------------
func countStringIgnoreCase(s: String, sub: String) -> Int {
    return s.countIgnoreCase(sub)
}

// -----------------------------------------------------------------------------
// 16. Write a function that takes a string and returns the number of times
//     that string appears in the string, ignoring case and punctuation.
//     Example: countStringIgnoreCaseAndPunctuation("Hello, world!", "l") // returns 3
// -----------------------------------------------------------------------------
func countStringIgnoreCaseAndPunctuation(s: String, sub: String) -> Int {
    return s.countIgnoreCaseAndPunctuation(sub)
}

// -----------------------------------------------------------------------------
// 17. Write a function that takes a string and returns the number of times
//     that string appears in the string, ignoring case, punctuation, and spaces.
//     Example: countStringIgnoreCaseAndPunctuationAndSpaces("Hello, world!", "l") // returns 3
// ---------------
return Int(x).isPowerOf(n) // value of type 'Int' has no member 'isPowerOf'
return Int(x) + Int(y) // binary operator '+' cannot be applied to two 'Int?' operands
return s.count(.vowel) // cannot infer contextual base in reference to member 'vowel'
return s.count(.vowel) // cannot call value of non-function type 'Int'
return s.isPalindrome() // value of type 'String' has no member 'isPalindrome'
return s.count(sub) // cannot call value of non-function type 'Int'
return s.countIgnoreCase(sub) // value of type 'String' has no member 'countIgnoreCase'
return s.countIgnoreCaseAndPunctuation(sub) // value of type 'String' has no member 'countIgnoreCaseAndPunctuation'

func isSimplePower(x: Int, n: Int) -> Bool {
    return Int(x) == pow(n, Int(log(Double(x), n)))
}
```swift
// Your task is to write a function that returns true if a number x is a simple
// power of n and false in other cases.
// x is a simple power of n if n**int=x
// For example:
// isSimplePower(x: 1, n: 4) == true
// isSimplePower(x: 2, n: 2) == true
// isSimplePower(x: 8, n: 2) == true
// isSimplePower(x: 3, n: 2) == false
// isSimplePower(x: 3, n: 1) == false
// isSimplePower(x: 5, n: 3) == false
func isSimplePower(x: Int, n: Int) -> Bool {
    return Int(x) == pow(n, Int(log(Double(x), n)))
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
return Int(x) == pow(n, Int(log(Double(x), n))) // operator function '==' requires that 'Decimal' conform to 'BinaryInteger'
return Int(x) == pow(n, Int(log(Double(x), n))) // cannot convert value of type 'Int' to expected argument type 'Decimal'
return Int(x) == pow(n, Int(log(Double(x), n))) // extra argument in call

func isSimplePower(x: Int, n: Int) -> Bool {
    if x == 1 {
        return true
    }
    if x == 0 {
        return false
    }
    if x % n != 0 {
        return false
    }
    let result = x / n
    if result == 1 {
        return true
    }
    return isSimplePower(x: result, n: n)
}
```swift
// Your task is to write a function that returns true if a number x is a simple
// power of n and false in other cases.
// x is a simple power of n if n**int=x
// For example:
// isSimplePower(x: 1, n: 4) == true
// isSimplePower(x: 2, n: 2) == true
// isSimplePower(x: 8, n: 2) == true
// isSimplePower(x: 3, n: 2) == false
// isSimplePower(x: 3, n: 1) == false
// isSimplePower(x: 5, n: 3) == false
func isSimplePower(x: Int, n: Int) -> Bool {
    if x == 1 {
        return true
    }
    if x == 0 {
        return false
    }
    if x % n != 0 {
        return false
    }
    let result = x / n
    if result == 1 {
        return true
    }
    return isSimplePower(x: result, n: n)
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ---------

func isSimplePower(x: Int, n: Int) -> Bool {
    if x == 1 {
        return true
    }
    if x == 0 {
        return false
    }
    if x % n != 0 {
        return false
    }
    let pow = x / n
    if pow == 1 {
        return true
    }
    return isSimplePower(x: pow, n: n)
}
```swift
// Your task is to write a function that returns true if a number x is a simple
// power of n and false in other cases.
// x is a simple power of n if n**int=x
// For example:
// isSimplePower(x: 1, n: 4) == true
// isSimplePower(x: 2, n: 2) == true
// isSimplePower(x: 8, n: 2) == true
// isSimplePower(x: 3, n: 2) == false
// isSimplePower(x: 3, n: 1) == false
// isSimplePower(x: 5, n: 3) == false
func isSimplePower(x: Int, n: Int) -> Bool {
    if x == 1 {
        return true
    }
    if x == 0 {
        return false
    }
    if x % n != 0 {
        return false
    }
    let pow = x / n
    if pow == 1 {
        return true
    }
    return isSimplePower(x: pow, n: n)
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// ---

func isSimplePower(x: Int, n: Int) -> Bool {
    return Int(x) == Int(n) ** Int(n)
}

func numberOfDigits(number: Int) -> Int {
    return String(number).count
}
```swift
// Your task is to write a function that returns true if a number x is a simple
// power of n and false in other cases.
// x is a simple power of n if n**int=x
// For example:
// isSimplePower(x: 1, n: 4) == true
// isSimplePower(x: 2, n: 2) == true
// isSimplePower(x: 8, n: 2) == true
// isSimplePower(x: 3, n: 2) == false
// isSimplePower(x: 3, n: 1) == false
// isSimplePower(x: 5, n: 3) == false
func isSimplePower(x: Int, n: Int) -> Bool {
    return Int(x) == Int(n) ** Int(n)
}

// -----------------------------------------------------------------------------
// 12. Write a function that returns the number of digits of a given integer.
// For example:
// numberOfDigits(1234) == 4
// numberOfDigits(12) == 2
// numberOfDigits(1) == 1
// numberOfDigits(0) == 1
func numberOfDigits(number: Int) -> Int {
    return String(number).count
}

// -----------------------------------------------------------------------------
// 13. Write a function that returns the number of digits of a given integer.
// For example:
// numberOfDigits(1234) == 4
// numberOfDigits(12) == 2
// numberOfDigits(1) == 1
// numberOfDigits(0) == 1
func numberOfDigits(number: Int) -> Int {
    return String(number).count
}

// -----------------------------------------------------------------------------
// 14. Write a function that returns the number of digits of a given integer.
// For example:
// numberOfDigits(1234) == 4
// numberOfDigits(12) == 2
// numberOfDigits(1) == 1
// numberOfDigits(0) == 1
func numberOfDigits(number: Int) -> Int {
    return String(number).count
}

// -----------------------------------------------------------------------------
// 15. Write a function that returns the number of digits of a given integer.
// For example:
// numberOfDigits(1234) == 4
// numberOfDigits(12) == 2
// numberOfDigits(1) == 1
// numberOfDigits(0) == 1
func numberOfDigits(number: Int) -> Int {
    return String(number).count
}

// -----------------------------------------------------------------------------
// 16. Write a function that returns the number of digits of a given integer.
// For example:
// numberOfDigits(1234) == 4
// numberOfDigits(12) == 2
// numberOfDigits(1) == 1
// numberOfDigits(0) == 1
func numberOfDigits(number: Int) -> Int {
    return String(number).count
}

// -----------------------------------------------------------------------------
// 17. Write a function that returns the number of digits of a given integer.
// For example:
// numberOfDigits(1234) == 4
// numberOfDigits(12) == 2
// numberOfDigits(1) == 1
// numberOfDigits(0) == 1
func numberOfDigits(number: Int) -> Int {
    return String(number).count
}

// -----------------------------------------------------------------------------
// 18. Write a function that returns the number of digits of a given integer.
// For example:
// numberOfDigits(1234) == 4
// numberOfDigits(12) == 2
// numberOfDigits(1) == 1
// numberOfDigits(0) == 1
func numberOfDigits(number: Int) -> Int {
    return String(number).count
}

// -----------------------------------------------------------------------------
// 19. Write a function that returns the number of digits of a given integer.
// For example:
// numberOfDigits(1234) == 4
// numberOfDigits(12) ==
return Int(x) == Int(n) ** Int(n) // no operator '**' is defined; did you mean 'pow(_:_:)'?

func isSimplePower(x: Int, n: Int) -> Bool {
    return Int(x) == Int(n) ** Int(n)
}

func add(a: Int, b: Int) -> Int {
    return a + b
}

func doubleChar(s: String) -> String {
    return String(s).map { $0 * 2 }.joined()
}
```swift
// Your task is to write a function that returns true if a number x is a simple
// power of n and false in other cases.
// x is a simple power of n if n**int=x
// For example:
// isSimplePower(x: 1, n: 4) == true
// isSimplePower(x: 2, n: 2) == true
// isSimplePower(x: 8, n: 2) == true
// isSimplePower(x: 3, n: 2) == false
// isSimplePower(x: 3, n: 1) == false
// isSimplePower(x: 5, n: 3) == false
func isSimplePower(x: Int, n: Int) -> Bool {
    return Int(x) == Int(n) ** Int(n)
}

// -----------------------------------------------------------------------------
// 12. Write a function that returns the sum of two numbers.
// Example:
// add(1, 2) == 3
func add(a: Int, b: Int) -> Int {
    return a + b
}

// -----------------------------------------------------------------------------
// 13. Given a string, you have to return a string in which each character (case-sensitive) is repeated once.
// Examples:
// doubleChar("String") ==> "SSttrriinngg"
// doubleChar("Hello World!") ==> "HHeelllloo  WWoorrlldd!!"
// doubleChar("1234!_ ") ==> "11223344!!__  "
func doubleChar(s: String) -> String {
    return String(s).map { $0 * 2 }.joined()
}

// -----------------------------------------------------------------------------
// 14. Given a string, you have to return a string in which each character (case-sensitive) is repeated once.
// Examples:
// doubleChar("String") ==> "SSttrriinngg"
// doubleChar("Hello World!") ==> "HHeelllloo  WWoorrlldd!!"
// doubleChar("1234!_ ") ==> "11223344!!__  "
func doubleChar(s: String) -> String {
    return String(s).map { $0 * 2 }.joined()
}

// -----------------------------------------------------------------------------
// 15. Given a string, you have to return a string in which each character (case-sensitive) is repeated once.
// Examples:
// doubleChar("String") ==> "SSttrriinngg"
// doubleChar("Hello World!") ==> "HHeelllloo  WWoorrlldd!!"
// doubleChar("1234!_ ") ==> "11223344!!__  "
func doubleChar(s: String) -> String {
    return String(s).map { $0 * 2 }.joined()
}

// -----------------------------------------------------------------------------
// 16. Given a string, you have to return a string in which each character (case-sensitive) is repeated once.
// Examples:
// doubleChar("String") ==> "SSttrriinngg"
// doubleChar("Hello World!") ==> "HHeelllloo  WWoorrlldd!!"
// doubleChar("1234!_ ") ==> "11223344!!__  "
func doubleChar(s: String) -> String {
    return String(s).map { $0 * 2 }.joined()
}

// -----------------------------------------------------------------------------
// 17. Given a string, you have to return a string in which each character (case-sensitive) is repeated once.
// Examples:
// doubleChar("String") ==> "SSttrriinngg"
// doubleChar("Hello World!") ==> "HHeelllloo  WWoorrlldd!!"
// doubleChar("1234!_ ") ==> "11223344!!__  "
func doubleChar(s: String) -> String {
    return String(s).map { $0 * 2 }.joined()
}

// -----------------------------------------------------------------------------
// 18. Given a string, you have to return
return Int(x) == Int(n) ** Int(n) // no operator '**' is defined; did you mean 'pow(_:_:)'?
return String(s).map { $0 * 2 }.joined() // cannot convert value of type 'Int' to closure result type 'String'
return String(s).map { $0 * 2 }.joined() // cannot convert value of type 'String.Element' (aka 'Character') to expected argument type 'Int'

func isSimplePower(x: Int, n: Int) -> Bool {
    return Int(x) == pow(n, Int(x))
}

func reverseString(string: String) -> String {
    return string.reversed().join()
}

func isPalindrome(string: String) -> Bool {
    return string == string.reversed().join()
}

func removeVowels(string: String) -> String {
    return string.filter { !isVowel($0) }
}
```swift
// Your task is to write a function that returns true if a number x is a simple
// power of n and false in other cases.
// x is a simple power of n if n**int=x
// For example:
// isSimplePower(x: 1, n: 4) == true
// isSimplePower(x: 2, n: 2) == true
// isSimplePower(x: 8, n: 2) == true
// isSimplePower(x: 3, n: 2) == false
// isSimplePower(x: 3, n: 1) == false
// isSimplePower(x: 5, n: 3) == false
func isSimplePower(x: Int, n: Int) -> Bool {
    return Int(x) == pow(n, Int(x))
}

// 12. Write a function that takes a string as an argument and returns the
// string with the letters reversed.
// For example:
// reverseString("hello") == "olleh"
// reverseString("Howdy") == "ydwoH"
// reverseString("Greetings from Earth") == "htraE morf sgniteerG"
func reverseString(string: String) -> String {
    return string.reversed().join()
}

// 13. Write a function that takes a string as an argument and returns true if
// the string is a palindrome and false if it is not.
// A palindrome is a word, phrase, number, or other sequence of characters
// which reads the same backward as forward, such as madam or racecar.
// For example:
// isPalindrome("madam") == true
// isPalindrome("hello") == false
// isPalindrome("123210") == false
// isPalindrome("12321") == true
// isPalindrome("12345") == false
func isPalindrome(string: String) -> Bool {
    return string == string.reversed().join()
}

// 14. Write a function that takes a string as an argument and returns the
// string with all vowels removed.
// For example:
// removeVowels("I have never seen a thin person drinking Diet Coke.") ==
// " hv nvr sn  thn prsn drnkng Dt Ck."
// removeVowels("aeiou") == ""
// removeVowels("abcdefghijklmnopqrstuvwxyz") == "bcdfghjklmnpqrstvwxyz"
func removeVowels(string: String) -> String {
    return string.filter { !isVowel($0) }
}

// 15. Write a function that takes a string as an argument and returns true if
// the string is a palindrome and false if it is not.
// A palindrome is a word, phrase, number, or other sequence of characters
// which reads the same backward as forward, such as madam or racecar.
// For example:
// isPalindrome("madam") == true
// isPalindrome("hello") == false
// isPalindrome("123210") == false
// isPalindrome("12321") == true
// isPalindrome("12345") == false
func isPalindrome(string: String) -> Bool {
    return string == string.reversed().join()
}

// 16. Write a function that takes a string as an argument and returns true if
// the string is a palindrome and false if it is not.
// A palindrome is a word, phrase, number, or other sequence of characters
// which reads the same backward as forward, such as madam or racecar.
// For example:
// isPalindrome("madam") == true
// isPalindrome("hello") == false
// isPalindrome("123210") == false
// isPalindrome("12321") == true
// isPalindrome("12345") == false
func isPalindrome(string: String) -> Bool {
    return string == string.reversed().join()
}

// 17. Write a function that takes a string as an argument and returns true if
// the string is a palindrome and false if it is not.
// A palindrome is a word, phrase, number, or other sequence of characters
// which reads the same backward as forward, such as madam or racecar.
// For example:
// isPalindrome("madam") == true
// isPalindrome("hello") == false
// isPalindrome("123210") == false
// isPalindrome("12321") == true
// isPalindrome("12345") == false
func isPalindrome(
return Int(x) == pow(n, Int(x)) // operator function '==' requires that 'Decimal' conform to 'BinaryInteger'
return Int(x) == pow(n, Int(x)) // cannot convert value of type 'Int' to expected argument type 'Decimal'
return string.reversed().join() // reference to member 'join' cannot be resolved without a contextual type
return string == string.reversed().join() // reference to member 'join' cannot be resolved without a contextual type
return string.filter { !isVowel($0) } // cannot find 'isVowel' in scope

func isSimplePower(x: Int, n: Int) -> Bool {
    return Int(x) == Int(pow(n, Int(log2(x))))
}

func removeVowels(s: String) -> String {
    return s.trim().filter { !isVowel($0) }
}

func removeConsonants(s: String) -> String {
    return s.trim().filter { isConsonant($0) }
}
```swift
// Your task is to write a function that returns true if a number x is a simple
// power of n and false in other cases.
// x is a simple power of n if n**int=x
// For example:
// isSimplePower(x: 1, n: 4) == true
// isSimplePower(x: 2, n: 2) == true
// isSimplePower(x: 8, n: 2) == true
// isSimplePower(x: 3, n: 2) == false
// isSimplePower(x: 3, n: 1) == false
// isSimplePower(x: 5, n: 3) == false
func isSimplePower(x: Int, n: Int) -> Bool {
    return Int(x) == Int(pow(n, Int(log2(x))))
}

// -----------------------------------------------------------------------------
// 10. Write a function that takes a string and returns a new string with all
// the vowels removed.
// For example:
// removeVowels("I have never seen a thin person drinking Diet Coke.") ==
// " hv nvr sn  thn prsn drnkng Dt Ck."
// removeVowels("abracadabra") == "brcrdrbr"
// removeVowels("") == ""
func removeVowels(s: String) -> String {
    return s.trim().filter { !isVowel($0) }
}

// -----------------------------------------------------------------------------
// 11. Write a function that takes a string and returns a new string with all
// the consonants removed.
// For example:
// removeConsonants("I have never seen a thin person drinking Diet Coke.") ==
// " hv nvr sn  thn prsn drnkng Dt Ck."
// removeConsonants("abracadabra") == "brcrdrbr"
// removeConsonants("") == ""
func removeConsonants(s: String) -> String {
    return s.trim().filter { isConsonant($0) }
}

// -----------------------------------------------------------------------------
// 12. Write a function that takes a string and returns a new string with all
// the vowels removed.
// For example:
// removeConsonants("I have never seen a thin person drinking Diet Coke.") ==
// " hv nvr sn  thn prsn drnkng Dt Ck."
// removeConsonants("abracadabra") == "brcrdrbr"
// removeConsonants("") == ""
func removeConsonants(s: String) -> String {
    return s.trim().filter { isConsonant($0) }
}

// -----------------------------------------------------------------------------
// 13. Write a function that takes a string and returns a new string with all
// the vowels removed.
// For example:
// removeConsonants("I have never seen a thin person drinking Diet Coke.") ==
// " hv nvr sn  thn prsn drnkng Dt Ck."
// removeConsonants("abracadabra") == "brcrdrbr"
// removeConsonants("") == ""
func removeConsonants(s: String) -> String {
    return s.trim().filter { isConsonant($0) }
}

// -----------------------------------------------------------------------------
// 14. Write a function that takes a string and returns a new string with all
// the vowels removed.
// For example:
// removeConsonants("I have never seen a thin person drinking Diet Coke.") ==
// " hv nvr sn  thn prsn drnkng Dt Ck."
// removeConsonants("abracadabra") == "brcrdrbr"
// removeConsonants("") == ""
func removeConsonants(s: String) -> String {
    return s.trim().filter { isConsonant($0) }
}

// -----------------------------------------------------------------------------
// 15. Write a function that takes a string and returns a new string with all
// the vowels removed.
// For example:
// removeConsonants("I have never seen a thin person drinking Diet Coke.") ==
// " hv nvr sn  thn prsn drnkng Dt Ck."
// removeConsonants("abracadabra") ==
return Int(x) == Int(pow(n, Int(log2(x)))) // no exact matches in call to global function 'log2'
return Int(x) == Int(pow(n, Int(log2(x)))) // cannot convert value of type 'Int' to expected argument type 'Decimal'
return Int(x) == Int(pow(n, Int(log2(x)))) // initializer 'init(_:)' requires that 'Decimal' conform to 'BinaryInteger'
return s.trim().filter { !isVowel($0) } // value of type 'String' has no member 'trim'
return s.trim().filter { !isVowel($0) } // cannot find 'isVowel' in scope
return s.trim().filter { isConsonant($0) } // cannot find 'isConsonant' in scope
return s.trim().filter { isConsonant($0) } // value of type 'String' has no member 'trim'

func isSimplePower(x: Int, n: Int) -> Bool {
    return Int(x) == pow(n, Int(log(Double(x) / log(n)) / log(n)))
}
```swift
// Your task is to write a function that returns true if a number x is a simple
// power of n and false in other cases.
// x is a simple power of n if n**int=x
// For example:
// isSimplePower(x: 1, n: 4) == true
// isSimplePower(x: 2, n: 2) == true
// isSimplePower(x: 8, n: 2) == true
// isSimplePower(x: 3, n: 2) == false
// isSimplePower(x: 3, n: 1) == false
// isSimplePower(x: 5, n: 3) == false
func isSimplePower(x: Int, n: Int) -> Bool {
    return Int(x) == pow(n, Int(log(Double(x) / log(n)) / log(n)))
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// https://www.codewars.com/kata/546e2562b03326a88e000020/train/swift
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// 
return Int(x) == pow(n, Int(log(Double(x) / log(n)) / log(n))) // cannot convert value of type 'Int' to expected argument type 'Decimal'
return Int(x) == pow(n, Int(log(Double(x) / log(n)) / log(n))) // cannot convert value of type 'Int' to expected argument type 'Double'
return Int(x) == pow(n, Int(log(Double(x) / log(n)) / log(n))) // cannot convert value of type 'Int' to expected argument type 'Double'
return Int(x) == pow(n, Int(log(Double(x) / log(n)) / log(n))) // operator function '==' requires that 'Decimal' conform to 'BinaryInteger'

func iscube(a: Int) -> Bool {
    return Int(cbrt(a)) ** 3 == a
}

func sortString(s: String) -> String {
    return String(sorted: s)
}

func countVowels(s: String) -> Int {
    return s.count(where: \Character.isVowel)
}

func isPalindrome(s: String) -> Bool {
    return s == String(sorted: s.reversed())
}

func removeVowels(s: String) -> String {
    return s.replacingCharacters(with: "aeiouAEIOU", options: .caseInsensitive)
}
```swift
// Write a function that takes an integer a and returns true 
// if this ingeger is a cube of some integer number.
// Note: you may assume the input is always valid.
// Examples:
// iscube(a: 1) == true
// iscube(a: 2) == false
// iscube(a: -1) == true
// iscube(a: 64) == true
// iscube(a: 0) == true
// iscube(a: 180) == false
func iscube(a: Int) -> Bool {
    return Int(cbrt(a)) ** 3 == a
}

// -----------------------------------------------------------------------------
// 10. Write a function that takes a string and returns a string in which
//     characters are sorted in alphabetical order.
// Examples:
// sortString("hello") == "ehllo"
// sortString("edabit") == "abdeit"
// sortString("hacker") == "aaeehh"
// sortString("geek") == "aeegk"
// sortString("javascript") == "aacijprstv"
func sortString(s: String) -> String {
    return String(sorted: s)
}

// -----------------------------------------------------------------------------
// 11. Write a function that takes a string and returns the number of
//     vowels in the string.
// Note:
//     The vowel letters are: a, e, i, o, u, and the letter y.
//     The letter y should not be counted as a vowel if it is the first or
//     last letter in the string.
//     The function should be case-insensitive, meaning that A and a should
//     be counted together.
// Examples:
// countVowels("Celebration") == 5
// countVowels("Palm") == 1
// countVowels("Prediction") == 4
func countVowels(s: String) -> Int {
    return s.count(where: \Character.isVowel)
}

// -----------------------------------------------------------------------------
// 12. Write a function that takes a string and returns true if the string
//     is a palindrome and false otherwise.
// Note:
//     A palindrome is a word that is spelled the same forwards and backwards.
// Examples:
// isPalindrome("anna") == true
// isPalindrome("civic") == true
// isPalindrome("civic2") == false
// isPalindrome("apple") == false
func isPalindrome(s: String) -> Bool {
    return s == String(sorted: s.reversed())
}

// -----------------------------------------------------------------------------
// 13. Write a function that takes a string and returns a new string with
//     all vowels removed.
// Note:
//     The vowel letters are: a, e, i, o, u, and the letter y.
//     The letter y should not be counted as a vowel if it is the first or
//     last letter in the string.
//     The function should be case-insensitive, meaning that A and a should
//     be counted together.
// Examples:
// removeVowels("I have never seen a thin person drinking Diet Coke.") ==
//     " hv nvr sn  thn prsn drnkng Dt Coke."
// removeVowels("abracadabra") == "brcrdbr"
// removeVowels("pear tree") == " prtr"
// removeVowels("bring out your dead body") == " brng  yt hw ydb"
func removeVowels(s: String) -> String {
    return s.replacingCharacters(with: "aeiouAEIOU", options: .caseInsensitive)
}

// -----------------------------------------------------------------------------
// 14. Write a function that takes a string and returns a new string with
//     all the vowels removed.
// Note:
//     The vowel letters are: a, e, i, o, u, and the letter y.
//     The letter y should not be counted as a vowel if it is the first or
//     last letter in the string.
//     The function should be case-insensitive, meaning that A and a should
//     be counted
return Int(cbrt(a)) ** 3 == a // no operator '**' is defined; did you mean 'pow(_:_:)'?
return Int(cbrt(a)) ** 3 == a // no exact matches in call to global function 'cbrt'
return String(sorted: s) // no exact matches in call to initializer
return s.count(where: \Character.isVowel) // cannot call value of non-function type 'Int'
return s.count(where: \Character.isVowel) // value of type 'Character' has no member 'isVowel'
return s == String(sorted: s.reversed()) // no exact matches in call to initializer
return s.replacingCharacters(with: "aeiouAEIOU", options: .caseInsensitive) // extra argument 'options' in call
return s.replacingCharacters(with: "aeiouAEIOU", options: .caseInsensitive) // missing argument for parameter 'in' in call
return s.replacingCharacters(with: "aeiouAEIOU", options: .caseInsensitive) // cannot infer contextual base in reference to member 'caseInsensitive'

func iscube(a: Int) -> Bool {
    let root = Int(cbrt(Double(a)))
    return root * root * root == a
}

func isPerfectPower(a: Int) -> Bool {
    var root = Int(cbrt(Double(a)))
    while root * root * root > a {
        root -= 1
    }
    return root * root * root == a
}
```swift
// Write a function that takes an integer a and returns true 
// if this ingeger is a cube of some integer number.
// Note: you may assume the input is always valid.
// Examples:
// iscube(a: 1) == true
// iscube(a: 2) == false
// iscube(a: -1) == true
// iscube(a: 64) == true
// iscube(a: 0) == true
// iscube(a: 180) == false
func iscube(a: Int) -> Bool {
    let root = Int(cbrt(Double(a)))
    return root * root * root == a
}

// -----------------------------------------------------------------------------
// 11. Write a function that takes an integer a and returns true if it is a perfect
// power. A perfect power is defined as an integer that can be expressed as
// an integer power of another integer.
// Examples:
// isPerfectPower(4) == true
// isPerfectPower(5) == false
// isPerfectPower(16) == true
// isPerfectPower(100) == true
// isPerfectPower(99) == false
// isPerfectPower(6561) == true
// isPerfectPower(216) == true
// isPerfectPower(6560) == false
// isPerfectPower(1) == true
// isPerfectPower(2) == true
// isPerfectPower(81) == true
// isPerfectPower(1000000000000000) == false
func isPerfectPower(a: Int) -> Bool {
    var root = Int(cbrt(Double(a)))
    while root * root * root > a {
        root -= 1
    }
    return root * root * root == a
}

// -----------------------------------------------------------------------------
// 12. Write a function that takes an integer a and returns true if it is a perfect
// power. A perfect power is defined as an integer that can be expressed as
// an integer power of another integer.
// Examples:
// isPerfectPower(4) == true
// isPerfectPower(5) == false
// isPerfectPower(16) == true
// isPerfectPower(100) == true
// isPerfectPower(99) == false
// isPerfectPower(6561) == true
// isPerfectPower(216) == true
// isPerfectPower(6560) == false
// isPerfectPower(1) == true
// isPerfectPower(2) == true
// isPerfectPower(81) == true
// isPerfectPower(1000000000000000) == false
func isPerfectPower(a: Int) -> Bool {
    var root = Int(cbrt(Double(a)))
    while root * root * root > a {
        root -= 1
    }
    return root * root * root == a
}

// -----------------------------------------------------------------------------
// 13. Write a function that takes an integer a and returns true if it is a perfect
// power. A perfect power is defined as an integer that can be expressed as
// an integer power of another integer.
// Examples:
// isPerfectPower(4) == true
// isPerfectPower(5) == false
// isPerfectPower(16) == true
// isPerfectPower(100) == true
// isPerfectPower(99) == false
// isPerfectPower(6561) == true
// isPerfectPower(216) == true
// isPerfectPower(6560) == false
// isPerfectPower(1) == true
// isPerfectPower(2) == true
// isPerfectPower(81) == true
// isPerfectPower(1000000000000000) == false
func isPerfectPower(a: Int) -> Bool {
    var root = Int(cbrt(Double(a)))
    while root * root * root > a {
        root -= 1
    }
    return root * root * root == a
}

// -----------------------------------------------------------------------------
// 14. Write a function that takes an integer a and returns true if it is a perfect
// power. A perfect power is defined as an integer that can be expressed as
// an integer power of another integer.
// Examples:
// is

func iscube(a: Int) -> Bool {
    let x = Int(sqrt(a))
    return x * x * x == a
}
```swift
// Write a function that takes an integer a and returns true 
// if this ingeger is a cube of some integer number.
// Note: you may assume the input is always valid.
// Examples:
// iscube(a: 1) == true
// iscube(a: 2) == false
// iscube(a: -1) == true
// iscube(a: 64) == true
// iscube(a: 0) == true
// iscube(a: 180) == false
func iscube(a: Int) -> Bool {
    let x = Int(sqrt(a))
    return x * x * x == a
}

// 12. Write a function that takes an integer a and returns true ...
// ... if this integer is a perfect cube.
// Note: you may assume the input is always valid.
// Examples:
// iscube(a: 1) == true
// iscube(a: 2) == false
// iscube(a: -1) == true
// iscube(a: 64) == true
// iscube(a: 0) == true
// iscube(a: 180) == false
func iscube(a: Int) -> Bool {
    let x = Int(sqrt(a))
    return x * x * x == a
}

// 13. Write a function that takes an integer a and returns true ...
// ... if this integer is a perfect cube.
// Note: you may assume the input is always valid.
// Examples:
// iscube(a: 1) == true
// iscube(a: 2) == false
// iscube(a: -1) == true
// iscube(a: 64) == true
// iscube(a: 0) == true
// iscube(a: 180) == false
func iscube(a: Int) -> Bool {
    let x = Int(sqrt(a))
    return x * x * x == a
}

// 14. Write a function that takes an integer a and returns true ...
// ... if this integer is a perfect cube.
// Note: you may assume the input is always valid.
// Examples:
// iscube(a: 1) == true
// iscube(a: 2) == false
// iscube(a: -1) == true
// iscube(a: 64) == true
// iscube(a: 0) == true
// iscube(a: 180) == false
func iscube(a: Int) -> Bool {
    let x = Int(sqrt(a))
    return x * x * x == a
}

// 15. Write a function that takes an integer a and returns true ...
// ... if this integer is a perfect cube.
// Note: you may assume the input is always valid.
// Examples:
// iscube(a: 1) == true
// iscube(a: 2) == false
// iscube(a: -1) == true
// iscube(a: 64) == true
// iscube(a: 0) == true
// iscube(a: 180) == false
func iscube(a: Int) -> Bool {
    let x = Int(sqrt(a))
    return x * x * x == a
}

// 16. Write a function that takes an integer a and returns true ...
// ... if this integer is a perfect cube.
// Note: you may assume the input is always valid.
// Examples:
// iscube(a: 1) == true
// iscube(a: 2) == false
// iscube(a: -1) == true
// iscube(a: 64) == true
// iscube(a: 0) == true
// iscube(a: 180) == false
func iscube(a: Int) -> Bool {
    let x = Int(sqrt(a))
    return x * x * x == a
}

// 17. Write a function that takes an integer a and returns true ...
// ... if this integer is a perfect cube.
// Note: you may assume the input is always valid.
// Examples:
// iscube(a: 1) == true
// iscube(a: 2) == false
// iscube(a: -1) == true
// iscube(a: 64) == true
// iscube(a: 0) == true
// iscube(a: 180) == false
func iscube(a: Int) -> Bool {
    let x = Int(sqrt(a))
    return x * x * x == a
}

// 18. Write a function that takes an integer a and returns
let x = Int(sqrt(a)) // no exact matches in call to global function 'sqrt'

func iscube(a: Int) -> Bool {
    let sqrt = Int(sqrt(Double(a)))
    return sqrt * sqrt == a
}

func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

func removeNonAlphabetic(input: String) -> String {
    var result = ""
    for char in input {
        if char.isAlphabetic() {
            result += char
        }
    }
    return result
}

func reverseAlphabetic(input: String) -> String {
    var result = ""
    for char in input {
        if char.isAlphabetic() {
            result = char + result
        }
    }
    return result
}

func reverseAndRemoveNonAlphabetic(input: String) -> String {
    var result = ""
    for char in input {
        if char.isAlphabetic() {
            result = char + result
        }
    }
    return result
}
```swift
// Write a function that takes an integer a and returns true 
// if this ingeger is a cube of some integer number.
// Note: you may assume the input is always valid.
// Examples:
// iscube(a: 1) == true
// iscube(a: 2) == false
// iscube(a: -1) == true
// iscube(a: 64) == true
// iscube(a: 0) == true
// iscube(a: 180) == false
func iscube(a: Int) -> Bool {
    let sqrt = Int(sqrt(Double(a)))
    return sqrt * sqrt == a
}

// 2. Write a function that takes a string and returns a string
// with all vowels removed.
// Examples:
// removeVowels("I have never seen a thin person drinking Diet Coke.") == " hv nvr sn  thn prsn drnkng Dt Ck."
// removeVowels("abracadabra") == "brcrdbrkr"
// removeVowels("pear tree") == " pr t"
// removeVowels("ho ho ho") == "h h h"
// removeVowels("uwu uwu") == ""
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if char != "a" && char != "e" && char != "i" && char != "o" && char != "u" {
            result += char
        }
    }
    return result
}

// 3. Write a function that takes a string and returns a string
// with all non-alphabetic characters removed.
// Examples:
// removeNonAlphabetic("aiuoe") == ""
// removeNonAlphabetic("aiuoea") == "a"
// removeNonAlphabetic("aiuoea!@#$%^&*()") == "a"
// removeNonAlphabetic("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") == "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
// removeNonAlphabetic("") == ""
func removeNonAlphabetic(input: String) -> String {
    var result = ""
    for char in input {
        if char.isAlphabetic() {
            result += char
        }
    }
    return result
}

// 4. Write a function that takes a string and returns a string
// with all alphabetic characters in reverse order.
// Examples:
// reverseAlphabetic("I have never seen a thin person drinking Diet Coke.") == ".kc d ni rt dahP esac siht nrev yrev a hvej I"
// reverseAlphabetic("abracadabra") == "arbadacarba"
// reverseAlphabetic("pear tree") == "eart tree"
// reverseAlphabetic("ho ho ho") == "ho ho ho"
// reverseAlphabetic("") == ""
func reverseAlphabetic(input: String) -> String {
    var result = ""
    for char in input {
        if char.isAlphabetic() {
            result = char + result
        }
    }
    return result
}

// 5. Write a function that takes a string and returns a string
// with all non-alphabetic characters removed and the remaining
// characters reversed.
// Examples:
// reverseAndRemoveNonAlphabetic("I have never seen a thin person drinking Diet Coke.") == ".kc d ni rt dahP esac siht nrev yrev a hvej I"
// reverseAndRemoveNonAlphabetic("abracadabra") == "arbadacarba"
// reverseAndRemoveNonAlphabetic("pear tree") == "eart tree"
// reverseAndRemoveNonAlphabetic("ho ho ho") == "ho ho ho"
// reverseAndRemoveNonAlphabetic("") == ""
func reverseAndRemoveNonAlphabetic(input: String) -> String {
    var result = ""
    for char in input {
        if char.isAlphabetic() {
            result = char + result
        }
    }
    return result
}

// 6. Write a function that takes a string and returns a string
// with all alphabetic characters in reverse order and the remaining
// characters left unchanged.
// Examples:
// reverseAlphabeticAndRemoveNonAlphabetic("I have never seen a thin person drinking Diet Coke.") == ".kc d ni rt dahP esac siht
result += char // cannot convert value of type 'Character' to expected argument type 'String'
if char.isAlphabetic() { // value of type 'Character' has no member 'isAlphabetic'
result += char // cannot convert value of type 'Character' to expected argument type 'String'
if char.isAlphabetic() { // value of type 'Character' has no member 'isAlphabetic'
result = char + result // cannot convert value of type 'Character' to expected argument type 'String'
if char.isAlphabetic() { // value of type 'Character' has no member 'isAlphabetic'
result = char + result // cannot convert value of type 'Character' to expected argument type 'String'

func iscube(a: Int) -> Bool {
    return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a
}
```swift
// Write a function that takes an integer a and returns true 
// if this ingeger is a cube of some integer number.
// Note: you may assume the input is always valid.
// Examples:
// iscube(a: 1) == true
// iscube(a: 2) == false
// iscube(a: -1) == true
// iscube(a: 64) == true
// iscube(a: 0) == true
// iscube(a: 180) == false
func iscube(a: Int) -> Bool {
    return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a
}

// -----------------------------------------------------------------------------
// 10. Write a function that takes an integer a and returns true ...
// ... if it is a perfect cube. Otherwise return false.
// Note: you may assume the input is always valid.
// Examples:
// iscube(a: 1) == true
// iscube(a: 2) == false
// iscube(a: -1) == true
// iscube(a: 64) == true
// iscube(a: 0) == true
// iscube(a: 180) == false
func iscube(a: Int) -> Bool {
    return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a
}

// -----------------------------------------------------------------------------
// 11. Write a function that takes an integer a and returns true ...
// ... if it is a perfect cube. Otherwise return false.
// Note: you may assume the input is always valid.
// Examples:
// iscube(a: 1) == true
// iscube(a: 2) == false
// iscube(a: -1) == true
// iscube(a: 64) == true
// iscube(a: 0) == true
// iscube(a: 180) == false
func iscube(a: Int) -> Bool {
    return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a
}

// -----------------------------------------------------------------------------
// 12. Write a function that takes an integer a and returns true ...
// ... if it is a perfect cube. Otherwise return false.
// Note: you may assume the input is always valid.
// Examples:
// iscube(a: 1) == true
// iscube(a: 2) == false
// iscube(a: -1) == true
// iscube(a: 64) == true
// iscube(a: 0) == true
// iscube(a: 180) == false
func iscube(a: Int) -> Bool {
    return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a
}

// -----------------------------------------------------------------------------
// 13. Write a function that takes an integer a and returns true ...
// ... if it is a perfect cube. Otherwise return false.
// Note: you may assume the input is always valid.
// Examples:
// iscube(a: 1) == true
// iscube(a: 2) == false
// iscube(a: -1) == true
// iscube(a: 64) == true
// iscube(a: 0) == true
// iscube(a: 180) == false
func iscube(a: Int) -> Bool {
    return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a
}

// -----------------------------------------------------------------------------
// 14. Write a function that takes an integer a and returns true ...
// ... if it is a perfect cube. Otherwise return false.
// Note: you may assume the input is always valid.
// Examples:
// iscube(a: 1) == true
// iscube(a: 2) == false
// iscube(a: -1) == true
// iscube(a: 64) == true
// iscube(a: 0) == true
// iscube(a: 180) == false
func iscube(a:
return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a // no exact matches in call to global function 'cbrt'
return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a // no exact matches in call to global function 'cbrt'
return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a // no exact matches in call to global function 'cbrt'

func iscube(a: Int) -> Bool {
    return Int(cbrt(a)) ** 3 == a
}

func countVowel(s: String) -> Int {
    var count = 0
    for c in s {
        switch c {
        case "a", "e", "i", "o", "u":
            count += 1
        default:
            break
        }
    }
    return count
}

func reverse(s: String) -> String {
    var reversed = ""
    for c in s {
        reversed = c + reversed
    }
    return reversed
}

func reverseWords(s: String) -> String {
    var reversed = ""
    var word = ""
    for c in s {
        if c == " " {
            reversed = word + " " + reversed
            word = ""
        } else {
            word = c + word
        }
    }
    reversed = word + " " + reversed
    return reversed
}
```swift
// Write a function that takes an integer a and returns true 
// if this ingeger is a cube of some integer number.
// Note: you may assume the input is always valid.
// Examples:
// iscube(a: 1) == true
// iscube(a: 2) == false
// iscube(a: -1) == true
// iscube(a: 64) == true
// iscube(a: 0) == true
// iscube(a: 180) == false
func iscube(a: Int) -> Bool {
    return Int(cbrt(a)) ** 3 == a
}

// -----------------------------------------------------------------------------
// 2. Write a function that takes a string and returns the number of vowels
//    in the string.
//    Note: you may assume the string will always be valid.
//    a, e, i, o, u are considered vowels (not y).
//    The letters a, o, u, and i are not considered vowels.
// Examples:
// countVowel("ciao") == 2
// countVowel("abracadabra") == 5
// countVowel("abcdefghijklmnopqrstuvwxyz") == 5
func countVowel(s: String) -> Int {
    var count = 0
    for c in s {
        switch c {
        case "a", "e", "i", "o", "u":
            count += 1
        default:
            break
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// 3. Write a function that takes a string and returns a new string with
//    the sentence in reversed order.
//    Note: you may assume the input is always valid.
//    Examples:
//    reverse("Hello world!") == "!dlrow olleH"
//    reverse("Hi There.") == ".eht RehtaH"
func reverse(s: String) -> String {
    var reversed = ""
    for c in s {
        reversed = c + reversed
    }
    return reversed
}

// -----------------------------------------------------------------------------
// 4. Write a function that takes a string and returns a new string with
//    the sentence in reversed order while keeping the word order.
//    Note: you may assume the input is always valid.
//    Examples:
//    reverseWords("Hello world!") == "world! Hello"
//    reverseWords("Hi There.") == "There. Hi"
func reverseWords(s: String) -> String {
    var reversed = ""
    var word = ""
    for c in s {
        if c == " " {
            reversed = word + " " + reversed
            word = ""
        } else {
            word = c + word
        }
    }
    reversed = word + " " + reversed
    return reversed
}

// -----------------------------------------------------------------------------
// 5. Write a function that takes a string and returns a new string with
//    the sentence in reversed order while keeping the word order.
//    Note: you may assume the input is always valid.
//    Examples:
//    reverseWords("Hello world!") == "world! Hello"
//    reverseWords("Hi There.") == "There. Hi"
func reverseWords(s: String) -> String {
    var reversed = ""
    var word = ""
    for c in s {
        if c == " " {
            reversed = word + " " + reversed
            word = ""
        } else {
            word = c + word
        }
    }
    reversed = word + " " + reversed
    return reversed
}

// -----------------------------------------------------------------------------
// 6. Write a function that takes a string and returns a new string with
//    the sentence in reversed order while keeping the word order.
//    Note: you may assume the input is always valid.
//    Examples:
//    reverseWords("Hello world!") == "world! Hello"
//    reverseWords("Hi There.") == "There. Hi"
func reverseWords(s: String) -> String {
    var reversed = ""
    var word = ""
    for c in s {
        if c == " " {
            reversed = word + " " + reversed
            word = "
return Int(cbrt(a)) ** 3 == a // no exact matches in call to global function 'cbrt'
return Int(cbrt(a)) ** 3 == a // no operator '**' is defined; did you mean 'pow(_:_:)'?
reversed = c + reversed // cannot convert value of type 'Character' to expected argument type 'String'
word = c + word // cannot convert value of type 'Character' to expected argument type 'String'

func iscube(a: Int) -> Bool {
    return Int(cbrt(a)) ** 3 == a
}
```swift
// Write a function that takes an integer a and returns true 
// if this ingeger is a cube of some integer number.
// Note: you may assume the input is always valid.
// Examples:
// iscube(a: 1) == true
// iscube(a: 2) == false
// iscube(a: -1) == true
// iscube(a: 64) == true
// iscube(a: 0) == true
// iscube(a: 180) == false
func iscube(a: Int) -> Bool {
    return Int(cbrt(a)) ** 3 == a
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// ---------------
return Int(cbrt(a)) ** 3 == a // no exact matches in call to global function 'cbrt'
return Int(cbrt(a)) ** 3 == a // no operator '**' is defined; did you mean 'pow(_:_:)'?

func iscube(a: Int) -> Bool {
    return Int(cbrt(a)) ** 3 == a
}

func countVowels(s: String) -> Int {
    var count = 0
    for c in s {
        switch c {
        case "a":
        case "e":
        case "i":
        case "o":
        case "u":
            count += 1
        default:
            break
        }
    }
    return count
}
```swift
// Write a function that takes an integer a and returns true 
// if this ingeger is a cube of some integer number.
// Note: you may assume the input is always valid.
// Examples:
// iscube(a: 1) == true
// iscube(a: 2) == false
// iscube(a: -1) == true
// iscube(a: 64) == true
// iscube(a: 0) == true
// iscube(a: 180) == false
func iscube(a: Int) -> Bool {
    return Int(cbrt(a)) ** 3 == a
}

// 2. Write a function that takes a string and returns the number of
// vowels in the string.
// Note: you may assume the string is in lowercase.
// Examples:
// countVowels("apple") == 2
// countVowels("banana") == 3
// countVowels("grapefruit") == 5
// countVowels("kiwi") == 3
// countVowels("orange") == 5
// countVowels("pineapple") == 5
// countVowels("cherry") == 3
func countVowels(s: String) -> Int {
    var count = 0
    for c in s {
        switch c {
        case "a":
        case "e":
        case "i":
        case "o":
        case "u":
            count += 1
        default:
            break
        }
    }
    return count
}

// 3. Write a function that takes a string and returns the number of
// consonants in the string.
// Note: you may assume the string is in lowercase.
// Examples:
// countConsonants("apple") == 4
// countConsonants("banana") == 6
// countConsonants("grapefruit") == 7
// countConsonants("kiwi") == 4
// countConsonants("orange") == 5
// countConsonants("pineapple") == 5
// countConsonants("cherry") == 4
func countConsonants(s: String) -> Int {
    var count = 0
    for c in s {
        switch c {
        case "a":
        case "e":
        case "i":
        case "o":
        case "u":
        case "y":
        case "w":
        case "h":
        case "k":
        case "l":
        case "m":
        case "n":
        case "p":
        case "q":
        case "r":
        case "s":
        case "t":
        case "v":
        case "x":
        case "z":
        case "d":
        case "f":
        case "g":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
        case "j":
return Int(cbrt(a)) ** 3 == a // no operator '**' is defined; did you mean 'pow(_:_:)'?
return Int(cbrt(a)) ** 3 == a // no exact matches in call to global function 'cbrt'
case "a": // 'case' label in a 'switch' must have at least one executable statement
case "e": // 'case' label in a 'switch' must have at least one executable statement
case "i": // 'case' label in a 'switch' must have at least one executable statement
case "o": // 'case' label in a 'switch' must have at least one executable statement

func iscube(a: Int) -> Bool {
    let root = Int(cbrt(Double(a)))
    return root * root * root == a
}
```swift
// Write a function that takes an integer a and returns true 
// if this ingeger is a cube of some integer number.
// Note: you may assume the input is always valid.
// Examples:
// iscube(a: 1) == true
// iscube(a: 2) == false
// iscube(a: -1) == true
// iscube(a: 64) == true
// iscube(a: 0) == true
// iscube(a: 180) == false
func iscube(a: Int) -> Bool {
    let root = Int(cbrt(Double(a)))
    return root * root * root == a
}

// -----------------------------------------------------------------------------
// 14. Write a function that takes an integer a and returns true ...
// ... if this integer is a perfect cube.
// Examples:
// iscube(a: 1) == true
// iscube(a: 2) == false
// iscube(a: -1) == true
// iscube(a: 64) == true
// iscube(a: 0) == true
// iscube(a: 180) == false
func iscube(a: Int) -> Bool {
    let root = Int(cbrt(Double(a)))
    return root * root * root == a
}

// -----------------------------------------------------------------------------
// 15. Write a function that takes an integer a and returns true ...
// ... if this integer is a perfect cube.
// Examples:
// iscube(a: 1) == true
// iscube(a: 2) == false
// iscube(a: -1) == true
// iscube(a: 64) == true
// iscube(a: 0) == true
// iscube(a: 180) == false
func iscube(a: Int) -> Bool {
    let root = Int(cbrt(Double(a)))
    return root * root * root == a
}

// -----------------------------------------------------------------------------
// 16. Write a function that takes an integer a and returns true ...
// ... if this integer is a perfect cube.
// Examples:
// iscube(a: 1) == true
// iscube(a: 2) == false
// iscube(a: -1) == true
// iscube(a: 64) == true
// iscube(a: 0) == true
// iscube(a: 180) == false
func iscube(a: Int) -> Bool {
    let root = Int(cbrt(Double(a)))
    return root * root * root == a
}

// -----------------------------------------------------------------------------
// 17. Write a function that takes an integer a and returns true ...
// ... if this integer is a perfect cube.
// Examples:
// iscube(a: 1) == true
// iscube(a: 2) == false
// iscube(a: -1) == true
// iscube(a: 64) == true
// iscube(a: 0) == true
// iscube(a: 180) == false
func iscube(a: Int) -> Bool {
    let root = Int(cbrt(Double(a)))
    return root * root * root == a
}

// -----------------------------------------------------------------------------
// 18. Write a function that takes an integer a and returns true ...
// ... if this integer is a perfect cube.
// Examples:
// iscube(a: 1) == true
// iscube(a: 2) == false
// iscube(a: -1) == true
// iscube(a: 64) == true
// iscube(a: 0) == true
// iscube(a: 180) == false
func iscube(a: Int) -> Bool {
    let root = Int(cbrt(Double(a)))
    return root * root * root == a
}

// -----------------------------------------------------------------------------
// 19. Write a function that takes an integer a and returns true ...
// ... if this integer is a perfect cube.
// Examples:
// iscube(a: 

func iscube(a: Int) -> Bool {
    return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a
}

func ispower(a: Int) -> Bool {
    return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a
}

func isperfectcube(a: Int) -> Bool {
    return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a
}

func isperfectpower(a: Int) -> Bool {
    return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a
}

func isperfectsquare(a: Int) -> Bool {
    return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a
}

func isperfectfifthpower(a: Int) -> Bool {
    return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a
}
```swift
// Write a function that takes an integer a and returns true 
// if this ingeger is a cube of some integer number.
// Note: you may assume the input is always valid.
// Examples:
// iscube(a: 1) == true
// iscube(a: 2) == false
// iscube(a: -1) == true
// iscube(a: 64) == true
// iscube(a: 0) == true
// iscube(a: 180) == false
func iscube(a: Int) -> Bool {
    return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a
}

// 2. Write a function that takes an integer a and returns true
// if this ingeger is a power of some integer number.
// Note: you may assume the input is always valid.
// Examples:
// ispower(a: 1) == true
// ispower(a: 2) == false
// ispower(a: -1) == true
// ispower(a: 64) == true
// ispower(a: 0) == true
// ispower(a: 180) == false
func ispower(a: Int) -> Bool {
    return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a
}

// 3. Write a function that takes an integer a and returns true
// if this ingeger is a perfect cube.
// Note: you may assume the input is always valid.
// Examples:
// isperfectcube(a: 1) == true
// isperfectcube(a: 2) == false
// isperfectcube(a: -1) == true
// isperfectcube(a: 64) == true
// isperfectcube(a: 0) == true
// isperfectcube(a: 180) == false
func isperfectcube(a: Int) -> Bool {
    return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a
}

// 4. Write a function that takes an integer a and returns true
// if this ingeger is a perfect power.
// Note: you may assume the input is always valid.
// Examples:
// isperfectpower(a: 1) == true
// isperfectpower(a: 2) == false
// isperfectpower(a: -1) == true
// isperfectpower(a: 64) == true
// isperfectpower(a: 0) == true
// isperfectpower(a: 180) == false
func isperfectpower(a: Int) -> Bool {
    return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a
}

// 5. Write a function that takes an integer a and returns true
// if this ingeger is a perfect square.
// Note: you may assume the input is always valid.
// Examples:
// isperfectsquare(a: 1) == true
// isperfectsquare(a: 2) == false
// isperfectsquare(a: -1) == true
// isperfectsquare(a: 64) == true
// isperfectsquare(a: 0) == true
// isperfectsquare(a: 180) == false
func isperfectsquare(a: Int) -> Bool {
    return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a
}

// 6. Write a function that takes an integer a and returns true
// if this ingeger is a perfect fifth power.
// Note: you may assume the input is always valid.
// Examples:
// isperfectfifthpower(a: 1) == true
// isperfectfifthpower(a: 2) == false
// isperfectfifthpower(a: -1) == true
// isperfectfifthpower(a: 64) == true
// isperfectfifthpower(a: 0) == true
// isperfectfifthpower(a: 180) == false
func isperfectfifthpower(a: Int) -> Bool {
    return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a
}

// 7. Write a function that takes an integer a and returns true
// if this ingeger is a perfect fourth power.
// Note: you may assume the input is always valid.
// Examples:
// isperfectfourthpower(a: 1) == true
// isperfectfourthpower(a: 2) == false
// isperfectfourthpower(a: -1) == true
// isperfectfourthpower(a: 64) == true
// isperfectfourthpower(
return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a // no exact matches in call to global function 'cbrt'
return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a // no exact matches in call to global function 'cbrt'
return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a // no exact matches in call to global function 'cbrt'
return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a // no exact matches in call to global function 'cbrt'
return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a // no exact matches in call to global function 'cbrt'
return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a // no exact matches in call to global function 'cbrt'
return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a // no exact matches in call to global function 'cbrt'
return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a // no exact matches in call to global function 'cbrt'
return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a // no exact matches in call to global function 'cbrt'
return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a // no exact matches in call to global function 'cbrt'
return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a // no exact matches in call to global function 'cbrt'
return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a // no exact matches in call to global function 'cbrt'
return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a // no exact matches in call to global function 'cbrt'
return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a // no exact matches in call to global function 'cbrt'
return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a // no exact matches in call to global function 'cbrt'
return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a // no exact matches in call to global function 'cbrt'
return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a // no exact matches in call to global function 'cbrt'
return Int(cbrt(a)) * Int(cbrt(a)) * Int(cbrt(a)) == a // no exact matches in call to global function 'cbrt'

func hexKey(num: String) -> Int {
    let hex = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"]
    var count = 0
    for i in num {
        if hex.contains(i) {
            count += 1
        }
    }
    return count
}
```swift
// You have been tasked to write a function that receives 
// a hexadecimal number as a string and counts the number of hexadecimal 
// digits that are primes (prime number, or a prime, is a natural number 
// greater than 1 that is not a product of two smaller natural numbers).
// Hexadecimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
// Prime numbers are 2, 3, 5, 7, 11, 13, 17,...
// So you have to determine a number of the following digits: 2, 3, 5, 7, 
// B (=decimal 11), D (=decimal 13).
// Note: you may assume the input is always correct or empty string, 
// and symbols A,B,C,D,E,F are always uppercase.
// Examples:
// hexKey(num: "AB") == 1
// hexKey(num: "1077E") == 2
// hexKey(num: "ABED1A33") == 4
// hexKey(num: "123456789ABCDEF0") == 6
// hexKey(num: "2020") == 2
func hexKey(num: String) -> Int {
    let hex = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"]
    var count = 0
    for i in num {
        if hex.contains(i) {
            count += 1
        }
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------
if hex.contains(i) { // cannot convert value of type 'Character' to expected argument type 'String'

func hexKey(num: String) -> Int {
    let hex = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"]
    let count = 0
    for i in num.uppercase {
        if hex.contains(i) {
            count += 1
        }
    }
    return count
}

func sumNumbers(s: String) -> Int {
    var sum = 0
    for i in s {
        if i.isNumber {
            sum += i
        }
    }
    return sum
}
```swift
// You have been tasked to write a function that receives 
// a hexadecimal number as a string and counts the number of hexadecimal 
// digits that are primes (prime number, or a prime, is a natural number 
// greater than 1 that is not a product of two smaller natural numbers).
// Hexadecimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
// Prime numbers are 2, 3, 5, 7, 11, 13, 17,...
// So you have to determine a number of the following digits: 2, 3, 5, 7, 
// B (=decimal 11), D (=decimal 13).
// Note: you may assume the input is always correct or empty string, 
// and symbols A,B,C,D,E,F are always uppercase.
// Examples:
// hexKey(num: "AB") == 1
// hexKey(num: "1077E") == 2
// hexKey(num: "ABED1A33") == 4
// hexKey(num: "123456789ABCDEF0") == 6
// hexKey(num: "2020") == 2
func hexKey(num: String) -> Int {
    let hex = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"]
    let count = 0
    for i in num.uppercase {
        if hex.contains(i) {
            count += 1
        }
    }
    return count
}

// 2.
// Given a string, return the sum of the numbers appearing in the string,
// ignoring all other characters. A number is a series of 1 or more
// continuous digits (0-9).
// So the strings "abc123xyz" and "aa11b33" only return 123 and 33
// respectively.
// Note: ignore all non-numeric characters in the string.
// Example:
// sumNumbers("abc123xyz") == 123
// sumNumbers("aa11b33") == 44
// sumNumbers("7 11") == 18
// sumNumbers("Chocolate") == 0
// sumNumbers("5one") == 5
// sumNumbers("1st42nd") == 42
// sumNumbers("") == 0
// sumNumbers("ab123") == 123
func sumNumbers(s: String) -> Int {
    var sum = 0
    for i in s {
        if i.isNumber {
            sum += i
        }
    }
    return sum
}

// 3.
// Given a string, return the sum of the numbers appearing in the string,
// ignoring all other characters. A number is a series of 1 or more
// continuous digits (0-9).
// So the strings "abc123xyz" and "aa11b33" only return 123 and 33
// respectively.
// Note: ignore all non-numeric characters in the string.
// Example:
// sumNumbers("abc123xyz") == 123
// sumNumbers("aa11b33") == 44
// sumNumbers("7 11") == 18
// sumNumbers("Chocolate") == 0
// sumNumbers("5one") == 5
// sumNumbers("1st42nd") == 42
// sumNumbers("") == 0
// sumNumbers("ab123") == 123
func sumNumbers(s: String) -> Int {
    var sum = 0
    for i in s {
        if i.isNumber {
            sum += i
        }
    }
    return sum
}

// 4.
// Given a string, return the sum of the numbers appearing in the string,
// ignoring all other characters. A number is a series of 1 or more
// continuous digits (0-9).
// So the strings "abc123xyz" and "aa11b33" only return 123 and 33
// respectively.
// Note: ignore all non-numeric characters in the string.
// Example:
// sumNumbers("abc123xyz") == 123
// sumNumbers("aa11b33") == 44
// sumNumbers("7 11") == 18
// sumNumbers("Chocolate") == 0
// sumNumbers("5one") == 5
// sumNumbers("1st42nd") == 42
// sumNumbers("") == 0
// sumNumbers("ab123") == 123
func sumNumbers(s: String) -> Int {
    var sum = 0
    for i in s {
        if i.isNumber {
            sum += i
        }
    }
    return sum
}

// 5.
// Given a string, return the sum of the numbers appearing in the string,
// ignoring all other characters. A number is a series of 1 or more
// continuous digits (0-9).
for i in num.uppercase { // value of type 'String' has no member 'uppercase'
sum += i // cannot convert value of type 'Character' to expected argument type 'Int'

func hexKey(num: String) -> Int {
    var count = 0
    for char in num {
        if char == "2" || char == "3" || char == "5" || char == "7" ||
            char == "B" || char == "D" {
            count += 1
        }
    }
    return count
}
```swift
// You have been tasked to write a function that receives 
// a hexadecimal number as a string and counts the number of hexadecimal 
// digits that are primes (prime number, or a prime, is a natural number 
// greater than 1 that is not a product of two smaller natural numbers).
// Hexadecimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
// Prime numbers are 2, 3, 5, 7, 11, 13, 17,...
// So you have to determine a number of the following digits: 2, 3, 5, 7, 
// B (=decimal 11), D (=decimal 13).
// Note: you may assume the input is always correct or empty string, 
// and symbols A,B,C,D,E,F are always uppercase.
// Examples:
// hexKey(num: "AB") == 1
// hexKey(num: "1077E") == 2
// hexKey(num: "ABED1A33") == 4
// hexKey(num: "123456789ABCDEF0") == 6
// hexKey(num: "2020") == 2
func hexKey(num: String) -> Int {
    var count = 0
    for char in num {
        if char == "2" || char == "3" || char == "5" || char == "7" ||
            char == "B" || char == "D" {
            count += 1
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ---------------------------

func hexKey(num: String) -> Int {
    let hex = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"]
    var count = 0
    for i in num {
        if hex.contains(String(i)) {
            count += 1
        }
    }
    return count
}
```swift
// You have been tasked to write a function that receives 
// a hexadecimal number as a string and counts the number of hexadecimal 
// digits that are primes (prime number, or a prime, is a natural number 
// greater than 1 that is not a product of two smaller natural numbers).
// Hexadecimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
// Prime numbers are 2, 3, 5, 7, 11, 13, 17,...
// So you have to determine a number of the following digits: 2, 3, 5, 7, 
// B (=decimal 11), D (=decimal 13).
// Note: you may assume the input is always correct or empty string, 
// and symbols A,B,C,D,E,F are always uppercase.
// Examples:
// hexKey(num: "AB") == 1
// hexKey(num: "1077E") == 2
// hexKey(num: "ABED1A33") == 4
// hexKey(num: "123456789ABCDEF0") == 6
// hexKey(num: "2020") == 2
func hexKey(num: String) -> Int {
    let hex = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"]
    var count = 0
    for i in num {
        if hex.contains(String(i)) {
            count += 1
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
 // XCTAssertTrue failed

func hexKey(num: String) -> Int {
    var count = 0
    for char in num {
        if char == "2" || char == "3" || char == "5" || char == "7" || char == "B" || char == "D" {
            count += 1
        }
    }
    return count
}
```swift
// You have been tasked to write a function that receives 
// a hexadecimal number as a string and counts the number of hexadecimal 
// digits that are primes (prime number, or a prime, is a natural number 
// greater than 1 that is not a product of two smaller natural numbers).
// Hexadecimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
// Prime numbers are 2, 3, 5, 7, 11, 13, 17,...
// So you have to determine a number of the following digits: 2, 3, 5, 7, 
// B (=decimal 11), D (=decimal 13).
// Note: you may assume the input is always correct or empty string, 
// and symbols A,B,C,D,E,F are always uppercase.
// Examples:
// hexKey(num: "AB") == 1
// hexKey(num: "1077E") == 2
// hexKey(num: "ABED1A33") == 4
// hexKey(num: "123456789ABCDEF0") == 6
// hexKey(num: "2020") == 2
func hexKey(num: String) -> Int {
    var count = 0
    for char in num {
        if char == "2" || char == "3" || char == "5" || char == "7" || char == "B" || char == "D" {
            count += 1
        }
    }
    return count
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------

// ---------------------------------------------------------------------------

func hexKey(num: String) -> Int {
    var count = 0
    for i in num {
        if isPrime(Int(i)) {
            count += 1
        }
    }
    return count
}

func isPrime(num: Int) -> Bool {
    if num == 2 {
        return true
    }
    if num % 2 == 0 {
        return false
    }
    for i in 3..<num {
        if num % i == 0 {
            return false
        }
    }
    return true
}
```swift
// You have been tasked to write a function that receives 
// a hexadecimal number as a string and counts the number of hexadecimal 
// digits that are primes (prime number, or a prime, is a natural number 
// greater than 1 that is not a product of two smaller natural numbers).
// Hexadecimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
// Prime numbers are 2, 3, 5, 7, 11, 13, 17,...
// So you have to determine a number of the following digits: 2, 3, 5, 7, 
// B (=decimal 11), D (=decimal 13).
// Note: you may assume the input is always correct or empty string, 
// and symbols A,B,C,D,E,F are always uppercase.
// Examples:
// hexKey(num: "AB") == 1
// hexKey(num: "1077E") == 2
// hexKey(num: "ABED1A33") == 4
// hexKey(num: "123456789ABCDEF0") == 6
// hexKey(num: "2020") == 2
func hexKey(num: String) -> Int {
    var count = 0
    for i in num {
        if isPrime(Int(i)) {
            count += 1
        }
    }
    return count
}

func isPrime(num: Int) -> Bool {
    if num == 2 {
        return true
    }
    if num % 2 == 0 {
        return false
    }
    for i in 3..<num {
        if num % i == 0 {
            return false
        }
    }
    return true
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// ------------------------------------------------------------
if isPrime(Int(i)) { // missing argument label 'num:' in call
if isPrime(Int(i)) { // no exact matches in call to initializer

func hexKey(num: String) -> Int {
    var count = 0
    for char in num {
        if char == "2" || char == "3" || char == "5" || char == "7" ||
            char == "B" || char == "D" {
            count += 1
        }
    }
    return count
}
```swift
// You have been tasked to write a function that receives 
// a hexadecimal number as a string and counts the number of hexadecimal 
// digits that are primes (prime number, or a prime, is a natural number 
// greater than 1 that is not a product of two smaller natural numbers).
// Hexadecimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
// Prime numbers are 2, 3, 5, 7, 11, 13, 17,...
// So you have to determine a number of the following digits: 2, 3, 5, 7, 
// B (=decimal 11), D (=decimal 13).
// Note: you may assume the input is always correct or empty string, 
// and symbols A,B,C,D,E,F are always uppercase.
// Examples:
// hexKey(num: "AB") == 1
// hexKey(num: "1077E") == 2
// hexKey(num: "ABED1A33") == 4
// hexKey(num: "123456789ABCDEF0") == 6
// hexKey(num: "2020") == 2
func hexKey(num: String) -> Int {
    var count = 0
    for char in num {
        if char == "2" || char == "3" || char == "5" || char == "7" ||
            char == "B" || char == "D" {
            count += 1
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ---------------------------

func hexKey(num: String) -> Int {
    var count = 0
    var hex = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"]
    for i in num {
        if hex.contains(String(i)) {
            count += 1
        }
    }
    return count
}

func vowels(str: String) -> Int {
    var count = 0
    var vowels = ["a", "e", "i", "o", "u"]
    for i in str {
        if vowels.contains(String(i)) {
            count += 1
        }
    }
    return count
}
```swift
// You have been tasked to write a function that receives 
// a hexadecimal number as a string and counts the number of hexadecimal 
// digits that are primes (prime number, or a prime, is a natural number 
// greater than 1 that is not a product of two smaller natural numbers).
// Hexadecimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
// Prime numbers are 2, 3, 5, 7, 11, 13, 17,...
// So you have to determine a number of the following digits: 2, 3, 5, 7, 
// B (=decimal 11), D (=decimal 13).
// Note: you may assume the input is always correct or empty string, 
// and symbols A,B,C,D,E,F are always uppercase.
// Examples:
// hexKey(num: "AB") == 1
// hexKey(num: "1077E") == 2
// hexKey(num: "ABED1A33") == 4
// hexKey(num: "123456789ABCDEF0") == 6
// hexKey(num: "2020") == 2
func hexKey(num: String) -> Int {
    var count = 0
    var hex = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"]
    for i in num {
        if hex.contains(String(i)) {
            count += 1
        }
    }
    return count
}

// 2.
// Write a function that receives a string and returns the number of vowels
// (a, e, i, o, u) in the string.
// Note: you may assume the input is always correct or empty string.
// Examples:
// vowels("apple") == 2
// vowels("banana") == 3
// vowels("") == 0
// vowels("xyz") == 0
func vowels(str: String) -> Int {
    var count = 0
    var vowels = ["a", "e", "i", "o", "u"]
    for i in str {
        if vowels.contains(String(i)) {
            count += 1
        }
    }
    return count
}

// 3.
// Write a function that receives a string and returns the number of words
// in the string.
// Note: you may assume the input is always correct or empty string.
// Examples:
// words("Hello world") == 2
// words("") == 0
// words("xyz") == 0
// words("Hello world!") == 2
// words("Hello world!!!") == 2
// words("Hello world!!!!!") == 2
// words("Hello world!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
var hex = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"] // variable 'hex' was never mutated; consider changing to 'let' constant
var vowels = ["a", "e", "i", "o", "u"] // variable 'vowels' was never mutated; consider changing to 'let' constant
 // XCTAssertTrue failed

func hexKey(num: String) -> Int {
    var count = 0
    for char in num {
        if char == "2" || char == "3" || char == "5" || char == "7" ||
            char == "B" || char == "D" {
            count += 1
        }
    }
    return count
}
```swift
// You have been tasked to write a function that receives 
// a hexadecimal number as a string and counts the number of hexadecimal 
// digits that are primes (prime number, or a prime, is a natural number 
// greater than 1 that is not a product of two smaller natural numbers).
// Hexadecimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
// Prime numbers are 2, 3, 5, 7, 11, 13, 17,...
// So you have to determine a number of the following digits: 2, 3, 5, 7, 
// B (=decimal 11), D (=decimal 13).
// Note: you may assume the input is always correct or empty string, 
// and symbols A,B,C,D,E,F are always uppercase.
// Examples:
// hexKey(num: "AB") == 1
// hexKey(num: "1077E") == 2
// hexKey(num: "ABED1A33") == 4
// hexKey(num: "123456789ABCDEF0") == 6
// hexKey(num: "2020") == 2
func hexKey(num: String) -> Int {
    var count = 0
    for char in num {
        if char == "2" || char == "3" || char == "5" || char == "7" ||
            char == "B" || char == "D" {
            count += 1
        }
    }
    return count
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// ---------------------------------------------------

func hexKey(num: String) -> Int {
    var count = 0
    for char in num {
        if char == "2" || char == "3" || char == "5" || char == "7" ||
            char == "B" || char == "D" {
            count += 1
        }
    }
    return count
}
```swift
// You have been tasked to write a function that receives 
// a hexadecimal number as a string and counts the number of hexadecimal 
// digits that are primes (prime number, or a prime, is a natural number 
// greater than 1 that is not a product of two smaller natural numbers).
// Hexadecimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
// Prime numbers are 2, 3, 5, 7, 11, 13, 17,...
// So you have to determine a number of the following digits: 2, 3, 5, 7, 
// B (=decimal 11), D (=decimal 13).
// Note: you may assume the input is always correct or empty string, 
// and symbols A,B,C,D,E,F are always uppercase.
// Examples:
// hexKey(num: "AB") == 1
// hexKey(num: "1077E") == 2
// hexKey(num: "ABED1A33") == 4
// hexKey(num: "123456789ABCDEF0") == 6
// hexKey(num: "2020") == 2
func hexKey(num: String) -> Int {
    var count = 0
    for char in num {
        if char == "2" || char == "3" || char == "5" || char == "7" ||
            char == "B" || char == "D" {
            count += 1
        }
    }
    return count
}

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------

// ---------------------------------------------------

func decimalToBinary(decimal: Int) -> String {
    var binary = "db"
    while decimal > 0 {
        binary += String(decimal % 2)
        decimal /= 2
    }
    return binary.reversed().join()
}
```swift
// You will be given a number in decimal form and your task is to convert it to
// binary format. The function should return a string, with each character representing a binary
// number. Each character in the string will be '0' or '1'.
// There will be an extra couple of characters 'db' at the beginning and at the end of the string.
// The extra characters are there to help with the format.
// Examples:
// decimalToBinary(decimal: 15) == "db1111db"
// decimalToBinary(decimal: 32) == "db100000db"
func decimalToBinary(decimal: Int) -> String {
    var binary = "db"
    while decimal > 0 {
        binary += String(decimal % 2)
        decimal /= 2
    }
    return binary.reversed().join()
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
decimal /= 2 // left side of mutating operator isn't mutable: 'decimal' is a 'let' constant
return binary.reversed().join() // reference to member 'join' cannot be resolved without a contextual type

func decimalToBinary(decimal: Int) -> String {
    var binary = "db"
    while decimal > 0 {
        if decimal % 2 == 0 {
            binary += "0"
        } else {
            binary += "1"
        }
        decimal /= 2
    }
    return binary
}
```swift
// You will be given a number in decimal form and your task is to convert it to
// binary format. The function should return a string, with each character representing a binary
// number. Each character in the string will be '0' or '1'.
// There will be an extra couple of characters 'db' at the beginning and at the end of the string.
// The extra characters are there to help with the format.
// Examples:
// decimalToBinary(decimal: 15) == "db1111db"
// decimalToBinary(decimal: 32) == "db100000db"
func decimalToBinary(decimal: Int) -> String {
    var binary = "db"
    while decimal > 0 {
        if decimal % 2 == 0 {
            binary += "0"
        } else {
            binary += "1"
        }
        decimal /= 2
    }
    return binary
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
decimal /= 2 // left side of mutating operator isn't mutable: 'decimal' is a 'let' constant

func decimalToBinary(decimal: Int) -> String {
    var binary = "db"
    while decimal > 0 {
        binary += String(decimal % 2)
        decimal /= 2
    }
    return binary.reversed().join()
}
```swift
// You will be given a number in decimal form and your task is to convert it to
// binary format. The function should return a string, with each character representing a binary
// number. Each character in the string will be '0' or '1'.
// There will be an extra couple of characters 'db' at the beginning and at the end of the string.
// The extra characters are there to help with the format.
// Examples:
// decimalToBinary(decimal: 15) == "db1111db"
// decimalToBinary(decimal: 32) == "db100000db"
func decimalToBinary(decimal: Int) -> String {
    var binary = "db"
    while decimal > 0 {
        binary += String(decimal % 2)
        decimal /= 2
    }
    return binary.reversed().join()
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
decimal /= 2 // left side of mutating operator isn't mutable: 'decimal' is a 'let' constant
return binary.reversed().join() // reference to member 'join' cannot be resolved without a contextual type

func decimalToBinary(decimal: Int) -> String {
    let binary = String(decimal, radix: 2)
    return "db" + binary + "db"
}
```swift
// You will be given a number in decimal form and your task is to convert it to
// binary format. The function should return a string, with each character representing a binary
// number. Each character in the string will be '0' or '1'.
// There will be an extra couple of characters 'db' at the beginning and at the end of the string.
// The extra characters are there to help with the format.
// Examples:
// decimalToBinary(decimal: 15) == "db1111db"
// decimalToBinary(decimal: 32) == "db100000db"
func decimalToBinary(decimal: Int) -> String {
    let binary = String(decimal, radix: 2)
    return "db" + binary + "db"
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

func decimalToBinary(decimal: Int) -> String {
    var binary = "db"
    while decimal > 0 {
        binary += String(decimal % 2)
        decimal /= 2
    }
    return binary.reversed().join()
}
```swift
// You will be given a number in decimal form and your task is to convert it to
// binary format. The function should return a string, with each character representing a binary
// number. Each character in the string will be '0' or '1'.
// There will be an extra couple of characters 'db' at the beginning and at the end of the string.
// The extra characters are there to help with the format.
// Examples:
// decimalToBinary(decimal: 15) == "db1111db"
// decimalToBinary(decimal: 32) == "db100000db"
func decimalToBinary(decimal: Int) -> String {
    var binary = "db"
    while decimal > 0 {
        binary += String(decimal % 2)
        decimal /= 2
    }
    return binary.reversed().join()
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
decimal /= 2 // left side of mutating operator isn't mutable: 'decimal' is a 'let' constant
return binary.reversed().join() // reference to member 'join' cannot be resolved without a contextual type

func decimalToBinary(decimal: Int) -> String {
    var binary = ""
    while decimal > 0 {
        binary = String(decimal % 2) + binary
        decimal /= 2
    }
    return "db" + binary + "db"
}
```swift
// You will be given a number in decimal form and your task is to convert it to
// binary format. The function should return a string, with each character representing a binary
// number. Each character in the string will be '0' or '1'.
// There will be an extra couple of characters 'db' at the beginning and at the end of the string.
// The extra characters are there to help with the format.
// Examples:
// decimalToBinary(decimal: 15) == "db1111db"
// decimalToBinary(decimal: 32) == "db100000db"
func decimalToBinary(decimal: Int) -> String {
    var binary = ""
    while decimal > 0 {
        binary = String(decimal % 2) + binary
        decimal /= 2
    }
    return "db" + binary + "db"
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
decimal /= 2 // left side of mutating operator isn't mutable: 'decimal' is a 'let' constant

func decimalToBinary(decimal: Int) -> String {
    var binary = "db"
    while decimal > 0 {
        binary += String(decimal % 2)
        decimal /= 2
    }
    return binary.reversed().join()
}
```swift
// You will be given a number in decimal form and your task is to convert it to
// binary format. The function should return a string, with each character representing a binary
// number. Each character in the string will be '0' or '1'.
// There will be an extra couple of characters 'db' at the beginning and at the end of the string.
// The extra characters are there to help with the format.
// Examples:
// decimalToBinary(decimal: 15) == "db1111db"
// decimalToBinary(decimal: 32) == "db100000db"
func decimalToBinary(decimal: Int) -> String {
    var binary = "db"
    while decimal > 0 {
        binary += String(decimal % 2)
        decimal /= 2
    }
    return binary.reversed().join()
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
decimal /= 2 // left side of mutating operator isn't mutable: 'decimal' is a 'let' constant
return binary.reversed().join() // reference to member 'join' cannot be resolved without a contextual type

func decimalToBinary(decimal: Int) -> String {
    var binary = ""
    while decimal > 0 {
        binary = String(decimal % 2) + binary
        decimal /= 2
    }
    return "db" + binary + "db"
}
```swift
// You will be given a number in decimal form and your task is to convert it to
// binary format. The function should return a string, with each character representing a binary
// number. Each character in the string will be '0' or '1'.
// There will be an extra couple of characters 'db' at the beginning and at the end of the string.
// The extra characters are there to help with the format.
// Examples:
// decimalToBinary(decimal: 15) == "db1111db"
// decimalToBinary(decimal: 32) == "db100000db"
func decimalToBinary(decimal: Int) -> String {
    var binary = ""
    while decimal > 0 {
        binary = String(decimal % 2) + binary
        decimal /= 2
    }
    return "db" + binary + "db"
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
decimal /= 2 // left side of mutating operator isn't mutable: 'decimal' is a 'let' constant

func decimalToBinary(decimal: Int) -> String {
    var binary = "db"
    while decimal > 0 {
        if decimal % 2 == 0 {
            binary += "0"
        } else {
            binary += "1"
        }
        decimal /= 2
    }
    return binary.reversed().join()
}
```swift
// You will be given a number in decimal form and your task is to convert it to
// binary format. The function should return a string, with each character representing a binary
// number. Each character in the string will be '0' or '1'.
// There will be an extra couple of characters 'db' at the beginning and at the end of the string.
// The extra characters are there to help with the format.
// Examples:
// decimalToBinary(decimal: 15) == "db1111db"
// decimalToBinary(decimal: 32) == "db100000db"
func decimalToBinary(decimal: Int) -> String {
    var binary = "db"
    while decimal > 0 {
        if decimal % 2 == 0 {
            binary += "0"
        } else {
            binary += "1"
        }
        decimal /= 2
    }
    return binary.reversed().join()
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
decimal /= 2 // left side of mutating operator isn't mutable: 'decimal' is a 'let' constant
return binary.reversed().join() // reference to member 'join' cannot be resolved without a contextual type

func decimalToBinary(decimal: Int) -> String {
    var binary = ""
    while decimal > 0 {
        binary = String(decimal % 2) + binary
        decimal /= 2
    }
    return "db" + binary + "db"
}
```swift
// You will be given a number in decimal form and your task is to convert it to
// binary format. The function should return a string, with each character representing a binary
// number. Each character in the string will be '0' or '1'.
// There will be an extra couple of characters 'db' at the beginning and at the end of the string.
// The extra characters are there to help with the format.
// Examples:
// decimalToBinary(decimal: 15) == "db1111db"
// decimalToBinary(decimal: 32) == "db100000db"
func decimalToBinary(decimal: Int) -> String {
    var binary = ""
    while decimal > 0 {
        binary = String(decimal % 2) + binary
        decimal /= 2
    }
    return "db" + binary + "db"
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
decimal /= 2 // left side of mutating operator isn't mutable: 'decimal' is a 'let' constant

func isHappy(s: String) -> Bool {
    if s.length < 3 {
        return false
    }
    var count = 0
    for i in 0..<s.length-2 {
        if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] {
            count += 1
        }
    }
    return count == 0
}
```swift
// You are given a string s.
// Your task is to check if the string is hapswift or not.
// A string is hapswift if its length is at least 3 and every 3 consecutive letters are distinct
// For example:
// isHappy(s: "a") == false
// isHappy(s: "aa") == false
// isHappy(s: "abcd") == true
// isHappy(s: "aabb") == false
// isHappy(s: "adb") == true
// isHappy(s: "xyy") == false
func isHappy(s: String) -> Bool {
    if s.length < 3 {
        return false
    }
    var count = 0
    for i in 0..<s.length-2 {
        if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] {
            count += 1
        }
    }
    return count == 0
}

// ----------------------------------------------------------------------------------------------------------------------
// Task 2:
// Write a function that takes a string and returns a string with the letters in reverse order.
// For example:
// reverse(s: "hello") == "olleh"
// reverse(s: "") == ""
// reverse(s: "h") == "h"
// reverse(s: "a") == "a"
// reverse(s: "a b c") == "c b a"
// reverse(s: "a-b-c") == "c-b-a"
// reverse(s: "a-b-c-d") == "d-c-b-a"
// reverse(s: "a-b-c-d-e") == "e-d-c-b-a"
// reverse(s: "a-b-c-d-e-f") == "f-e-d-c-b-a"
// reverse(s: "a-b-c-d-e-f-g") == "g-f-e-d-c-b-a"
// reverse(s: "a-b-c-d-e-f-g-h") == "h-g-f-e-d-c-b-a"
// reverse(s: "a-b-c-d-e-f-g-h-i") == "i-h-g-f-e-d-c-b-a"
// reverse(s: "a-b-c-d-e-f-g-h-i-j") == "j-i-h-g-f-e-d-c-b-a"
// reverse(s: "a-b-c-d-e-f-g-h-i-j-k") == "k-j-i-h-g-f-e-d-c-b-a"
// reverse(s: "a-b-c-d-e-f-g-h-i-j-k-l") == "l-k-j-i-h-g-f-e-d-c-b-a"
// reverse(s: "a-b-c-d-e-f-g-h-i-j-k-l-m") == "m-l-k-j-i-h-g-f-e-d-c-b-a"
// reverse(s: "a-b-c-d-e-f-g-h-i-j-k-l-m-n") == "n-m-l-k-j-i-h-g-f-e-d-c-b-a"
// reverse(s: "a-b-c-d-e-f-g-h-i-j-k-l-m-n-o") == "o-n-m-l-k-j-i-h-g-f-e-d-c-b-a"
// reverse(s: "a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p") == "p-o-n-m-l-k-j-i-h-g-f-e-d-c-b-a"
// reverse(s: "a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q") == "q-p-o-n-m-l-k-j-i-h-g-f-e-d-c-b-a"
// reverse(s: "a-b-c-d-e-f-g-h-
if s.length < 3 { // value of type 'String' has no member 'length'
for i in 0..<s.length-2 { // value of type 'String' has no member 'length'

func isHappy(s: String) -> Bool {
    var count = 0
    var i = 0
    while i < s.count {
        if s[i] == s[i+1] || s[i] == s[i+2] {
            count += 1
        }
        i += 1
    }
    return count == 0
}
```swift
// You are given a string s.
// Your task is to check if the string is hapswift or not.
// A string is hapswift if its length is at least 3 and every 3 consecutive letters are distinct
// For example:
// isHappy(s: "a") == false
// isHappy(s: "aa") == false
// isHappy(s: "abcd") == true
// isHappy(s: "aabb") == false
// isHappy(s: "adb") == true
// isHappy(s: "xyy") == false
func isHappy(s: String) -> Bool {
    var count = 0
    var i = 0
    while i < s.count {
        if s[i] == s[i+1] || s[i] == s[i+2] {
            count += 1
        }
        i += 1
    }
    return count == 0
}

// Task
// Given a string, s, return the number of times that the string contains a substring that is a palindrome.
// A palindrome is a string that is the same forwards and backwards.
// For example:
// palindromeCount(s: "abba") == 2
// palindromeCount(s: "abbaa") == 3
// palindromeCount(s: "abbaabba") == 4
// palindromeCount(s: "abbaabbaa") == 5
// palindromeCount(s: "abbaabbaabba") == 6
// palindromeCount(s: "abbaabbaabbaa") == 7
// palindromeCount(s: "abbaabbaabbaabba") == 8
// palindromeCount(s: "abbaabbaabbaabbaa") == 9
// palindromeCount(s: "abbaabbaabbaabbaabba") == 10
// palindromeCount(s: "abbaabbaabbaabbaabbaa") == 11
// palindromeCount(s: "abbaabbaabbaabbaabbaabba") == 12
// palindromeCount(s: "abbaabbaabbaabbaabbaabbaa") == 13
// palindromeCount(s: "abbaabbaabbaabbaabbaabbaabba") == 14
// palindromeCount(s: "abbaabbaabbaabbaabbaabbaabbaa") == 15
// palindromeCount(s: "abbaabbaabbaabbaabbaabbaabbaabba") == 16
// palindromeCount(s: "abbaabbaabbaabbaabbaabbaabbaabbaa") == 17
// palindromeCount(s: "abbaabbaabbaabbaabbaabbaabbaabbaabba") == 18
// palindromeCount(s: "abbaabbaabbaabbaabbaabbaabbaabbaabbaa") == 19
// palindromeCount(s: "abbaabbaabbaabbaabbaabbaabbaabbaabbaabba") == 20
// palindromeCount(s: "abbaabbaabbaabbaabbaabbaabbaabbaabbaabbaa") == 21
// palindromeCount(s: "abbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabba") == 22
// palindromeCount(s: "abbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaa") == 23
// palindromeCount(s: "abbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabba") == 24
// palindromeCount(s: "abbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaa") == 25
// palindromeCount(s: "abbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabba") == 26
// palindromeCount(s: "abbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaa") == 27
// palindromeCount(s: "abbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabba") == 28
// palindromeCount(s: "abbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaa") == 29
// palindromeCount(s: "abbaabbaabbaabbaabba
if s[i] == s[i+1] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i+1] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i+1] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i+1] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.

func isHappy(s: String) -> Bool {
    if s.count < 3 {
        return false
    }
    var seen = Set<String>()
    while s.count > 0 {
        if seen.contains(s) {
            return false
        }
        seen.insert(s)
        var sum = 0
        for c in s {
            sum += c.asciiRepresentation!.first!.numericValue!
        }
        s = String(characters: Character(UnicodeScalar(sum)), count: 1)
    }
    return true
}
```swift
// You are given a string s.
// Your task is to check if the string is hapswift or not.
// A string is hapswift if its length is at least 3 and every 3 consecutive letters are distinct
// For example:
// isHappy(s: "a") == false
// isHappy(s: "aa") == false
// isHappy(s: "abcd") == true
// isHappy(s: "aabb") == false
// isHappy(s: "adb") == true
// isHappy(s: "xyy") == false
func isHappy(s: String) -> Bool {
    if s.count < 3 {
        return false
    }
    var seen = Set<String>()
    while s.count > 0 {
        if seen.contains(s) {
            return false
        }
        seen.insert(s)
        var sum = 0
        for c in s {
            sum += c.asciiRepresentation!.first!.numericValue!
        }
        s = String(characters: Character(UnicodeScalar(sum)), count: 1)
    }
    return true
}

// -----------------------------------------------------------------------------
// 10. Write a function that takes a string and returns the number of vowels in the string.
//     The vowel letters are a, e, i, o, u.
//     For example:
//     countVowels("Hello") == 2
//     countVowels("apple") == 2
//     countVowels("banana") == 3
//     countVowels("") == 0
//     countVowels("xyz") == 0
//     countVowels("aeiou") == 5
//     countVowels("AEIOU") == 5
//     countVowels("AaEeIiOoUu") == 10
//     countVowels("AaEeIiOoUu1234567890") == 10
//     countVowels("AaEeIiOoUu1234567890aeiouAEIOU") == 15
//     countVowels("AaEeIiOoUu1234567890aeiouAEIOUaAeEiIoOuU") == 20
//     countVowels("AaEeIiOoUu1234567890aeiouAEIOUaAeEiIoOuUaAeEiIoOuU") == 30
//     countVowels("AaEeIiOoUu1234567890aeiouAEIOUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuU") == 40
//     countVowels("AaEeIiOoUu1234567890aeiouAEIOUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUaAeEiIoOuUa
sum += c.asciiRepresentation!.first!.numericValue! // value of type 'Character' has no member 'asciiRepresentation'
s = String(characters: Character(UnicodeScalar(sum)), count: 1) // value of optional type 'UnicodeScalar?' (aka 'Optional<Unicode.Scalar>') must be unwrapped to a value of type 'UnicodeScalar' (aka 'Unicode.Scalar')
s = String(characters: Character(UnicodeScalar(sum)), count: 1) // incorrect argument label in call (have 'characters:count:', expected 'repeating:count:')
s = String(characters: Character(UnicodeScalar(sum)), count: 1) // cannot assign to value: 's' is a 'let' constant

func isHappy(s: String) -> Bool {
    if s.count < 3 {
        return false
    }
    for i in 0..<s.count-2 {
        if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] {
            return false
        }
    }
    return true
}
```swift
// You are given a string s.
// Your task is to check if the string is hapswift or not.
// A string is hapswift if its length is at least 3 and every 3 consecutive letters are distinct
// For example:
// isHappy(s: "a") == false
// isHappy(s: "aa") == false
// isHappy(s: "abcd") == true
// isHappy(s: "aabb") == false
// isHappy(s: "adb") == true
// isHappy(s: "xyy") == false
func isHappy(s: String) -> Bool {
    if s.count < 3 {
        return false
    }
    for i in 0..<s.count-2 {
        if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] {
            return false
        }
    }
    return true
}

// 2. Write a function that takes a string as input and returns the number of vowels in the string.
// For example:
// countVowels(s: "Hello") == 2
// countVowels(s: "apple") == 2
// countVowels(s: "banana") == 3
// countVowels(s: "") == 0
// countVowels(s: "a") == 1
// countVowels(s: "A") == 1
// countVowels(s: "Aa") == 1
// countVowels(s: "AaBb") == 2
// countVowels(s: "AaBbCc") == 3
// countVowels(s: "AaBbCcDd") == 4
// countVowels(s: "AaBbCcDdEe") == 5
// countVowels(s: "AaBbCcDdEeFf") == 6
// countVowels(s: "AaBbCcDdEeFfGg") == 7
// countVowels(s: "AaBbCcDdEeFfGgHh") == 8
// countVowels(s: "AaBbCcDdEeFfGgHhIi") == 9
// countVowels(s: "AaBbCcDdEeFfGgHhIiJj") == 10
// countVowels(s: "AaBbCcDdEeFfGgHhIiJjKk") == 11
// countVowels(s: "AaBbCcDdEeFfGgHhIiJjKkLl") == 12
// countVowels(s: "AaBbCcDdEeFfGgHhIiJjKkLlMm") == 13
// countVowels(s: "AaBbCcDdEeFfGgHhIiJjKkLlMmNn") == 14
// countVowels(s: "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOo") == 15
// countVowels(s: "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPp") == 16
// countVowels(s: "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQq") == 17
// countVowels(s: "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRr") == 18
// countVowels(s: "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSs") == 19
// countVowels(s: "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTt") == 20
// countVowels(s: "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtTu") == 21
// countVowels(s: "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqR
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.

func isHappy(s: String) -> Bool {
    if s.count < 3 {
        return false
    }
    for i in 0..<s.count - 2 {
        if s[i] == s[i + 1] || s[i] == s[i + 2] || s[i + 1] == s[i + 2] {
            return false
        }
    }
    return true
}

func isPalindrome(s: String) -> Bool {
    if s.count == 1 {
        return true
    }
    for i in 0..<s.count / 2 {
        if s[i] != s[s.count - i - 1] {
            return false
        }
    }
    return true
}
```swift
// You are given a string s.
// Your task is to check if the string is hapswift or not.
// A string is hapswift if its length is at least 3 and every 3 consecutive letters are distinct
// For example:
// isHappy(s: "a") == false
// isHappy(s: "aa") == false
// isHappy(s: "abcd") == true
// isHappy(s: "aabb") == false
// isHappy(s: "adb") == true
// isHappy(s: "xyy") == false
func isHappy(s: String) -> Bool {
    if s.count < 3 {
        return false
    }
    for i in 0..<s.count - 2 {
        if s[i] == s[i + 1] || s[i] == s[i + 2] || s[i + 1] == s[i + 2] {
            return false
        }
    }
    return true
}

// Task 2
// You are given a string s.
// Your task is to check if the string is a palindrome.
// A string is a palindrome if it reads the same backward as forward.
// For example:
// isPalindrome(s: "a") == true
// isPalindrome(s: "ab") == false
// isPalindrome(s: "aba") == true
// isPalindrome(s: "abba") == true
// isPalindrome(s: "abbc") == false
// isPalindrome(s: "abcc") == false
// isPalindrome(s: "abcba") == true
// isPalindrome(s: "abcdba") == true
// isPalindrome(s: "abcdbac") == false
func isPalindrome(s: String) -> Bool {
    if s.count == 1 {
        return true
    }
    for i in 0..<s.count / 2 {
        if s[i] != s[s.count - i - 1] {
            return false
        }
    }
    return true
}

// Task 3
// You are given a string s.
// Your task is to check if the string is a pangram.
// A pangram is a sentence that contains every letter in the English alphabet at least once.
// For example:
// isPangram(s: "a") == false
// isPangram(s: "ab") == false
// isPangram(s: "abc") == false
// isPangram(s: "abcdefghijklmnopqrstuvwxyz") == true
// isPangram(s: "The quick brown fox jumps over the lazy dog") == true
// isPangram(s: "The quick brown fox jumps over the lazy dog.") == true
// isPangram(s: "The quick brown fox jumps over the lazy dog!") == false
// isPangram(s: "The quick brown fox jumps over the lazy dog,") == false
// isPangram(s: "The quick brown fox jumps over the lazy dog. ") == false
// isPangram(s: "The quick brown fox jumps over the lazy dog.  ") == false
// isPangram(s: "The quick brown fox jumps over the lazy dog.  .") == false
// isPangram(s: "The quick brown fox jumps over the lazy dog.  . ") == false
// isPangram(s: "The quick brown fox jumps over the lazy dog.  .  ") == false
// isPangram(s: "The quick brown fox jumps over the lazy dog.  .  .") == false
// isPangram(s: "The quick brown fox jumps over the lazy dog.  .  . ") == false
// isPangram(s: "The quick brown fox jumps over the lazy dog.  .  .  ") == false
// isPangram(s: "The quick brown fox jumps over the lazy dog.  .  .  .") == false
// isPangram(s: "The quick brown fox jumps over the lazy dog.  .  .  . ") == false
// isPangram(s: "The quick brown fox jumps over the lazy dog.  .  .  .  ") == false
// isPangram(s: "The quick brown fox jumps over the lazy dog.  .  .  .  .") == false
// isPangram(s: "The quick brown fox jumps over the lazy dog.  .  .  .  . ") == false
// isPangram(s: "The quick brown fox jumps over the lazy dog.  .  .  .  .  ") == false
// isPangram(s: "The quick brown fox jumps over the lazy dog.  
if s[i] == s[i + 1] || s[i] == s[i + 2] || s[i + 1] == s[i + 2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i + 1] || s[i] == s[i + 2] || s[i + 1] == s[i + 2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i + 1] || s[i] == s[i + 2] || s[i + 1] == s[i + 2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i + 1] || s[i] == s[i + 2] || s[i + 1] == s[i + 2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i + 1] || s[i] == s[i + 2] || s[i + 1] == s[i + 2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i + 1] || s[i] == s[i + 2] || s[i + 1] == s[i + 2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] != s[s.count - i - 1] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] != s[s.count - i - 1] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.

func isHappy(s: String) -> Bool {
    if s.count < 3 {
        return false
    }
    for i in 0..<s.count-2 {
        if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] {
            return false
        }
    }
    return true
}
```swift
// You are given a string s.
// Your task is to check if the string is hapswift or not.
// A string is hapswift if its length is at least 3 and every 3 consecutive letters are distinct
// For example:
// isHappy(s: "a") == false
// isHappy(s: "aa") == false
// isHappy(s: "abcd") == true
// isHappy(s: "aabb") == false
// isHappy(s: "adb") == true
// isHappy(s: "xyy") == false
func isHappy(s: String) -> Bool {
    if s.count < 3 {
        return false
    }
    for i in 0..<s.count-2 {
        if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] {
            return false
        }
    }
    return true
}

// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.

func isHappy(s: String) -> Bool {
    if s.count < 3 {
        return false
    }
    for i in 0..<s.count-2 {
        if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] {
            return false
        }
    }
    return true
}

import Foundation

class Solution {
    var maxDepth = 0
    func maxDepth(root: TreeNode?) -> Int {
        if root == nil {
            return 0
        }
        maxDepth(root: root.left)
        maxDepth(root: root.right)
        maxDepth += 1
        return maxDepth
    }
}

class Solution {
    func maxDepth(root: TreeNode?) -> Int {
        if root == nil {
            return 0
        }
        var stack = [root]
        var depth = 0
        while stack.count > 0 {
            var tempStack = []
            for node in stack {
                if node.left != nil {
                    tempStack.append(node.left)
                }
                if node.right != nil {
                    tempStack.append(node.right)
                }
            }
            stack = tempStack
            depth += 1
        }
        return depth
    }
}

class Solution {
    var result = []
    func levelOrder(root: TreeNode?) {
        if root == nil {
            return
        }
        result.append(root.val)
        levelOrder(root: root.left)
        levelOrder(root: root.right)
    }
}

class Solution {
    func levelOrder(root: TreeNode?) -> [Int] {
        if root == nil {
            return []
        }
        var result = []
        var queue = [root]
        while queue.count > 0 {
            var tempQueue = []
            var tempResult = []
            for node in queue {
                tempResult.append(node.val)
                if node.left != nil {
                    tempQueue.append(node.left)
                }
                if node.right != nil {
                    tempQueue.append(node.right)
                }
            }
            result.append(tempResult)
            queue = tempQueue
        }
        return result
    }
}
```swift
// You are given a string s.
// Your task is to check if the string is hapswift or not.
// A string is hapswift if its length is at least 3 and every 3 consecutive letters are distinct
// For example:
// isHappy(s: "a") == false
// isHappy(s: "aa") == false
// isHappy(s: "abcd") == true
// isHappy(s: "aabb") == false
// isHappy(s: "adb") == true
// isHappy(s: "xyy") == false
func isHappy(s: String) -> Bool {
    if s.count < 3 {
        return false
    }
    for i in 0..<s.count-2 {
        if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] {
            return false
        }
    }
    return true
}

var result = isHappy("aabb")
print(result)<|endoftext|>//
//  main.swift
//  101-二叉树的最大深度
//
//  Created by 邱翔宇 on 2019/1/29.
//  Copyright © 2019 邱翔宇. All rights reserved.
//

import Foundation

// 给定一个二叉树,找出其最大深度。
// 二叉树的深度为根节点到最远叶子节点的最长路径上的节点数。
// 说明: 叶子节点是指没有子节点的节点。

// 示例:
// 给定二叉树 [3,9,20,null,null,15,7],
//     3
//    / \
//   9  20
//     /  \
//    15   7
// 返回它的最大深度 3 。

// 递归
class Solution {
    var maxDepth = 0
    func maxDepth(root: TreeNode?) -> Int {
        if root == nil {
            return 0
        }
        maxDepth(root: root.left)
        maxDepth(root: root.right)
        maxDepth += 1
        return maxDepth
    }
}

// 迭代
class Solution {
    func maxDepth(root: TreeNode?) -> Int {
        if root == nil {
            return 0
        }
        var stack = [root]
        var depth = 0
        while stack.count > 0 {
            var tempStack = []
            for node in stack {
                if node.left != nil {
                    tempStack.append(node.left)
                }
                if node.right != nil {
                    tempStack.append(node.right)
                }
            }
            stack = tempStack
            depth += 1
        }
        return depth
    }
}<|endoftext|>//
//  main.swift
//  102-二叉树的层次遍历
//
//  Created by 邱翔宇 on 2019/1/29.
//  Copyright © 2019 邱翔宇. All rights reserved.
//

import Foundation

// 给定一个二叉树,返回其按层次遍历的节点值。 (即逐层地,从左到右访问所有节点)。
// 例如:
// 给定二叉树: [3,9,20,null,null,15,7],
//     3
//    / \
//   9  20
//     /  \
//    15   7
// 返回其层次遍历结果:
// [
//   [3],
//   [9,20],
//   [15,7]
// ]

// 递归
class Solution {
    var result = []
    func levelOrder(root: TreeNode?) {
        if root == nil {
            return
        }
        result.append(root.val)
        levelOrder(root: root.left)
        levelOrder(root: root.right)
    }
}

// 迭代
class Solution {
    func levelOrder(root: TreeNode?) -> [Int] {
        if root == nil {
            return []
        }
        var result = []
        var queue = [root]
        while queue.count > 0 {
            var tempQueue = []
            var tempResult = []
            for node in queue {
                tempResult.append(node.val)
                if node.left != nil {
                    tempQueue.append(node.left)
                }
                if node.right != nil {
                    tempQueue.append(node.right)
                }
            }
            result.append(tempResult)
            queue = tempQueue
        }
        return result
    }
}<
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
func maxDepth(root: TreeNode?) -> Int { // cannot find type 'TreeNode' in scope
maxDepth(root: root.left) // cannot call value of non-function type 'Int'
maxDepth(root: root.right) // cannot call value of non-function type 'Int'
class Solution { // invalid redeclaration of 'Solution'
func maxDepth(root: TreeNode?) -> Int { // cannot find type 'TreeNode' in scope
var tempStack = [] // empty collection literal requires an explicit type
class Solution { // invalid redeclaration of 'Solution'
var result = [] // empty collection literal requires an explicit type
func levelOrder(root: TreeNode?) { // cannot find type 'TreeNode' in scope
class Solution { // invalid redeclaration of 'Solution'
func levelOrder(root: TreeNode?) -> [Int] { // cannot find type 'TreeNode' in scope
var result = [] // empty collection literal requires an explicit type
var tempQueue = [] // empty collection literal requires an explicit type
var tempResult = [] // empty collection literal requires an explicit type
return result // cannot convert return expression of type '[Any]' to return type '[Int]'

func isHappy(s: String) -> Bool {
    if s.count < 3 {
        return false
    }
    for i in 0..<s.count-2 {
        if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] {
            return false
        }
    }
    return true
}
```swift
// You are given a string s.
// Your task is to check if the string is hapswift or not.
// A string is hapswift if its length is at least 3 and every 3 consecutive letters are distinct
// For example:
// isHappy(s: "a") == false
// isHappy(s: "aa") == false
// isHappy(s: "abcd") == true
// isHappy(s: "aabb") == false
// isHappy(s: "adb") == true
// isHappy(s: "xyy") == false
func isHappy(s: String) -> Bool {
    if s.count < 3 {
        return false
    }
    for i in 0..<s.count-2 {
        if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] {
            return false
        }
    }
    return true
}

// Task
// Given a string, find the length of the longest substring without repeating characters.
// Example 1:
// Input: "abcabcbb"
// Output: 3
// Explanation: The answer is "abc", with the length of 3.
// Example 2:
// Input: "bbbbb"
// Output: 1
// Explanation: The answer is "b", with the length of 1.
// Example 3:
// Input: "pwwkew"
// Output: 3
// Explanation: The answer is "wke", with the length of 3.
// Note that the answer must be a substring, "pwke" is a subsequence and not a substring.

// Solution
// 1. Use a set to store the characters
// 2. Use two pointers to keep track of the start and end of the substring
// 3. Use a variable to keep track of the length of the longest substring
// 4. Use a loop to iterate through the string
// 5. Use a loop to iterate through the substring
// 6. Use a loop to iterate through the characters
// 7. Use a loop to iterate through the characters
// 8. Use a loop to iterate through the characters
// 9. Use a loop to iterate through the characters
// 10. Use a loop to iterate through the characters
// 11. Use a loop to iterate through the characters
// 12. Use a loop to iterate through the characters
// 13. Use a loop to iterate through the characters
// 14. Use a loop to iterate through the characters
// 15. Use a loop to iterate through the characters
// 16. Use a loop to iterate through the characters
// 17. Use a loop to iterate through the characters
// 18. Use a loop to iterate through the characters
// 19. Use a loop to iterate through the characters
// 20. Use a loop to iterate through the characters
// 21. Use a loop to iterate through the characters
// 22. Use a loop to iterate through the characters
// 23. Use a loop to iterate through the characters
// 24. Use a loop to iterate through the characters
// 25. Use a loop to iterate through the characters
// 26. Use a loop to iterate through the characters
// 27. Use a loop to iterate through the characters
// 28. Use a loop to iterate through the characters
// 29. Use a loop to iterate through the characters
// 30. Use a loop to iterate through the characters
// 31. Use a loop to iterate through the characters
// 32. Use a loop to iterate through the characters
// 33. Use a loop to iterate through the characters
// 34. Use a loop to iterate through the characters
// 35. Use a loop to iterate through the characters
// 36. Use a loop to iterate through the characters
// 37. Use a loop to iterate through the characters
// 38. Use a loop to iterate through the characters
// 39. Use a loop to iterate through the characters
// 40. Use a loop to iterate through the characters
// 41. Use a loop to iterate through the characters
// 42. Use a loop to iterate through the characters
// 43. Use a loop to iterate through the characters
// 44. Use a loop to iterate through the characters
// 45. Use a loop to iterate through the characters
// 46. Use a loop to iterate through the characters
// 47. Use a loop to iterate through the characters
// 48. Use a loop to iterate through the characters
// 49. Use a loop to iterate through the characters
// 50. Use a loop to iterate through the characters
// 51. Use a loop to iterate through the characters
// 52. Use a loop to iterate through the characters
// 53. Use a loop to iterate through the characters
// 54. Use a loop to iterate through the characters
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.

func isHappy(s: String) -> Bool {
    if s.count < 3 {
        return false
    }
    for i in 0..<s.count-2 {
        if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] {
            return false
        }
    }
    return true
}
```swift
// You are given a string s.
// Your task is to check if the string is hapswift or not.
// A string is hapswift if its length is at least 3 and every 3 consecutive letters are distinct
// For example:
// isHappy(s: "a") == false
// isHappy(s: "aa") == false
// isHappy(s: "abcd") == true
// isHappy(s: "aabb") == false
// isHappy(s: "adb") == true
// isHappy(s: "xyy") == false
func isHappy(s: String) -> Bool {
    if s.count < 3 {
        return false
    }
    for i in 0..<s.count-2 {
        if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] {
            return false
        }
    }
    return true
}

// ----------------------------------------------------------------------------------------------------------------------
// Task 11
// ----------------------------------------------------------------------------------------------------------------------

// Write a function that takes a string as input and returns the string reversed.
// Example:
// Given s = "hello", return "olleh".

// ----------------------------------------------------------------------------------------------------------------------
// Solution
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// Tests
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// Tests
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// Tests
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// Tests
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// Tests
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// Tests
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// Tests
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// Tests
// ---------------------------------------------------------------------------------------------------
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.

func isHappy(s: String) -> Bool {
    if s.count < 3 {
        return false
    }
    for i in 0..<s.count-2 {
        if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] {
            return false
        }
    }
    return true
}

func firstRepeatedCharacter(s: String) -> String? {
    var dictionary = [Character: Int]()
    for character in s {
        if dictionary[character] == nil {
            dictionary[character] = 1
        } else {
            dictionary[character] += 1
        }
    }
    for (character, count) in dictionary {
        if count > 1 {
            return String(character)
        }
    }
    return nil
}
```swift
// You are given a string s.
// Your task is to check if the string is hapswift or not.
// A string is hapswift if its length is at least 3 and every 3 consecutive letters are distinct
// For example:
// isHappy(s: "a") == false
// isHappy(s: "aa") == false
// isHappy(s: "abcd") == true
// isHappy(s: "aabb") == false
// isHappy(s: "adb") == true
// isHappy(s: "xyy") == false
func isHappy(s: String) -> Bool {
    if s.count < 3 {
        return false
    }
    for i in 0..<s.count-2 {
        if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] {
            return false
        }
    }
    return true
}

// Task
// Given a string, find the first character that repeats and return it.
// If there are no repeating characters, return nil/None.
// Examples
// "aabbcde"      -->  "b"
// "abcdefgh"     -->  nil/None
// "aabBcde"      -->  "b"
// "aabBcdeB"     -->  "B"
// "aabBcdeBc"    -->  "B"
// "aabBcdeBcFf"  -->  "F"
// ""             -->  nil/None

// Solution
// 1. Create an empty dictionary to store the characters and their counts
// 2. Iterate through the string and update the count of each character in the dictionary
// 3. Iterate through the dictionary and find the first character with a count greater than 1
// 4. If no such character is found, return nil/None
// 5. Otherwise, return the character

// Time Complexity: O(n)
// Space Complexity: O(n)
func firstRepeatedCharacter(s: String) -> String? {
    var dictionary = [Character: Int]()
    for character in s {
        if dictionary[character] == nil {
            dictionary[character] = 1
        } else {
            dictionary[character] += 1
        }
    }
    for (character, count) in dictionary {
        if count > 1 {
            return String(character)
        }
    }
    return nil
}

// Task
// Given a string, find the first character that repeats and return it.
// If there are no repeating characters, return nil/None.
// Examples
// "aabbcde"      -->  "b"
// "abcdefgh"     -->  nil/None
// "aabBcde"      -->  "b"
// "aabBcdeB"     -->  "B"
// "aabBcdeBc"    -->  "B"
// "aabBcdeBcFf"  -->  "F"
// ""             -->  nil/None

// Solution
// 1. Create an empty dictionary to store the characters and their counts
// 2. Iterate through the string and update the count of each character in the dictionary
// 3. Iterate through the dictionary and find the first character with a count greater than 1
// 4. If no such character is found, return nil/None
// 5. Otherwise, return the character

// Time Complexity: O(n)
// Space Complexity: O(n)
func firstRepeatedCharacter(s: String) -> String? {
    var dictionary = [Character: Int]()
    for character in s {
        if dictionary[character] == nil {
            dictionary[character] = 1
        } else {
            dictionary[character] += 1
        }
    }
    for (character, count) in dictionary {
        if count > 1 {
            return String(character)
        }
    }
    return nil
}

// Task
// Given a string, find the first character that repeats and return it.
// If there are no repeating characters, return nil/None.
// Examples
// "aabbcde"      -->  "b"
// "abcdefgh"     -->  nil/None
// "aabBcde"      -->  "b"
// "aabBcdeB"     -->  "B"
// "aabBcdeBc"    -->  "B"
// "aabBcdeBcFf"  -->  "F"
// ""             -->  nil/None

// Solution
// 1. Create an empty dictionary to store the characters and their counts
// 2. Iterate through the string and update the count of each character in the dictionary
// 3. Iterate through the dictionary and find the first character with a count greater than 1
// 4. If no
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
dictionary[character] += 1 // value of optional type 'Int?' must be unwrapped to a value of type 'Int'

func numericalLetterGrade(grades: [Double]) -> [String] {
    var result = [String]()
    for grade in grades {
        if grade >= 4.0 {
            result.append("A+")
        } else if grade >= 3.7 {
            result.append("A")
        } else if grade >= 3.3 {
            result.append("A-")
        } else if grade >= 3.0 {
            result.append("B+")
        } else if grade >= 2.7 {
            result.append("B")
        } else if grade >= 2.3 {
            result.append("B-")
        } else if grade >= 2.0 {
            result.append("C+")
        } else if grade >= 1.7 {
            result.append("C")
        } else if grade >= 1.3 {
            result.append("C-")
        } else if grade >= 1.0 {
            result.append("D+")
        } else if grade >= 0.7 {
            result.append("D")
        } else {
            result.append("E")
        }
    }
    return result
}
```swift
// It is the last week of the semester and the teacher has to give the grades
// to students. The teacher has been making her own algorithm for grading.
// The only problem is, she has lost the code she used for grading.
// She has given you an array of GPAs for some students and you have to write 
// a function that can output an array of letter grades using the following table:
// GPA       |    Letter grade
// 4.0                A+
// > 3.7                A 
// > 3.3                A- 
// > 3.0                B+
// > 2.7                B 
// > 2.3                B-
// > 2.0                C+
// > 1.7                C
// > 1.3                C-
// > 1.0                D+ 
// > 0.7                D 
// > 0.0                D-
// 0.0                E
// Example:
// numericalLetterGrade(grades: [4.0, 3, 1.7, 2, 3.5]) == ["A+", "B", "C-", "C", "A-"]
func numericalLetterGrade(grades: [Double]) -> [String] {
    var result = [String]()
    for grade in grades {
        if grade >= 4.0 {
            result.append("A+")
        } else if grade >= 3.7 {
            result.append("A")
        } else if grade >= 3.3 {
            result.append("A-")
        } else if grade >= 3.0 {
            result.append("B+")
        } else if grade >= 2.7 {
            result.append("B")
        } else if grade >= 2.3 {
            result.append("B-")
        } else if grade >= 2.0 {
            result.append("C+")
        } else if grade >= 1.7 {
            result.append("C")
        } else if grade >= 1.3 {
            result.append("C-")
        } else if grade >= 1.0 {
            result.append("D+")
        } else if grade >= 0.7 {
            result.append("D")
        } else {
            result.append("E")
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
 // XCTAssertTrue failed

func numericalLetterGrade(grades: [Double]) -> [String] {
    var result = [String]()
    for grade in grades {
        if grade >= 4.0 {
            result.append("A+")
        } else if grade >= 3.7 {
            result.append("A")
        } else if grade >= 3.3 {
            result.append("A-")
        } else if grade >= 3.0 {
            result.append("B+")
        } else if grade >= 2.7 {
            result.append("B")
        } else if grade >= 2.3 {
            result.append("B-")
        } else if grade >= 2.0 {
            result.append("C+")
        } else if grade >= 1.7 {
            result.append("C")
        } else if grade >= 1.3 {
            result.append("C-")
        } else if grade >= 1.0 {
            result.append("D+")
        } else if grade >= 0.7 {
            result.append("D")
        } else {
            result.append("E")
        }
    }
    return result
}
```swift
// It is the last week of the semester and the teacher has to give the grades
// to students. The teacher has been making her own algorithm for grading.
// The only problem is, she has lost the code she used for grading.
// She has given you an array of GPAs for some students and you have to write 
// a function that can output an array of letter grades using the following table:
// GPA       |    Letter grade
// 4.0                A+
// > 3.7                A 
// > 3.3                A- 
// > 3.0                B+
// > 2.7                B 
// > 2.3                B-
// > 2.0                C+
// > 1.7                C
// > 1.3                C-
// > 1.0                D+ 
// > 0.7                D 
// > 0.0                D-
// 0.0                E
// Example:
// numericalLetterGrade(grades: [4.0, 3, 1.7, 2, 3.5]) == ["A+", "B", "C-", "C", "A-"]
func numericalLetterGrade(grades: [Double]) -> [String] {
    var result = [String]()
    for grade in grades {
        if grade >= 4.0 {
            result.append("A+")
        } else if grade >= 3.7 {
            result.append("A")
        } else if grade >= 3.3 {
            result.append("A-")
        } else if grade >= 3.0 {
            result.append("B+")
        } else if grade >= 2.7 {
            result.append("B")
        } else if grade >= 2.3 {
            result.append("B-")
        } else if grade >= 2.0 {
            result.append("C+")
        } else if grade >= 1.7 {
            result.append("C")
        } else if grade >= 1.3 {
            result.append("C-")
        } else if grade >= 1.0 {
            result.append("D+")
        } else if grade >= 0.7 {
            result.append("D")
        } else {
            result.append("E")
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ---------------
 // XCTAssertTrue failed

func numericalLetterGrade(grades: [Double]) -> [String] {
    var result = [String]()
    for grade in grades {
        if grade >= 4.0 {
            result.append("A+")
        } else if grade >= 3.7 {
            result.append("A")
        } else if grade >= 3.3 {
            result.append("A-")
        } else if grade >= 3.0 {
            result.append("B+")
        } else if grade >= 2.7 {
            result.append("B")
        } else if grade >= 2.3 {
            result.append("B-")
        } else if grade >= 2.0 {
            result.append("C+")
        } else if grade >= 1.7 {
            result.append("C")
        } else if grade >= 1.3 {
            result.append("C-")
        } else if grade >= 1.0 {
            result.append("D+")
        } else if grade >= 0.7 {
            result.append("D")
        } else {
            result.append("E")
        }
    }
    return result
}
```swift
// It is the last week of the semester and the teacher has to give the grades
// to students. The teacher has been making her own algorithm for grading.
// The only problem is, she has lost the code she used for grading.
// She has given you an array of GPAs for some students and you have to write 
// a function that can output an array of letter grades using the following table:
// GPA       |    Letter grade
// 4.0                A+
// > 3.7                A 
// > 3.3                A- 
// > 3.0                B+
// > 2.7                B 
// > 2.3                B-
// > 2.0                C+
// > 1.7                C
// > 1.3                C-
// > 1.0                D+ 
// > 0.7                D 
// > 0.0                D-
// 0.0                E
// Example:
// numericalLetterGrade(grades: [4.0, 3, 1.7, 2, 3.5]) == ["A+", "B", "C-", "C", "A-"]
func numericalLetterGrade(grades: [Double]) -> [String] {
    var result = [String]()
    for grade in grades {
        if grade >= 4.0 {
            result.append("A+")
        } else if grade >= 3.7 {
            result.append("A")
        } else if grade >= 3.3 {
            result.append("A-")
        } else if grade >= 3.0 {
            result.append("B+")
        } else if grade >= 2.7 {
            result.append("B")
        } else if grade >= 2.3 {
            result.append("B-")
        } else if grade >= 2.0 {
            result.append("C+")
        } else if grade >= 1.7 {
            result.append("C")
        } else if grade >= 1.3 {
            result.append("C-")
        } else if grade >= 1.0 {
            result.append("D+")
        } else if grade >= 0.7 {
            result.append("D")
        } else {
            result.append("E")
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ---------------
 // XCTAssertTrue failed

func numericalLetterGrade(grades: [Double]) -> [String] {
    var result = [String]()
    for grade in grades {
        switch grade {
        case 4.0:
            result.append("A+")
        case 3.0...3.9:
            result.append("B+")
        case 2.0...2.9:
            result.append("B")
        case 1.0...1.9:
            result.append("C+")
        case 0.0...0.9:
            result.append("C")
        default:
            result.append("D")
        }
    }
    return result
}
```swift
// It is the last week of the semester and the teacher has to give the grades
// to students. The teacher has been making her own algorithm for grading.
// The only problem is, she has lost the code she used for grading.
// She has given you an array of GPAs for some students and you have to write 
// a function that can output an array of letter grades using the following table:
// GPA       |    Letter grade
// 4.0                A+
// > 3.7                A 
// > 3.3                A- 
// > 3.0                B+
// > 2.7                B 
// > 2.3                B-
// > 2.0                C+
// > 1.7                C
// > 1.3                C-
// > 1.0                D+ 
// > 0.7                D 
// > 0.0                D-
// 0.0                E
// Example:
// numericalLetterGrade(grades: [4.0, 3, 1.7, 2, 3.5]) == ["A+", "B", "C-", "C", "A-"]
func numericalLetterGrade(grades: [Double]) -> [String] {
    var result = [String]()
    for grade in grades {
        switch grade {
        case 4.0:
            result.append("A+")
        case 3.0...3.9:
            result.append("B+")
        case 2.0...2.9:
            result.append("B")
        case 1.0...1.9:
            result.append("C+")
        case 0.0...0.9:
            result.append("C")
        default:
            result.append("D")
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ---------------------------------------------
 // XCTAssertTrue failed

func numericalLetterGrade(grades: [Double]) -> [String] {
    var result = [String]()
    for grade in grades {
        if grade >= 4.0 {
            result.append("A+")
        } else if grade >= 3.7 {
            result.append("A")
        } else if grade >= 3.3 {
            result.append("A-")
        } else if grade >= 3.0 {
            result.append("B+")
        } else if grade >= 2.7 {
            result.append("B")
        } else if grade >= 2.3 {
            result.append("B-")
        } else if grade >= 2.0 {
            result.append("C+")
        } else if grade >= 1.7 {
            result.append("C")
        } else if grade >= 1.3 {
            result.append("C-")
        } else if grade >= 1.0 {
            result.append("D+")
        } else if grade >= 0.7 {
            result.append("D")
        } else if grade >= 0.0 {
            result.append("D-")
        } else {
            result.append("E")
        }
    }
    return result
}
```swift
// It is the last week of the semester and the teacher has to give the grades
// to students. The teacher has been making her own algorithm for grading.
// The only problem is, she has lost the code she used for grading.
// She has given you an array of GPAs for some students and you have to write 
// a function that can output an array of letter grades using the following table:
// GPA       |    Letter grade
// 4.0                A+
// > 3.7                A 
// > 3.3                A- 
// > 3.0                B+
// > 2.7                B 
// > 2.3                B-
// > 2.0                C+
// > 1.7                C
// > 1.3                C-
// > 1.0                D+ 
// > 0.7                D 
// > 0.0                D-
// 0.0                E
// Example:
// numericalLetterGrade(grades: [4.0, 3, 1.7, 2, 3.5]) == ["A+", "B", "C-", "C", "A-"]
func numericalLetterGrade(grades: [Double]) -> [String] {
    var result = [String]()
    for grade in grades {
        if grade >= 4.0 {
            result.append("A+")
        } else if grade >= 3.7 {
            result.append("A")
        } else if grade >= 3.3 {
            result.append("A-")
        } else if grade >= 3.0 {
            result.append("B+")
        } else if grade >= 2.7 {
            result.append("B")
        } else if grade >= 2.3 {
            result.append("B-")
        } else if grade >= 2.0 {
            result.append("C+")
        } else if grade >= 1.7 {
            result.append("C")
        } else if grade >= 1.3 {
            result.append("C-")
        } else if grade >= 1.0 {
            result.append("D+")
        } else if grade >= 0.7 {
            result.append("D")
        } else if grade >= 0.0 {
            result.append("D-")
        } else {
            result.append("E")
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// ---------
 // XCTAssertTrue failed

func numericalLetterGrade(grades: [Double]) -> [String] {
    var result = [String]()
    for grade in grades {
        if grade >= 4.0 {
            result.append("A+")
        } else if grade >= 3.7 {
            result.append("A")
        } else if grade >= 3.3 {
            result.append("A-")
        } else if grade >= 3.0 {
            result.append("B+")
        } else if grade >= 2.7 {
            result.append("B")
        } else if grade >= 2.3 {
            result.append("B-")
        } else if grade >= 2.0 {
            result.append("C+")
        } else if grade >= 1.7 {
            result.append("C")
        } else if grade >= 1.3 {
            result.append("C-")
        } else if grade >= 1.0 {
            result.append("D+")
        } else if grade >= 0.7 {
            result.append("D")
        } else {
            result.append("E")
        }
    }
    return result
}
```swift
// It is the last week of the semester and the teacher has to give the grades
// to students. The teacher has been making her own algorithm for grading.
// The only problem is, she has lost the code she used for grading.
// She has given you an array of GPAs for some students and you have to write 
// a function that can output an array of letter grades using the following table:
// GPA       |    Letter grade
// 4.0                A+
// > 3.7                A 
// > 3.3                A- 
// > 3.0                B+
// > 2.7                B 
// > 2.3                B-
// > 2.0                C+
// > 1.7                C
// > 1.3                C-
// > 1.0                D+ 
// > 0.7                D 
// > 0.0                D-
// 0.0                E
// Example:
// numericalLetterGrade(grades: [4.0, 3, 1.7, 2, 3.5]) == ["A+", "B", "C-", "C", "A-"]
func numericalLetterGrade(grades: [Double]) -> [String] {
    var result = [String]()
    for grade in grades {
        if grade >= 4.0 {
            result.append("A+")
        } else if grade >= 3.7 {
            result.append("A")
        } else if grade >= 3.3 {
            result.append("A-")
        } else if grade >= 3.0 {
            result.append("B+")
        } else if grade >= 2.7 {
            result.append("B")
        } else if grade >= 2.3 {
            result.append("B-")
        } else if grade >= 2.0 {
            result.append("C+")
        } else if grade >= 1.7 {
            result.append("C")
        } else if grade >= 1.3 {
            result.append("C-")
        } else if grade >= 1.0 {
            result.append("D+")
        } else if grade >= 0.7 {
            result.append("D")
        } else {
            result.append("E")
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ---------------
 // XCTAssertTrue failed

func numericalLetterGrade(grades: [Double]) -> [String] {
    var result = [String]()
    for grade in grades {
        if grade >= 4.0 {
            result.append("A+")
        } else if grade >= 3.7 {
            result.append("A")
        } else if grade >= 3.3 {
            result.append("A-")
        } else if grade >= 3.0 {
            result.append("B+")
        } else if grade >= 2.7 {
            result.append("B")
        } else if grade >= 2.3 {
            result.append("B-")
        } else if grade >= 2.0 {
            result.append("C+")
        } else if grade >= 1.7 {
            result.append("C")
        } else if grade >= 1.3 {
            result.append("C-")
        } else if grade >= 1.0 {
            result.append("D+")
        } else if grade >= 0.7 {
            result.append("D")
        } else {
            result.append("E")
        }
    }
    return result
}
```swift
// It is the last week of the semester and the teacher has to give the grades
// to students. The teacher has been making her own algorithm for grading.
// The only problem is, she has lost the code she used for grading.
// She has given you an array of GPAs for some students and you have to write 
// a function that can output an array of letter grades using the following table:
// GPA       |    Letter grade
// 4.0                A+
// > 3.7                A 
// > 3.3                A- 
// > 3.0                B+
// > 2.7                B 
// > 2.3                B-
// > 2.0                C+
// > 1.7                C
// > 1.3                C-
// > 1.0                D+ 
// > 0.7                D 
// > 0.0                D-
// 0.0                E
// Example:
// numericalLetterGrade(grades: [4.0, 3, 1.7, 2, 3.5]) == ["A+", "B", "C-", "C", "A-"]
func numericalLetterGrade(grades: [Double]) -> [String] {
    var result = [String]()
    for grade in grades {
        if grade >= 4.0 {
            result.append("A+")
        } else if grade >= 3.7 {
            result.append("A")
        } else if grade >= 3.3 {
            result.append("A-")
        } else if grade >= 3.0 {
            result.append("B+")
        } else if grade >= 2.7 {
            result.append("B")
        } else if grade >= 2.3 {
            result.append("B-")
        } else if grade >= 2.0 {
            result.append("C+")
        } else if grade >= 1.7 {
            result.append("C")
        } else if grade >= 1.3 {
            result.append("C-")
        } else if grade >= 1.0 {
            result.append("D+")
        } else if grade >= 0.7 {
            result.append("D")
        } else {
            result.append("E")
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------------
 // XCTAssertTrue failed

func numericalLetterGrade(grades: [Double]) -> [String] {
    var result = [String]()
    for grade in grades {
        if grade >= 4.0 {
            result.append("A+")
        } else if grade >= 3.7 {
            result.append("A")
        } else if grade >= 3.3 {
            result.append("A-")
        } else if grade >= 3.0 {
            result.append("B+")
        } else if grade >= 2.7 {
            result.append("B")
        } else if grade >= 2.3 {
            result.append("B-")
        } else if grade >= 2.0 {
            result.append("C+")
        } else if grade >= 1.7 {
            result.append("C")
        } else if grade >= 1.3 {
            result.append("C-")
        } else if grade >= 1.0 {
            result.append("D+")
        } else if grade >= 0.7 {
            result.append("D")
        } else {
            result.append("E")
        }
    }
    return result
}
```swift
// It is the last week of the semester and the teacher has to give the grades
// to students. The teacher has been making her own algorithm for grading.
// The only problem is, she has lost the code she used for grading.
// She has given you an array of GPAs for some students and you have to write 
// a function that can output an array of letter grades using the following table:
// GPA       |    Letter grade
// 4.0                A+
// > 3.7                A 
// > 3.3                A- 
// > 3.0                B+
// > 2.7                B 
// > 2.3                B-
// > 2.0                C+
// > 1.7                C
// > 1.3                C-
// > 1.0                D+ 
// > 0.7                D 
// > 0.0                D-
// 0.0                E
// Example:
// numericalLetterGrade(grades: [4.0, 3, 1.7, 2, 3.5]) == ["A+", "B", "C-", "C", "A-"]
func numericalLetterGrade(grades: [Double]) -> [String] {
    var result = [String]()
    for grade in grades {
        if grade >= 4.0 {
            result.append("A+")
        } else if grade >= 3.7 {
            result.append("A")
        } else if grade >= 3.3 {
            result.append("A-")
        } else if grade >= 3.0 {
            result.append("B+")
        } else if grade >= 2.7 {
            result.append("B")
        } else if grade >= 2.3 {
            result.append("B-")
        } else if grade >= 2.0 {
            result.append("C+")
        } else if grade >= 1.7 {
            result.append("C")
        } else if grade >= 1.3 {
            result.append("C-")
        } else if grade >= 1.0 {
            result.append("D+")
        } else if grade >= 0.7 {
            result.append("D")
        } else {
            result.append("E")
        }
    }
    return result
}

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------
 // XCTAssertTrue failed

func numericalLetterGrade(grades: [Double]) -> [String] {
    var result = [String]()
    for grade in grades {
        if grade >= 4.0 {
            result.append("A+")
        } else if grade >= 3.7 {
            result.append("A")
        } else if grade >= 3.3 {
            result.append("A-")
        } else if grade >= 3.0 {
            result.append("B+")
        } else if grade >= 2.7 {
            result.append("B")
        } else if grade >= 2.3 {
            result.append("B-")
        } else if grade >= 2.0 {
            result.append("C+")
        } else if grade >= 1.7 {
            result.append("C")
        } else if grade >= 1.3 {
            result.append("C-")
        } else if grade >= 1.0 {
            result.append("D+")
        } else if grade >= 0.7 {
            result.append("D")
        } else {
            result.append("E")
        }
    }
    return result
}
```swift
// It is the last week of the semester and the teacher has to give the grades
// to students. The teacher has been making her own algorithm for grading.
// The only problem is, she has lost the code she used for grading.
// She has given you an array of GPAs for some students and you have to write 
// a function that can output an array of letter grades using the following table:
// GPA       |    Letter grade
// 4.0                A+
// > 3.7                A 
// > 3.3                A- 
// > 3.0                B+
// > 2.7                B 
// > 2.3                B-
// > 2.0                C+
// > 1.7                C
// > 1.3                C-
// > 1.0                D+ 
// > 0.7                D 
// > 0.0                D-
// 0.0                E
// Example:
// numericalLetterGrade(grades: [4.0, 3, 1.7, 2, 3.5]) == ["A+", "B", "C-", "C", "A-"]
func numericalLetterGrade(grades: [Double]) -> [String] {
    var result = [String]()
    for grade in grades {
        if grade >= 4.0 {
            result.append("A+")
        } else if grade >= 3.7 {
            result.append("A")
        } else if grade >= 3.3 {
            result.append("A-")
        } else if grade >= 3.0 {
            result.append("B+")
        } else if grade >= 2.7 {
            result.append("B")
        } else if grade >= 2.3 {
            result.append("B-")
        } else if grade >= 2.0 {
            result.append("C+")
        } else if grade >= 1.7 {
            result.append("C")
        } else if grade >= 1.3 {
            result.append("C-")
        } else if grade >= 1.0 {
            result.append("D+")
        } else if grade >= 0.7 {
            result.append("D")
        } else {
            result.append("E")
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
 // XCTAssertTrue failed

func numericalLetterGrade(grades: [Double]) -> [String] {
    var result = [String]()
    for grade in grades {
        if grade >= 4.0 {
            result.append("A+")
        } else if grade >= 3.7 {
            result.append("A")
        } else if grade >= 3.3 {
            result.append("A-")
        } else if grade >= 3.0 {
            result.append("B+")
        } else if grade >= 2.7 {
            result.append("B")
        } else if grade >= 2.3 {
            result.append("B-")
        } else if grade >= 2.0 {
            result.append("C+")
        } else if grade >= 1.7 {
            result.append("C")
        } else if grade >= 1.3 {
            result.append("C-")
        } else if grade >= 1.0 {
            result.append("D+")
        } else if grade >= 0.7 {
            result.append("D")
        } else {
            result.append("E")
        }
    }
    return result
}
```swift
// It is the last week of the semester and the teacher has to give the grades
// to students. The teacher has been making her own algorithm for grading.
// The only problem is, she has lost the code she used for grading.
// She has given you an array of GPAs for some students and you have to write 
// a function that can output an array of letter grades using the following table:
// GPA       |    Letter grade
// 4.0                A+
// > 3.7                A 
// > 3.3                A- 
// > 3.0                B+
// > 2.7                B 
// > 2.3                B-
// > 2.0                C+
// > 1.7                C
// > 1.3                C-
// > 1.0                D+ 
// > 0.7                D 
// > 0.0                D-
// 0.0                E
// Example:
// numericalLetterGrade(grades: [4.0, 3, 1.7, 2, 3.5]) == ["A+", "B", "C-", "C", "A-"]
func numericalLetterGrade(grades: [Double]) -> [String] {
    var result = [String]()
    for grade in grades {
        if grade >= 4.0 {
            result.append("A+")
        } else if grade >= 3.7 {
            result.append("A")
        } else if grade >= 3.3 {
            result.append("A-")
        } else if grade >= 3.0 {
            result.append("B+")
        } else if grade >= 2.7 {
            result.append("B")
        } else if grade >= 2.3 {
            result.append("B-")
        } else if grade >= 2.0 {
            result.append("C+")
        } else if grade >= 1.7 {
            result.append("C")
        } else if grade >= 1.3 {
            result.append("C-")
        } else if grade >= 1.0 {
            result.append("D+")
        } else if grade >= 0.7 {
            result.append("D")
        } else {
            result.append("E")
        }
    }
    return result
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// ------------------------------------------------------------------
 // XCTAssertTrue failed

func primeLength(string: String) -> Bool {
    return Int(string.length) % 2 != 0
}

func countA(string: String) -> Int {
    return string.count(for: "a")
}

func countA(string: String) -> Int {
    return string.count(for: "a", options: .caseInsensitive)
}
```swift
// Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// primeLength(string: "Hello") == true
// primeLength(string: "abcdcba") == true
// primeLength(string: "kittens") == true
// primeLength(string: "orange") == false
func primeLength(string: String) -> Bool {
    return Int(string.length) % 2 != 0
}

// 2. Write a function that takes a string and returns the number of times
// the letter "a" appears in it.
// Examples
// countA(string: "Hello") == 1
// countA(string: "Hello, World") == 2
// countA(string: "apple") == 1
// countA(string: "orange") == 0
func countA(string: String) -> Int {
    return string.count(for: "a")
}

// 3. Write a function that takes a string and returns the number of times
// the letter "a" appears in it, ignoring case.
// Examples
// countA(string: "Hello") == 1
// countA(string: "Hello, World") == 2
// countA(string: "apple") == 1
// countA(string: "orange") == 0
// countA(string: "A") == 1
// countA(string: "a") == 1
func countA(string: String) -> Int {
    return string.count(for: "a", options: .caseInsensitive)
}

// 4. Write a function that takes a string and returns the number of times
// the letter "a" appears in it, ignoring case and punctuation.
// Examples
// countA(string: "Hello") == 1
// countA(string: "Hello, World") == 2
// countA(string: "apple") == 1
// countA(string: "orange") == 0
// countA(string: "A") == 1
// countA(string: "a") == 1
// countA(string: "Hello, apple!") == 1
// countA(string: "Hello, apple?") == 1
// countA(string: "Hello, apple!?") == 1
// countA(string: "Hello, apple!?!") == 1
// countA(string: "Hello, apple!?!?") == 1
// countA(string: "Hello, apple!?!?!") == 1
// countA(string: "Hello, apple!?!?!?") == 1
// countA(string: "Hello, apple!?!?!?!") == 1
// countA(string: "Hello, apple!?!?!?!?") == 1
// countA(string: "Hello, apple!?!?!?!??") == 1
// countA(string: "Hello, apple!?!?!?!???") == 1
// countA(string: "Hello, apple!?!?!?!????") == 1
// countA(string: "Hello, apple!?!?!?!?????") == 1
// countA(string: "Hello, apple!?!?!?!??????") == 1
// countA(string: "Hello, apple!?!?!?!???????") == 1
// countA(string: "Hello, apple!?!?!?!????????") == 1
// countA(string: "Hello, apple!?!?!?!?????????") == 1
// countA(string: "Hello, apple!?!?!?!??????????") == 1
// countA(string: "Hello, apple!?!?!?!???????????") == 1
// countA(string: "Hello, apple!?!?!?!????????????") == 1
// countA(string: "Hello, apple!?!?!?!?????????????") == 1
// countA(string: "Hello, apple!?!?!?!??????????????") == 1
// countA(string: "Hello, apple!?!?!?!???
return Int(string.length) % 2 != 0 // value of type 'String' has no member 'length'
return string.count(for: "a") // cannot call value of non-function type 'Int'
func countA(string: String) -> Int { // invalid redeclaration of 'countA(string:)'
return string.count(for: "a", options: .caseInsensitive) // cannot call value of non-function type 'Int'
return string.count(for: "a", options: .caseInsensitive) // cannot infer contextual base in reference to member 'caseInsensitive'

func primeLength(string: String) -> Bool {
    return string.length % 2 == 1
}

func uniqueCharacters(string: String) -> Bool {
    return string.count == Set(string).count
}

func firstNonRepeatedCharacter(string: String) -> String? {
    for char in string {
        if string.count(char) == 1 {
            return String(char)
        }
    }
    return nil
}

func firstRepeatedCharacter(string: String) -> String? {
    for char in string {
        if string.count(char) > 1 {
            return String(char)
        }
    }
    return nil
}
```swift
// Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// primeLength(string: "Hello") == true
// primeLength(string: "abcdcba") == true
// primeLength(string: "kittens") == true
// primeLength(string: "orange") == false
func primeLength(string: String) -> Bool {
    return string.length % 2 == 1
}

// -----------------------------------------------------------------------------
// 2. Write a function that takes a string and returns true if the string
// contains only unique characters or false otherwise
// Examples
// uniqueCharacters(string: "Hello") == true
// uniqueCharacters(string: "abcdcba") == false
// uniqueCharacters(string: "kittens") == false
// uniqueCharacters(string: "orange") == true
func uniqueCharacters(string: String) -> Bool {
    return string.count == Set(string).count
}

// -----------------------------------------------------------------------------
// 3. Write a function that takes a string and returns the first non-repeated
// character in the string. If there are no non-repeated characters, return nil.
// Examples
// firstNonRepeatedCharacter(string: "Hello") == "e"
// firstNonRepeatedCharacter(string: "abcdcba") == "a"
// firstNonRepeatedCharacter(string: "kittens") == "i"
// firstNonRepeatedCharacter(string: "orange") == "o"
func firstNonRepeatedCharacter(string: String) -> String? {
    for char in string {
        if string.count(char) == 1 {
            return String(char)
        }
    }
    return nil
}

// -----------------------------------------------------------------------------
// 4. Write a function that takes a string and returns the first repeated
// character in the string. If there are no repeated characters, return nil.
// Examples
// firstRepeatedCharacter(string: "Hello") == "e"
// firstRepeatedCharacter(string: "abcdcba") == "d"
// firstRepeatedCharacter(string: "kittens") == "i"
// firstRepeatedCharacter(string: "orange") == "o"
func firstRepeatedCharacter(string: String) -> String? {
    for char in string {
        if string.count(char) > 1 {
            return String(char)
        }
    }
    return nil
}

// -----------------------------------------------------------------------------
// 5. Write a function that takes a string and returns the first repeated
// character in the string. If there are no repeated characters, return nil.
// Examples
// firstRepeatedCharacter(string: "Hello") == "e"
// firstRepeatedCharacter(string: "abcdcba") == "d"
// firstRepeatedCharacter(string: "kittens") == "i"
// firstRepeatedCharacter(string: "orange") == "o"
func firstRepeatedCharacter(string: String) -> String? {
    for char in string {
        if string.count(char) > 1 {
            return String(char)
        }
    }
    return nil
}

// -----------------------------------------------------------------------------
// 6. Write a function that takes a string and returns the first repeated
// character in the string. If there are no repeated characters, return nil.
// Examples
// firstRepeatedCharacter(string: "Hello") == "e"
// firstRepeatedCharacter(string: "abcdcba") == "d"
// firstRepeatedCharacter(string: "kittens") == "i"
// firstRepeatedCharacter(string: "orange") == "o"
func firstRepeatedCharacter(string: String) -> String? {
    for char in string {
        if string.count(char) > 1 {
            return String(char)
        }
    }
    return nil
}

// -----------------------------------------------------------------------------
// 7. Write a function that takes a string and returns the first repeated
// character in the string. If there are no repeated characters, return nil.
// Examples
// firstRepeatedCharacter(string: "Hello") == "e
return string.length % 2 == 1 // value of type 'String' has no member 'length'
if string.count(char) == 1 { // cannot call value of non-function type 'Int'
if string.count(char) > 1 { // cannot call value of non-function type 'Int'

func primeLength(string: String) -> Bool {
    return Int(string.length).isPrime
}
```swift
// Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// primeLength(string: "Hello") == true
// primeLength(string: "abcdcba") == true
// primeLength(string: "kittens") == true
// primeLength(string: "orange") == false
func primeLength(string: String) -> Bool {
    return Int(string.length).isPrime
}

// -----------------------------------------------------------------------------
// 10. Write a function that takes a string and returns the number of vowels
//     in the string.
//     Examples
//     vowels(string: "apple") == 2
//     vowels(string: "banana") == 3
//     vowels(string: "kiwi") == 0
//     vowels(string: "mango") == 3
//     vowels(string: "orange") == 4
//     vowels(string: "strawberry") == 6
//     vowels(string: "watermelon") == 8
//     vowels(string: "peach") == 2
//     vowels(string: "pear") == 1
//     vowels(string: "blueberry") == 5
//     vowels(string: "raspberry") == 4
//     vowels(string: "cinnamon") == 5
//     vowels(string: "lemon") == 2
//     vowels(string: "grapefruit") == 5
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi") == 0
//     vowels(string: "kiwi
return Int(string.length).isPrime // value of type 'String' has no member 'length'
return Int(string.length).isPrime // reference to member 'isPrime' cannot be resolved without a contextual type

func primeLength(string: String) -> Bool {
    return Int(string.length) % 2 == 1
}
```swift
// Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// primeLength(string: "Hello") == true
// primeLength(string: "abcdcba") == true
// primeLength(string: "kittens") == true
// primeLength(string: "orange") == false
func primeLength(string: String) -> Bool {
    return Int(string.length) % 2 == 1
}

// -----------------------------------------------------------------------------
// 1. Write a function that takes a string and returns the number of times
// the letter "a" appears in it.
// Examples
// countA(string: "Hello") == 1
// countA(string: "Hello, World!") == 2
// countA(string: "apple") == 1
// countA(string: "banana") == 3
// countA(string: "orange") == 1
// countA(string: "kiwi") == 0
// countA(string: "") == 0
// countA(string: "A") == 1
// countA(string: "a") == 1
// countA(string: "aa") == 2
// countA(string: "aaa") == 3
// countA(string: "aaaa") == 4
// countA(string: "aaaaa") == 5
// countA(string: "aaaaaa") == 6
// countA(string: "aaaaaaa") == 7
// countA(string: "aaaaaaaa") == 8
// countA(string: "aaaaaaaaa") == 9
// countA(string: "aaaaaaaaaa") == 10
// countA(string: "aaaaaaaaaaa") == 11
// countA(string: "aaaaaaaaaaaa") == 12
// countA(string: "aaaaaaaaaaaaa") == 13
// countA(string: "aaaaaaaaaaaaaa") == 14
// countA(string: "aaaaaaaaaaaaaaa") == 15
// countA(string: "aaaaaaaaaaaaaaaa") == 16
// countA(string: "aaaaaaaaaaaaaaaaa") == 17
// countA(string: "aaaaaaaaaaaaaaaaaa") == 18
// countA(string: "aaaaaaaaaaaaaaaaaaa") == 19
// countA(string: "aaaaaaaaaaaaaaaaaaaa") == 20
// countA(string: "aaaaaaaaaaaaaaaaaaaaa") == 21
// countA(string: "aaaaaaaaaaaaaaaaaaaaaa") == 22
// countA(string: "aaaaaaaaaaaaaaaaaaaaaaa") == 23
// countA(string: "aaaaaaaaaaaaaaaaaaaaaaaa") == 24
// countA(string: "aaaaaaaaaaaaaaaaaaaaaaaaa") == 25
// countA(string: "aaaaaaaaaaaaaaaaaaaaaaaaaa") == 26
// countA(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaa") == 27
// countA(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 28
// countA(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 29
// countA(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 30
// countA(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 31
// countA(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 32
// countA(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 33
// countA(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 34
// countA(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 35
// countA(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 36
// countA(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 37
// countA(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 38
// countA(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 39
// countA(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 40
// countA(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 41
// countA(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") == 42
// countA(string: "
return Int(string.length) % 2 == 1 // value of type 'String' has no member 'length'

func primeLength(string: String) -> Bool {
    return string.length % 2 == 1
}

func containsVowel(string: String) -> Bool {
    return string.contains("aeiou")
}

func containsOnlyLetters(string: String) -> Bool {
    return string.isLetter
}

func containsOnlyLettersAndNumbers(string: String) -> Bool {
    return string.isLetterOrNumber
}

func containsOnlyLettersNumbersAndSpaces(string: String) -> Bool {
    return string.isLetterOrNumberOrSpace
}

func containsOnlyLettersNumbersAndSpaces(string: String) -> Bool {
    return string.isLetterOrNumberOrSpaceOrSpace
}
```swift
// Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// primeLength(string: "Hello") == true
// primeLength(string: "abcdcba") == true
// primeLength(string: "kittens") == true
// primeLength(string: "orange") == false
func primeLength(string: String) -> Bool {
    return string.length % 2 == 1
}

// -----------------------------------------------------------------------------
// 2. Write a function that takes a string and returns true if the string
// contains at least one vowel or false otherwise
// Examples
// containsVowel(string: "Hello") == true
// containsVowel(string: "abcdcba") == true
// containsVowel(string: "kittens") == true
// containsVowel(string: "orange") == false
func containsVowel(string: String) -> Bool {
    return string.contains("aeiou")
}

// -----------------------------------------------------------------------------
// 3. Write a function that takes a string and returns true if the string
// contains only letters or false otherwise
// Examples
// containsOnlyLetters(string: "Hello") == true
// containsOnlyLetters(string: "abcdcba") == true
// containsOnlyLetters(string: "kittens") == true
// containsOnlyLetters(string: "orange") == false
func containsOnlyLetters(string: String) -> Bool {
    return string.isLetter
}

// -----------------------------------------------------------------------------
// 4. Write a function that takes a string and returns true if the string
// contains only letters and numbers or false otherwise
// Examples
// containsOnlyLettersAndNumbers(string: "Hello") == true
// containsOnlyLettersAndNumbers(string: "abcdcba") == true
// containsOnlyLettersAndNumbers(string: "kittens") == true
// containsOnlyLettersAndNumbers(string: "orange") == false
func containsOnlyLettersAndNumbers(string: String) -> Bool {
    return string.isLetterOrNumber
}

// -----------------------------------------------------------------------------
// 5. Write a function that takes a string and returns true if the string
// contains only letters, numbers, and spaces or false otherwise
// Examples
// containsOnlyLettersNumbersAndSpaces(string: "Hello") == true
// containsOnlyLettersNumbersAndSpaces(string: "abcdcba") == true
// containsOnlyLettersNumbersAndSpaces(string: "kittens") == true
// containsOnlyLettersNumbersAndSpaces(string: "orange") == false
func containsOnlyLettersNumbersAndSpaces(string: String) -> Bool {
    return string.isLetterOrNumberOrSpace
}

// -----------------------------------------------------------------------------
// 6. Write a function that takes a string and returns true if the string
// contains only letters, numbers, and spaces, or numbers and spaces or false otherwise
// Examples
// containsOnlyLettersNumbersAndSpaces(string: "Hello") == true
// containsOnlyLettersNumbersAndSpaces(string: "abcdcba") == true
// containsOnlyLettersNumbersAndSpaces(string: "kittens") == true
// containsOnlyLettersNumbersAndSpaces(string: "orange") == false
func containsOnlyLettersNumbersAndSpaces(string: String) -> Bool {
    return string.isLetterOrNumberOrSpaceOrSpace
}

// -----------------------------------------------------------------------------
// 7. Write a function that takes a string and returns true if the string
// contains only letters, numbers, and spaces, or numbers and spaces, or
// numbers and spaces and numbers or false otherwise
// Examples
// containsOnlyLettersNumbersAndSpaces(string: "Hello") == true
// containsOnlyLettersNumbersAndSpaces(string: "abcdcba") == true
// containsOnlyLettersNumbersAndSpaces(string: "kittens") == true
// containsOnlyLettersNumbersAndSpaces(string: "orange") == false
func containsOnlyLettersNumbersAndSpaces(
return string.length % 2 == 1 // value of type 'String' has no member 'length'
return string.isLetter // value of type 'String' has no member 'isLetter'
return string.isLetterOrNumber // value of type 'String' has no member 'isLetterOrNumber'
return string.isLetterOrNumberOrSpace // value of type 'String' has no member 'isLetterOrNumberOrSpace'
func containsOnlyLettersNumbersAndSpaces(string: String) -> Bool { // invalid redeclaration of 'containsOnlyLettersNumbersAndSpaces(string:)'
return string.isLetterOrNumberOrSpaceOrSpace // value of type 'String' has no member 'isLetterOrNumberOrSpaceOrSpace'

func primeLength(string: String) -> Bool {
    return Int(string.length).isPrime()
}
```swift
// Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// primeLength(string: "Hello") == true
// primeLength(string: "abcdcba") == true
// primeLength(string: "kittens") == true
// primeLength(string: "orange") == false
func primeLength(string: String) -> Bool {
    return Int(string.length).isPrime()
}

// -----------------------------------------------------------------------------
// 11. Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// primeLength(string: "Hello") == true
// primeLength(string: "abcdcba") == true
// primeLength(string: "kittens") == true
// primeLength(string: "orange") == false
func primeLength(string: String) -> Bool {
    return Int(string.length).isPrime()
}

// -----------------------------------------------------------------------------
// 12. Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// primeLength(string: "Hello") == true
// primeLength(string: "abcdcba") == true
// primeLength(string: "kittens") == true
// primeLength(string: "orange") == false
func primeLength(string: String) -> Bool {
    return Int(string.length).isPrime()
}

// -----------------------------------------------------------------------------
// 13. Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// primeLength(string: "Hello") == true
// primeLength(string: "abcdcba") == true
// primeLength(string: "kittens") == true
// primeLength(string: "orange") == false
func primeLength(string: String) -> Bool {
    return Int(string.length).isPrime()
}

// -----------------------------------------------------------------------------
// 14. Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// primeLength(string: "Hello") == true
// primeLength(string: "abcdcba") == true
// primeLength(string: "kittens") == true
// primeLength(string: "orange") == false
func primeLength(string: String) -> Bool {
    return Int(string.length).isPrime()
}

// -----------------------------------------------------------------------------
// 15. Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// primeLength(string: "Hello") == true
// primeLength(string: "abcdcba") == true
// primeLength(string: "kittens") == true
// primeLength(string: "orange") == false
func primeLength(string: String) -> Bool {
    return Int(string.length).isPrime()
}

// -----------------------------------------------------------------------------
// 16. Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// primeLength(string: "Hello") == true
// primeLength(string: "abcdcba") == true
// primeLength(string: "kittens") == true
// primeLength(string: "orange") == false
func primeLength(string: String) -> Bool {
    return Int(string.length).isPrime()
}

// -----------------------------------------------------------------------------
// 17. Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// primeLength(string: "Hello") == true
// primeLength(string: "abcdcba") == true
// primeLength(string: "kittens") == true
// primeLength(string: "orange") == false
func primeLength(string: String) -> Bool {
    
return Int(string.length).isPrime() // value of type 'String' has no member 'length'
return Int(string.length).isPrime() // reference to member 'isPrime' cannot be resolved without a contextual type

func primeLength(string: String) -> Bool {
    return Int(string.length).isPrime
}
```swift
// Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// primeLength(string: "Hello") == true
// primeLength(string: "abcdcba") == true
// primeLength(string: "kittens") == true
// primeLength(string: "orange") == false
func primeLength(string: String) -> Bool {
    return Int(string.length).isPrime
}

// -----------------------------------------------------------------------------
// 1.1.10
// Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// primeLength(string: "Hello") == true
// primeLength(string: "abcdcba") == true
// primeLength(string: "kittens") == true
// primeLength(string: "orange") == false
func primeLength(string: String) -> Bool {
    return Int(string.length).isPrime
}

// -----------------------------------------------------------------------------
// 1.1.11
// Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// primeLength(string: "Hello") == true
// primeLength(string: "abcdcba") == true
// primeLength(string: "kittens") == true
// primeLength(string: "orange") == false
func primeLength(string: String) -> Bool {
    return Int(string.length).isPrime
}

// -----------------------------------------------------------------------------
// 1.1.12
// Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// primeLength(string: "Hello") == true
// primeLength(string: "abcdcba") == true
// primeLength(string: "kittens") == true
// primeLength(string: "orange") == false
func primeLength(string: String) -> Bool {
    return Int(string.length).isPrime
}

// -----------------------------------------------------------------------------
// 1.1.13
// Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// primeLength(string: "Hello") == true
// primeLength(string: "abcdcba") == true
// primeLength(string: "kittens") == true
// primeLength(string: "orange") == false
func primeLength(string: String) -> Bool {
    return Int(string.length).isPrime
}

// -----------------------------------------------------------------------------
// 1.1.14
// Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// primeLength(string: "Hello") == true
// primeLength(string: "abcdcba") == true
// primeLength(string: "kittens") == true
// primeLength(string: "orange") == false
func primeLength(string: String) -> Bool {
    return Int(string.length).isPrime
}

// -----------------------------------------------------------------------------
// 1.1.15
// Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// primeLength(string: "Hello") == true
// primeLength(string: "abcdcba") == true
// primeLength(string: "kittens") == true
// primeLength(string: "orange") == false
func primeLength(string: String) -> Bool {
    return Int(string.length).isPrime
}

// -----------------------------------------------------------------------------
// 1.1.16
// Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// primeLength(string: "Hello") == true
// primeLength(string: "abcdcba") == true
// primeLength(string: "kittens") == true
return Int(string.length).isPrime // value of type 'String' has no member 'length'
return Int(string.length).isPrime // reference to member 'isPrime' cannot be resolved without a contextual type

func primeLength(string: String) -> Bool {
    return Int(string.length).isPrime()
}
```swift
// Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// primeLength(string: "Hello") == true
// primeLength(string: "abcdcba") == true
// primeLength(string: "kittens") == true
// primeLength(string: "orange") == false
func primeLength(string: String) -> Bool {
    return Int(string.length).isPrime()
}

// -----------------------------------------------------------------------------
// 10. Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// primeLength(string: "Hello") == true
// primeLength(string: "abcdcba") == true
// primeLength(string: "kittens") == true
// primeLength(string: "orange") == false
func primeLength(string: String) -> Bool {
    return Int(string.length).isPrime()
}

// -----------------------------------------------------------------------------
// 11. Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// primeLength(string: "Hello") == true
// primeLength(string: "abcdcba") == true
// primeLength(string: "kittens") == true
// primeLength(string: "orange") == false
func primeLength(string: String) -> Bool {
    return Int(string.length).isPrime()
}

// -----------------------------------------------------------------------------
// 12. Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// primeLength(string: "Hello") == true
// primeLength(string: "abcdcba") == true
// primeLength(string: "kittens") == true
// primeLength(string: "orange") == false
func primeLength(string: String) -> Bool {
    return Int(string.length).isPrime()
}

// -----------------------------------------------------------------------------
// 13. Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// primeLength(string: "Hello") == true
// primeLength(string: "abcdcba") == true
// primeLength(string: "kittens") == true
// primeLength(string: "orange") == false
func primeLength(string: String) -> Bool {
    return Int(string.length).isPrime()
}

// -----------------------------------------------------------------------------
// 14. Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// primeLength(string: "Hello") == true
// primeLength(string: "abcdcba") == true
// primeLength(string: "kittens") == true
// primeLength(string: "orange") == false
func primeLength(string: String) -> Bool {
    return Int(string.length).isPrime()
}

// -----------------------------------------------------------------------------
// 15. Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// primeLength(string: "Hello") == true
// primeLength(string: "abcdcba") == true
// primeLength(string: "kittens") == true
// primeLength(string: "orange") == false
func primeLength(string: String) -> Bool {
    return Int(string.length).isPrime()
}

// -----------------------------------------------------------------------------
// 16. Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// primeLength(string: "Hello") == true
// primeLength(string: "abcdcba") == true
// primeLength(string: "kittens") == true
// primeLength(string: "orange") == false
func primeLength(string: String) -> Bool {
    
return Int(string.length).isPrime() // value of type 'String' has no member 'length'
return Int(string.length).isPrime() // reference to member 'isPrime' cannot be resolved without a contextual type

func primeLength(string: String) -> Bool {
    if string.count % 2 == 0 {
        return false
    }
    for i in 3...Int(sqrt(string.count)) {
        if string.count % i == 0 {
            return false
        }
    }
    return true
}
```swift
// Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// primeLength(string: "Hello") == true
// primeLength(string: "abcdcba") == true
// primeLength(string: "kittens") == true
// primeLength(string: "orange") == false
func primeLength(string: String) -> Bool {
    if string.count % 2 == 0 {
        return false
    }
    for i in 3...Int(sqrt(string.count)) {
        if string.count % i == 0 {
            return false
        }
    }
    return true
}

// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ---------------------------------------------------------------------------
for i in 3...Int(sqrt(string.count)) { // no exact matches in call to global function 'sqrt'

func primeLength(string: String) -> Bool {
    if string.count == 1 {
        return true
    }
    for i in 2...(string.count / 2) {
        if string.count % i == 0 {
            return false
        }
    }
    return true
}
```swift
// Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// primeLength(string: "Hello") == true
// primeLength(string: "abcdcba") == true
// primeLength(string: "kittens") == true
// primeLength(string: "orange") == false
func primeLength(string: String) -> Bool {
    if string.count == 1 {
        return true
    }
    for i in 2...(string.count / 2) {
        if string.count % i == 0 {
            return false
        }
    }
    return true
}

// 2. Write a function that takes a string and returns the first character
// that is not repeated anywhere in the string.
// Examples
// firstNonRepeatedCharacter(string: "abcdcaf") == "b"
// firstNonRepeatedCharacter(string: "abcd") == "a"
// firstNonRepeatedCharacter(string: "aabbcc") == "c"
// firstNonRepeatedCharacter(string: "aabbc") == "d"
// firstNonRepeatedCharacter(string: "aabbcde") == "e"
// firstNonRepeatedCharacter(string: "aabbcdef") == "f"
// firstNonRepeatedCharacter(string: "aabbcdefg") == "g"
// firstNonRepeatedCharacter(string: "aabbcdefgh") == "h"
// firstNonRepeatedCharacter(string: "aabbcdefghi") == "i"
// firstNonRepeatedCharacter(string: "aabbcdefghij") == "j"
// firstNonRepeatedCharacter(string: "aabbcdefghijk") == "k"
// firstNonRepeatedCharacter(string: "aabbcdefghijkl") == "l"
// firstNonRepeatedCharacter(string: "aabbcdefghijklm") == "m"
// firstNonRepeatedCharacter(string: "aabbcdefghijklmn") == "n"
// firstNonRepeatedCharacter(string: "aabbcdefghijklmno") == "o"
// firstNonRepeatedCharacter(string: "aabbcdefghijklmnoq") == "q"
// firstNonRepeatedCharacter(string: "aabbcdefghijklmnoqr") == "r"
// firstNonRepeatedCharacter(string: "aabbcdefghijklmnoqrs") == "s"
// firstNonRepeatedCharacter(string: "aabbcdefghijklmnoqrsx") == "x"
// firstNonRepeatedCharacter(string: "aabbcdefghijklmnoqrsxt") == "t"
// firstNonRepeatedCharacter(string: "aabbcdefghijklmnoqrsxty") == "y"
// firstNonRepeatedCharacter(string: "aabbcdefghijklmnoqrsxtyz") == "z"
// firstNonRepeatedCharacter(string: "aabbcdefghijklmnoqrsxtyzw") == "w"
// firstNonRepeatedCharacter(string: "aabbcdefghijklmnoqrsxtyzwv") == "v"
// firstNonRepeatedCharacter(string: "aabbcdefghijklmnoqrsxtyzwvu") == "u"
// firstNonRepeatedCharacter(string: "aabbcdefghijklmnoqrsxtyzwvut") == "t"
// firstNonRepeatedCharacter(string: "aabbcdefghijklmnoqrsxtyzwvuti") == "i"
// firstNonRepeatedCharacter(string: "aabbcdefghijklmnoqrsxtyzwvutin") == "n"
// firstNonRepeatedCharacter(string: "aabbcdefghijklmnoqrsxtyzwvutinm") == "m"
// firstNonRepeatedCharacter(string: "aabbcdefghijklmnoqrsxtyzwvutinmz") == "z"
// firstNonRepeatedCharacter(string: "aabbcdefghijklmnoqrsxtyzwvutinmzp") == "p"
// firstNonRepeatedCharacter(string: "aabbcdefghijklmnoqrsxtyzwvutinmzpq") == "q"
// firstNonRepeatedCharacter(string: "aabbcdefghijklmnoqrsxtyzwvutinmzpqr") == "r"
// firstNonRepeatedCharacter(string: "aabbcdef
 // Fatal error: Range requires lowerBound <= upperBound

func startsOneEnds(n: Int) -> Int {
    var count = 0
    for i in 1...n {
        if i.isOneDigit() {
            count += 1
        }
    }
    return count
}

func divisibleBy11(n: Int) -> Int {
    var count = 0
    for i in 1...n {
        if i % 11 == 0 {
            count += 1
        }
    }
    return count
}

func divisibleBy13(n: Int) -> Int {
    var count = 0
    for i in 1...n {
        if i % 13 == 0 {
            count += 1
        }
    }
    return count
}

func divisibleBy17(n: Int) -> Int {
    var count = 0
    for i in 1...n {
        if i % 17 == 0 {
            count += 1
        }
    }
    return count
}

func divisibleBy19(n: Int) -> Int {
    var count = 0
    for i in 1...n {
        if i % 19 == 0 {
            count += 1
        }
    }
    return count
}

func divisibleBy23(n: Int) -> Int {
    var count = 0
    for i in 1...n {
        if i % 23 == 0 {
            count += 1
        }
    }
    return count
}
```swift
// Given a positive integer n, return the count of the numbers of n-digit
// positive integers that start or end with 1.
func startsOneEnds(n: Int) -> Int {
    var count = 0
    for i in 1...n {
        if i.isOneDigit() {
            count += 1
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// 1.2.1
// -----------------------------------------------------------------------------

// Given a positive integer n, return the count of the numbers of n-digit
// positive integers that are divisible by 11.
func divisibleBy11(n: Int) -> Int {
    var count = 0
    for i in 1...n {
        if i % 11 == 0 {
            count += 1
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// 1.3.1
// -----------------------------------------------------------------------------

// Given a positive integer n, return the count of the numbers of n-digit
// positive integers that are divisible by 13.
func divisibleBy13(n: Int) -> Int {
    var count = 0
    for i in 1...n {
        if i % 13 == 0 {
            count += 1
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// 1.4.1
// -----------------------------------------------------------------------------

// Given a positive integer n, return the count of the numbers of n-digit
// positive integers that are divisible by 17.
func divisibleBy17(n: Int) -> Int {
    var count = 0
    for i in 1...n {
        if i % 17 == 0 {
            count += 1
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// 1.5.1
// -----------------------------------------------------------------------------

// Given a positive integer n, return the count of the numbers of n-digit
// positive integers that are divisible by 19.
func divisibleBy19(n: Int) -> Int {
    var count = 0
    for i in 1...n {
        if i % 19 == 0 {
            count += 1
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// 1.6.1
// -----------------------------------------------------------------------------

// Given a positive integer n, return the count of the numbers of n-digit
// positive integers that are divisible by 23.
func divisibleBy23(n: Int) -> Int {
    var count = 0
    for i in 1...n {
        if i % 23 == 0 {
            count += 1
        }
    }
    return count
}

// -----------------------------------------------------------------------------
// 1.7.1
// -----------------------------------------------------------------------------

// Given a positive integer n, return the count of the numbers of n-digit
// positive integers that are divisible by 29.
func divisibleBy29(n: Int) -> Int {
    var count = 0
    for i in 1...n {
        if i % 29 == 0 {
            count += 1
        }
    }
    return count
if i.isOneDigit() { // value of type 'Int' has no member 'isOneDigit'

func startsOneEnds(n: Int) -> Int {
    return n == 1 ? 1 : 1 + startsOneEnds(n - 1)
}

func divisibleBySeven(n: Int) -> Int {
    return n == 1 ? 1 : 1 + divisibleBySeven(n - 1)
}

func divisibleByEleven(n: Int) -> Int {
    return n == 1 ? 1 : 1 + divisibleByEleven(n - 1)
}

func divisibleByThirteen(n: Int) -> Int {
    return n == 1 ? 1 : 1 + divisibleByThirteen(n - 1)
}

func divisibleBySeventeen(n: Int) -> Int {
    return n == 1 ? 1 : 1 + divisibleBySeventeen(n - 1)
}

func divisibleByNineteen(n: Int) -> Int {
    return n == 1 ? 1 : 1 + divisibleByNineteen(n - 1)
}

func divisibleByTwentyThree(n: Int) -> Int {
    return n == 1 ? 1 : 1 + divisibleByTwentyThree(n - 1)
}

func divisibleByTwentyNine(n: Int) -> Int {
    return n == 1 ? 1 : 1 + divisibleByTwentyNine(n - 1)
}

func divisibleByThirtyOne(n: Int) -> Int {
    return n == 1 ? 1 : 1 + divisibleByThirtyOne(n - 1)
}

func di