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 {
    // TODO: implement
}
```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 {
    // TODO: implement
}
```
} // missing return in global function expected to return 'Bool'

func hasCloseElements(numbers: [Double], threshold: Double) -> Bool {
    // ...
}
```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 {
    // ...
}
```
} // missing return in global function expected to return 'Bool'

func hasCloseElements(numbers: [Double], threshold: Double) -> Bool {
    // ...
}
```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 {
    // ...
}
```
} // missing return in global function expected to return 'Bool'

func hasCloseElements(numbers: [Double], threshold: Double) -> Bool {
    // ...
}
```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 {
    // ...
}
```
} // missing return in global function expected to return 'Bool'

func hasCloseElements(numbers: [Double], threshold: Double) -> Bool {
    // ...
}
```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 {
    // ...
}
```
} // missing return in global function expected to return 'Bool'

func hasCloseElements(numbers: [Double], threshold: Double) -> Bool {
    // ...
}
```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 {
    // ...
}
```
} // missing return in global function expected to return 'Bool'

func hasCloseElements(numbers: [Double], threshold: Double) -> Bool {
    // Write your code here
}
```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 {
    // Write your code here
}
```
} // missing return in global function expected to return 'Bool'

func hasCloseElements(numbers: [Double], threshold: Double) -> Bool {
    // ...
}
```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 {
    // ...
}
```
} // missing return in global function expected to return 'Bool'

func hasCloseElements(numbers: [Double], threshold: Double) -> Bool {
    // ...
}
```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 {
    // ...
}
```
} // missing return in global function expected to return 'Bool'

func hasCloseElements(numbers: [Double], threshold: Double) -> Bool {
    // TODO: implement
    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 {
    // TODO: implement
    return false
}
```
 // XCTAssertTrue failed

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

import Foundation
```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 currentString = ""
    var openCount = 0
    for char in parenString {
        if char == " " { continue }
        if char == "(" {
            openCount += 1
            currentString += char
        } else if char == ")" {
            openCount -= 1
            currentString += char
            if openCount == 0 {
                result.append(currentString)
                currentString = ""
            }
        }
    }
    return result
}

separateParenGroups(parenString: "( ) (( )) (( )( ))")

//: [Next](@next)<|endoftext|>//: [Previous](@previous)

import Foundation

//: ## Challenge 1
//:
//: Create a function that takes a string as input and returns a string with the characters in reverse order.
//:
//: ```
currentString += char // cannot convert value of type 'Character' to expected argument type 'String'
currentString += char // cannot convert value of type 'Character' to expected argument type 'String'

func separateParenGroups(parenString: String) -> [String] {
    var result: [String] = []
    var currentGroup: String = ""
    var openCount: Int = 0

    for char in parenString {
        if char == " " {
            continue
        }

        if char == "(" {
            openCount += 1
        } else if char == ")" {
            openCount -= 1
        }

        currentGroup.append(char)

        if openCount == 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: String = ""
    var openCount: Int = 0

    for char in parenString {
        if char == " " {
            continue
        }

        if char == "(" {
            openCount += 1
        } else if char == ")" {
            openCount -= 1
        }

        currentGroup.append(char)

        if openCount == 0 {
            result.append(currentGroup)
            currentGroup = ""
        }
    }

    return result
}

print(separateParenGroups(parenString: "( ) (( )) (( )( ))"))
// Output: ["()", "(())", "(()())"]
```

func separateParenGroups(parenString: String) -> [String] {
    var parenString = parenString.replacingOccurrences(of: " ", with: "")
    var result: [String] = []
    var currentGroup = ""
    var openParenCount = 0
    var closeParenCount = 0
    for char in parenString {
        if char == "(" {
            openParenCount += 1
        } else if char == ")" {
            closeParenCount += 1
        }
        currentGroup.append(char)
        if openParenCount == closeParenCount {
            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 parenString = parenString.replacingOccurrences(of: " ", with: "")
    var result: [String] = []
    var currentGroup = ""
    var openParenCount = 0
    var closeParenCount = 0
    for char in parenString {
        if char == "(" {
            openParenCount += 1
        } else if char == ")" {
            closeParenCount += 1
        }
        currentGroup.append(char)
        if openParenCount == closeParenCount {
            result.append(currentGroup)
            currentGroup = ""
        }
    }
    return result
}

print(separateParenGroups(parenString: "( ) (( )) (( )( ))"))
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenSt
var parenString = parenString.replacingOccurrences(of: " ", with: "") // variable 'parenString' was never mutated; consider changing to 'let' constant

func separateParenGroups(parenString: String) -> [String] {
    var result: [String] = []
    var currentGroup = ""
    var openParenCount = 0
    for char in parenString {
        if char == "(" {
            openParenCount += 1
            currentGroup.append(char)
        } else if char == ")" {
            openParenCount -= 1
            currentGroup.append(char)
            if openParenCount == 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 openParenCount = 0
    for char in parenString {
        if char == "(" {
            openParenCount += 1
            currentGroup.append(char)
        } else if char == ")" {
            openParenCount -= 1
            currentGroup.append(char)
            if openParenCount == 0 {
                result.append(currentGroup)
                currentGroup = ""
            }
        }
    }
    return result
}

print(separateParenGroups(parenString: "( ) (( )) (( )( ))"))
```

func separateParenGroups(parenString: String) -> [String] {
    var result: [String] = []
    var currentString = ""
    var openParenCount = 0
    for char in parenString {
        if char == " " {
            continue
        }
        if char == "(" {
            openParenCount += 1
        } else if char == ")" {
            openParenCount -= 1
        }
        currentString += String(char)
        if openParenCount == 0 {
            result.append(currentString)
            currentString = ""
        }
    }
    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 currentString = ""
    var openParenCount = 0
    for char in parenString {
        if char == " " {
            continue
        }
        if char == "(" {
            openParenCount += 1
        } else if char == ")" {
            openParenCount -= 1
        }
        currentString += String(char)
        if openParenCount == 0 {
            result.append(currentString)
            currentString = ""
        }
    }
    return result
}

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

func separateParenGroups(parenString: String) -> [String] {
    var result: [String] = []
    var currentString = ""
    var openParenCount = 0

    for char in parenString {
        if char == " " {
            continue
        }

        if char == "(" {
            openParenCount += 1
        } else if char == ")" {
            openParenCount -= 1
        }

        currentString.append(char)

        if openParenCount == 0 {
            result.append(currentString)
            currentString = ""
        }
    }

    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 currentString = ""
    var openParenCount = 0

    for char in parenString {
        if char == " " {
            continue
        }

        if char == "(" {
            openParenCount += 1
        } else if char == ")" {
            openParenCount -= 1
        }

        currentString.append(char)

        if openParenCount == 0 {
            result.append(currentString)
            currentString = ""
        }
    }

    return result
}

// Example usage
let parenString = "( ) (( )) (( )( ))"
let separatedGroups = separateParenGroups(parenString: parenString)
print(separatedGroups) // Output: ["()", "(())", "(()())"]
```

func separateParenGroups(parenString: String) -> [String] {
    var result: [String] = []
    var currentString = ""
    var openParenCount = 0

    for char in parenString {
        if char == " " {
            continue
        }

        if char == "(" {
            openParenCount += 1
        } else if char == ")" {
            openParenCount -= 1
        }

        currentString.append(char)

        if openParenCount == 0 {
            result.append(currentString)
            currentString = ""
        }
    }

    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 currentString = ""
    var openParenCount = 0

    for char in parenString {
        if char == " " {
            continue
        }

        if char == "(" {
            openParenCount += 1
        } else if char == ")" {
            openParenCount -= 1
        }

        currentString.append(char)

        if openParenCount == 0 {
            result.append(currentString)
            currentString = ""
        }
    }

    return result
}

// Example usage
let parenString = "( ) (( )) (( )( ))"
let separatedGroups = separateParenGroups(parenString: parenString)
print(separatedGroups) // Output: ["()", "(())", "(()())"]

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

func separateParenGroups(parenString: String) -> [String] {
    var result: [String] = []
    var currentGroup: String = ""
    var openParenCount: Int = 0

    for char in parenString {
        if char == "(" {
            openParenCount += 1
            currentGroup.append(char)
        } else if char == ")" {
            openParenCount -= 1
            currentGroup.append(char)
            if openParenCount == 0 {
                result.append(currentGroup)
                currentGroup = ""
            }
        }
    }

    return result
}

import Foundation
```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 = ""
    var openParenCount: Int = 0

    for char in parenString {
        if char == "(" {
            openParenCount += 1
            currentGroup.append(char)
        } else if char == ")" {
            openParenCount -= 1
            currentGroup.append(char)
            if openParenCount == 0 {
                result.append(currentGroup)
                currentGroup = ""
            }
        }
    }

    return result
}

print(separateParenGroups(parenString: "( ) (( )) (( )( ))"))

//: [Next](@next)<|endoftext|>//: [Previous](@previous)

import Foundation

//: ## Challenge 1
//:
//: Create a function that takes a string as a parameter and returns a dictionary containing the count of each character in the string.
//:
//: ```

func separateParenGroups(parenString: String) -> [String] {
    var result: [String] = []
    var currentString = ""
    var openParenCount = 0
    for char in parenString {
        if char == " " { continue }
        if char == "(" {
            openParenCount += 1
        } else if char == ")" {
            openParenCount -= 1
        }
        currentString += String(char)
        if openParenCount == 0 {
            result.append(currentString)
            currentString = ""
        }
    }
    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 currentString = ""
    var openParenCount = 0
    for char in parenString {
        if char == " " { continue }
        if char == "(" {
            openParenCount += 1
        } else if char == ")" {
            openParenCount -= 1
        }
        currentString += String(char)
        if openParenCount == 0 {
            result.append(currentString)
            currentString = ""
        }
    }
    return result
}

print(separateParenGroups(parenString: "( ) (( )) (( )( ))"))
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])
print(separateParenGroups(parenString: "( ) (( )) (( )( ))") == ["()", "(())", "(()())"])

func separateParenGroups(parenString: String) -> [String] {
    var parenString = parenString.replacingOccurrences(of: " ", with: "")
    var result: [String] = []
    var tempString = ""
    var openParenCount = 0
    var closeParenCount = 0

    for char in parenString {
        tempString += String(char)
        if char == "(" {
            openParenCount += 1
        } else if char == ")" {
            closeParenCount += 1
        }

        if openParenCount == closeParenCount {
            result.append(tempString)
            tempString = ""
        }
    }

    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 parenString = parenString.replacingOccurrences(of: " ", with: "")
    var result: [String] = []
    var tempString = ""
    var openParenCount = 0
    var closeParenCount = 0

    for char in parenString {
        tempString += String(char)
        if char == "(" {
            openParenCount += 1
        } else if char == ")" {
            closeParenCount += 1
        }

        if openParenCount == closeParenCount {
            result.append(tempString)
            tempString = ""
        }
    }

    return result
}

print(separateParenGroups(parenString: "( ) (( )) (( )( ))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(parenString: "() (()) (()(()))"))
print(separateParenGroups(
var parenString = parenString.replacingOccurrences(of: " ", with: "") // variable 'parenString' was never mutated; consider changing to 'let' constant

func truncateNumber(number: Double) -> Double {
    return number.truncatingRemainder(dividingBy: 1)
}

func floorNumber(number: Double) -> Double {
    return number.rounded(.down)
}

func ceilNumber(number: Double) -> Double {
    return number.rounded(.up)
}

func roundNumber(number: Double) -> Double {
    return number.rounded(.toNearestEven)
}

func roundNumber(number: Double, toNearest: Double) -> Double {
    return number.rounded(.toNearestEven)
}

func roundNumber(number: Double, toNearest: Double, rule: Float) -> Double {
    return number.rounded(.toNearestEven)
}

func roundNumber(number: Double, toNearest: Double, rule: Float, mode: Float) -> Double {
    return number.rounded(.toNearestEven)
}

func roundNumber(number: Double, toNearest: Double, rule: Float, mode: Float, precision: Float) -> Double {
    return number.rounded(.toNearestEven)
}

func roundNumber(number: Double, toNearest: Double, rule: Float, mode: Float, precision: Float, roundingMode: Float) -> Double {
    return number.rounded(.toNearestEven)
}

func roundNumber(number: Double, toNearest: Double, rule: Float, mode: Float, precision: Float, roundingMode: Float, roundingDirection: Float) -> Double {
    return number.rounded(.toNearestEven)
}
```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.truncatingRemainder(dividingBy: 1)
}

// 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 floorNumber(number: Double) -> Double {
    return number.rounded(.down)
}

// 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) == 4
func ceilNumber(number: Double) -> Double {
    return number.rounded(.up)
}

// 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) == 4
func roundNumber(number: Double) -> Double {
    return number.rounded(.toNearestEven)
}

// 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) == 4
func roundNumber(number: Double, toNearest: Double) -> Double {
    return number.rounded(.toNearestEven)
}

// 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) == 4
func roundNumber(number: Double, toNearest: Double, rule: Float) -> Double {
    return number.rounded(.toNearestEven)
}

// 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) == 4
func roundNumber(number: Double, toNearest: Double, rule: Float, mode: Float) -> Double {
    return number.rounded(.toNearestEven)
}

// 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) == 4
func roundNumber(number: Double, toNearest: Double, rule: Float, mode: Float, precision: Float) -> Double {
    return number.rounded(.toNearestEven)
}

// 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) == 4
func roundNumber(number: Double, toNearest: Double, rule: Float, mode: Float, precision: Float, roundingMode: Float) -> Double {
    return number.rounded(.toNearestEven)
}

// 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) == 4
func roundNumber(number: Double, toNearest: Double, rule: Float, mode: Float, precision: Float, roundingMode: Float, roundingDirection: Float) -> Double {
    return number.rounded(.toNearestEven)
}

// Given a positive floating point number, it can be decomposed into
return number.rounded(.toNearestEven) // type 'FloatingPointRoundingRule' has no member 'toNearestEven'
return number.rounded(.toNearestEven) // type 'FloatingPointRoundingRule' has no member 'toNearestEven'
return number.rounded(.toNearestEven) // type 'FloatingPointRoundingRule' has no member 'toNearestEven'
return number.rounded(.toNearestEven) // type 'FloatingPointRoundingRule' has no member 'toNearestEven'
return number.rounded(.toNearestEven) // type 'FloatingPointRoundingRule' has no member 'toNearestEven'
return number.rounded(.toNearestEven) // type 'FloatingPointRoundingRule' has no member 'toNearestEven'
return number.rounded(.toNearestEven) // type 'FloatingPointRoundingRule' has no member 'toNearestEven'

func truncateNumber(number: Double) -> Double {
    return 0.0
}
```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 0.0
}
```
 // XCTAssertTrue failed

func truncateNumber(number: Double) -> Double {
    // Write your code here
}
```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 {
    // Write your code here
}
```
} // missing return in global function expected to return 'Double'

func truncateNumber(number: Double) -> Double {
    // Write your code here
}
```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 {
    // Write your code here
}
```
} // missing return in global function expected to return 'Double'

func truncateNumber(number: Double) -> Double {
    return 0.0
}
```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 0.0
}
```
 // XCTAssertTrue failed

func truncateNumber(number: Double) -> Double {
    return 0.0
}
```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 0.0
}
```
 // XCTAssertTrue failed

func truncateNumber(number: Double) -> Double {
    // TODO: Implement
    return 0.0
}
```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 {
    // TODO: Implement
    return 0.0
}
```
 // XCTAssertTrue failed

func truncateNumber(number: Double) -> Double {
    let integerPart = Int(number)
    let decimalPart = number - Double(integerPart)
    return decimalPart
}

func truncateNumber2(number: Double) -> Int {
    let integerPart = Int(number)
    return integerPart
}

func truncateNumber3(number: Double) -> Int {
    let integerPart = Int(number)
    return integerPart
}

func truncateNumber4(number: Double) -> Int {
    let integerPart = Int(number)
    return integerPart
}

func truncateNumber5(number: Double) -> Int {
    let integerPart = Int(number)
    return integerPart
}

func truncateNumber6(number: Double) -> Int {
    let integerPart = Int(number)
    return integerPart
}

func truncateNumber7(number: Double) -> Int {
    let integerPart = Int(number)
    return integerPart
}

func truncateNumber8(number: Double) -> Int {
    let integerPart = Int(number)
    return integerPart
}

func truncateNumber9(number: Double) -> Int {
    let integerPart = Int(number)
    return integerPart
}

func truncateNumber10(number: Double) -> Int {
    let integerPart = Int(number)
    return integerPart
}
```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 {
    let integerPart = Int(number)
    let decimalPart = number - Double(integerPart)
    return decimalPart
}

// 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 truncateNumber2(number: Double) -> Int {
    let integerPart = Int(number)
    return integerPart
}

// 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 truncateNumber3(number: Double) -> Int {
    let integerPart = Int(number)
    return integerPart
}

// 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 truncateNumber4(number: Double) -> Int {
    let integerPart = Int(number)
    return integerPart
}

// 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 truncateNumber5(number: Double) -> Int {
    let integerPart = Int(number)
    return integerPart
}

// 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 truncateNumber6(number: Double) -> Int {
    let integerPart = Int(number)
    return integerPart
}

// 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 truncateNumber7(number: Double) -> Int {
    let integerPart = Int(number)
    return integerPart
}

// 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 truncateNumber8(number: Double) -> Int {
    let integerPart = Int(number)
    return integerPart
}

// 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 truncateNumber9(number: Double) -> Int {
    let integerPart = Int(number)
    return integerPart
}

// 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 truncateNumber10(number: Double) -> Int {
    let integerPart = Int(number)
    return integerPart
}

// 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

func truncateNumber(number: Double) -> Double {
    let integerPart = Int(number)
    let decimalPart = number - Double(integerPart)
    return decimalPart
}

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 {
    let integerPart = Int(number)
    let decimalPart = number - Double(integerPart)
    return decimalPart
}

// 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 decimal part of the number.
// truncateNumber(number: 3.5) == 0.5
func truncateNumber(number: Double) -> Double {
    let integerPart = Int(number)
    let decimalPart = number - Double(integerPart)
    return decimalPart
}

// 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 decimal part of the number.
// truncateNumber(number: 3.5) == 0.5
func truncateNumber(number: Double) -> Double {
    let integerPart = Int(number)
    let decimalPart = number - Double(integerPart)
    return decimalPart
}

// 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 decimal part of the number.
// truncateNumber(number: 3.5) == 0.5
func truncateNumber(number: Double) -> Double {
    let integerPart = Int(number)
    let decimalPart = number - Double(integerPart)
    return decimalPart
}

// 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 decimal part of the number.
// truncateNumber(number: 3.5) == 0.5
func truncateNumber(number: Double) -> Double {
    let integerPart = Int(number)
    let decimalPart = number - Double(integerPart)
    return decimalPart
}

// 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 decimal part of the number.

func truncateNumber(number: Double) -> Double {
    return 0
}
```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 0
}
```
 // XCTAssertTrue failed

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 countWords(_ string: String) -> Int {
    return string.components(separatedBy: " ").count
}

func sumOfEvenNumbers(_ numbers: [Int]) -> Int {
    var sum = 0
    for number in numbers {
        if number % 2 == 0 {
            sum += number
        }
    }
    return sum
}

func largestNumber(_ numbers: [Int]) -> Int {
    var largest = numbers[0]
    for number in numbers {
        if number > largest {
            largest = number
        }
    }
    return largest
}

func smallestNumber(_ numbers: [Int]) -> Int {
    var smallest = numbers[0]
    for number in numbers {
        if number < smallest {
            smallest = number
        }
    }
    return smallest
}

func average(_ numbers: [Int]) -> Double {
    var sum = 0
    for number in numbers {
        sum += number
    }
    return Double(sum) / Double(numbers.count)
}

func median(_ numbers: [Int]) -> Double {
    let sortedNumbers = numbers.sorted()
    let middleIndex = sortedNumbers.count / 2
    if sortedNumbers.count % 2 == 0 {
        return Double(sortedNumbers[middleIndex - 1] + sortedNumbers[middleIndex]) / 2.0
    } else {
        return Double(sortedNumbers[middleIndex])
    }
}

func mode(_ numbers: [Int]) -> Int {
    var countMap = [Int: Int]()
    for number in numbers {
        countMap[number, default: 0] += 1
    }
    var mode = numbers[0]
    var maxCount = countMap[mode]!
    for (number, count) in countMap {
        if count > maxCount {
            mode = number
            maxCount = count
        }
    }
    return mode
}
```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 of words in the string.
// countWords("Hello, world!") == 2
// countWords("The quick brown fox jumps over the lazy dog.") == 9
func countWords(_ string: String) -> Int {
    return string.components(separatedBy: " ").count
}

// 3. Write a function that takes an array of integers and returns the sum of all the even numbers in the array.
// sumOfEvenNumbers([1, 2, 3, 4, 5, 6]) == 12
// sumOfEvenNumbers([1, 3, 5, 7, 9]) == 0
func sumOfEvenNumbers(_ numbers: [Int]) -> Int {
    var sum = 0
    for number in numbers {
        if number % 2 == 0 {
            sum += number
        }
    }
    return sum
}

// 4. Write a function that takes an array of integers and returns the largest number in the array.
// largestNumber([1, 2, 3, 4, 5]) == 5
// largestNumber([1, 3, 5, 7, 9]) == 9
func largestNumber(_ numbers: [Int]) -> Int {
    var largest = numbers[0]
    for number in numbers {
        if number > largest {
            largest = number
        }
    }
    return largest
}

// 5. Write a function that takes an array of integers and returns the smallest number in the array.
// smallestNumber([1, 2, 3, 4, 5]) == 1
// smallestNumber([1, 3, 5, 7, 9]) == 1
func smallestNumber(_ numbers: [Int]) -> Int {
    var smallest = numbers[0]
    for number in numbers {
        if number < smallest {
            smallest = number
        }
    }
    return smallest
}

// 6. Write a function that takes an array of integers and returns the average of all the numbers in the array.
// average([1, 2, 3, 4, 5]) == 3
// average([1, 3, 5, 7, 9]) == 5
func average(_ numbers: [Int]) -> Double {
    var sum = 0
    for number in numbers {
        sum += number
    }
    return Double(sum) / Double(numbers.count)
}

// 7. Write a function that takes an array of integers and returns the median of all the numbers in the array.
// median([1, 2, 3, 4, 5]) == 3
// median([1, 3, 5, 7, 9]) == 5
func median(_ numbers: [Int]) -> Double {
    let sortedNumbers = numbers.sorted()
    let middleIndex = sortedNumbers.count / 2
    if sortedNumbers.count % 2 == 0 {
        return Double(sortedNumbers[middleIndex - 1] + sortedNumbers[middleIndex]) / 2.0
    } else {
        return Double(sortedNumbers[middleIndex])
    }
}

// 8. Write a function that takes an array of integers and returns the mode of all the numbers in the array.
// mode([1, 2, 3, 4, 5]) == 1
// mode([1, 3, 5, 7, 9]) == 1
func mode(_ numbers: [Int]) -> Int {
    var countMap = [Int: Int]()
    for number in numbers {
        countMap[number, default: 0] += 1
    }
    var mode = numbers[0]
    var maxCount = countMap[mode]!
    for (number, count) in countMap {
        if count > maxCount {
            mode = number
            maxCount = count
        }
    }
    return mode
}

// 9. Write a function that takes an array of integers and returns the range of all the numbers in the array.
// range([1, 

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
}
```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
}

print(belowZero(operations: [1, 2, 3])) // false
print(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
}
```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 meanAbsoluteDeviation(numbers: [Double]) -> Double {
    let mean = numbers.reduce(0, +) / Double(numbers.count)
    let deviations = numbers.map { abs($0 - mean) }
    return deviations.reduce(0, +) / Double(deviations.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, +) / Double(numbers.count)
    let deviations = numbers.map { abs($0 - mean) }
    return deviations.reduce(0, +) / Double(deviations.count)
}
```

func meanAbsoluteDeviation(numbers: [Double]) -> Double {
    let mean = numbers.mean()
    let absoluteDifferences = numbers.map { abs($0 - mean) }
    return absoluteDifferences.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 absoluteDifferences = numbers.map { abs($0 - mean) }
    return absoluteDifferences.mean()
}
```
let mean = numbers.mean() // value of type '[Double]' has no member 'mean'

func meanAbsoluteDeviation(numbers: [Double]) -> Double {
    let mean = numbers.reduce(0.0, +) / Double(numbers.count)
    let deviations = numbers.map { abs($0 - mean) }
    return deviations.reduce(0.0, +) / Double(deviations.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, +) / Double(numbers.count)
    let deviations = numbers.map { abs($0 - mean) }
    return deviations.reduce(0.0, +) / Double(deviations.count)
}
```

func meanAbsoluteDeviation(numbers: [Double]) -> Double {
    let mean = numbers.reduce(0.0, +) / Double(numbers.count)
    let absoluteDifferences = numbers.map { abs($0 - mean) }
    return absoluteDifferences.reduce(0.0, +) / Double(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, +) / Double(numbers.count)
    let absoluteDifferences = numbers.map { abs($0 - mean) }
    return absoluteDifferences.reduce(0.0, +) / Double(numbers.count)
}
```

func meanAbsoluteDeviation(numbers: [Double]) -> Double {
    let mean = numbers.reduce(0, +) / Double(numbers.count)
    let deviations = numbers.map { abs($0 - mean) }
    return deviations.reduce(0, +) / Double(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, +) / Double(numbers.count)
    let deviations = numbers.map { abs($0 - mean) }
    return deviations.reduce(0, +) / Double(numbers.count)
}
```

func meanAbsoluteDeviation(numbers: [Double]) -> Double {
    let mean = numbers.reduce(0.0, +) / Double(numbers.count)
    let deviations = numbers.map { abs($0 - mean) }
    return deviations.reduce(0.0, +) / Double(deviations.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, +) / Double(numbers.count)
    let deviations = numbers.map { abs($0 - mean) }
    return deviations.reduce(0.0, +) / Double(deviations.count)
}
```

func meanAbsoluteDeviation(numbers: [Double]) -> Double {
    let mean = numbers.reduce(0.0, +) / Double(numbers.count)
    let absoluteDifferences = numbers.map { abs($0 - mean) }
    return absoluteDifferences.reduce(0.0, +) / Double(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, +) / Double(numbers.count)
    let absoluteDifferences = numbers.map { abs($0 - mean) }
    return absoluteDifferences.reduce(0.0, +) / Double(numbers.count)
}
```

func meanAbsoluteDeviation(numbers: [Double]) -> Double {
    let mean = numbers.reduce(0.0, +) / Double(numbers.count)
    let absoluteDeviations = numbers.map { abs($0 - mean) }
    return absoluteDeviations.reduce(0.0, +) / Double(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, +) / Double(numbers.count)
    let absoluteDeviations = numbers.map { abs($0 - mean) }
    return absoluteDeviations.reduce(0.0, +) / Double(numbers.count)
}
```

func meanAbsoluteDeviation(numbers: [Double]) -> Double {
    let mean = numbers.reduce(0.0, +) / Double(numbers.count)
    let absoluteDifferences = numbers.map { abs($0 - mean) }
    return absoluteDifferences.reduce(0.0, +) / Double(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, +) / Double(numbers.count)
    let absoluteDifferences = numbers.map { abs($0 - mean) }
    return absoluteDifferences.reduce(0.0, +) / Double(numbers.count)
}
```

func meanAbsoluteDeviation(numbers: [Double]) -> Double {
    let mean = numbers.reduce(0.0, +) / Double(numbers.count)
    let deviations = numbers.map { abs($0 - mean) }
    return deviations.reduce(0.0, +) / Double(deviations.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, +) / Double(numbers.count)
    let deviations = numbers.map { abs($0 - mean) }
    return deviations.reduce(0.0, +) / Double(deviations.count)
}
```

func intersperse(numbers: [Int], delimeter: Int) -> [Int] {
    // ...
}
```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] {
    // ...
}
```
} // missing return in global function expected to return '[Int]'

func intersperse(numbers: [Int], delimeter: Int) -> [Int] {
    var result = [Int]()
    for (index, number) in numbers.enumerated() {
        result.append(number)
        if index < numbers.count - 1 {
            result.append(delimeter)
        }
    }
    return result
}

import Foundation

func isEqual(a: Int, b: Int, c: Int) -> Bool {
    return a == b && b == c
}
```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 (index, number) in numbers.enumerated() {
        result.append(number)
        if index < numbers.count - 1 {
            result.append(delimeter)
        }
    }
    return result
}

//: [Next](@next)<|endoftext|>//: [Previous](@previous)

import Foundation

//: # 1.1.1
//: 1.1.1 Write a program that takes three integer command-line arguments and prints equal if all three are equal, and not equal otherwise.

func isEqual(a: Int, b: Int, c: Int) -> Bool {
    return a == b && b == c
}

//: [Next](@next)<|endoftext|>//: [Previous](@previous)

import Foundation

//: # 1.1.19
//: 1.1.19 Run the following program on your computer:
//:
//: ```

func intersperse(numbers: [Int], delimeter: Int) -> [Int] {
    var result: [Int] = []
    for (index, number) in numbers.enumerated() {
        result.append(number)
        if index < numbers.count - 1 {
            result.append(delimeter)
        }
    }
    return result
}

import Foundation
```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 (index, number) in numbers.enumerated() {
        result.append(number)
        if index < numbers.count - 1 {
            result.append(delimeter)
        }
    }
    return result
}

//: [Next](@next)<|endoftext|>//
//  main.swift
//  Swift-Playground
//
//  Created by 周子涵 on 2020/1/11.
//  Copyright © 2020 周子涵. All rights reserved.
//

import Foundation

//: [Previous](@previous)

//: [Next](@next)<|endoftext|>//
//  main.swift
//  Swift-Playground
//
//  Created by 周子涵 on 2020/1/11.
//  Copyright © 2020 周子涵. All rights reserved.
//

import Foundation

//: [Previous](@previous)

//: [Next](@next)<|endoftext|>//
//  main.swift
//  Swift-Playground
//
//  Created by 周子涵 on 2020/1/11.
//  Copyright © 2020 周子涵. All rights reserved.
//

import Foundation

//: [Previous](@previous)

//: [Next](@next)<|endoftext|>//
//  main.swift
//  Swift-Playground
//
//  Created by 周子涵 on 2020/1/11.
//  Copyright © 2020 周子涵. All rights reserved.
//

import Foundation

//: [Previous](@previous)

//: [Next](@next)<|endoftext|>//
//  main.swift
//  Swift-Playground
//
//  Created by 周子涵 on 2020/1/11.
//  Copyright © 2020 周子涵. All rights reserved.
//

import Foundation

//: [Previous](@previous)

//: [Next](@next)<|endoftext|>//
//  main.swift
//  Swift-Playground
//
//  Created by 周子涵 on 2020/1/11.
//  Copyright © 2020 周子涵. All rights reserved.
//

import Foundation

//: [Previous](@previous)

//: [Next](@next)<|endoftext|>//
//  main.swift
//  Swift-Playground
//
//  Created by 周子涵 on 2020/1/11.
//  Copyright © 2020 周子涵. All rights reserved.
//

import Foundation

//: [Previous](@previous)

//: [Next](@next)<|endoftext|>//
//  main.swift
//  Swift-Playground
//
//  Created by 周子涵 on 2020/1/11.
//  Copyright © 2020 周子涵. All rights reserved.
//

import Foundation

//: [Previous](@previous)

//: [Next](@next)<|endoftext|>//
//  main.swift
//  Swift-Playground
//
//  Created by 周子涵 on 2020/1/11.
//  Copyright © 2020 周子涵. All rights reserved.
//

import Foundation

//: [Previous](@previous)

//: [Next](@next)<|endoftext|>//
//  main.swift
//  Swift-Playground
//
//  Created by 周子涵 on 2020/1/11.
//  Copyright © 2020 周子涵. All rights reserved.
//

import Foundation

//: [Previous](@previous)

//: [Next](@next)<|endoftext|>//
//  main.swift
//  Swift-Playground
//
//  Created by 周子涵 on 202

func intersperse(numbers: [Int], delimeter: Int) -> [Int] {
    var result: [Int] = []
    for (index, number) in numbers.enumerated() {
        result.append(number)
        if index != numbers.count - 1 {
            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 (index, number) in numbers.enumerated() {
        result.append(number)
        if index != numbers.count - 1 {
            result.append(delimeter)
        }
    }
    return result
}

//: ### 2.2.1
//: Write a function that takes an array of integers and returns an array of integers where every two consecutive integers have been summed.
//:
//: ```

func intersperse(numbers: [Int], delimeter: Int) -> [Int] {
    var result = [Int]()
    for (index, number) in numbers.enumerated() {
        result.append(number)
        if index < numbers.count - 1 {
            result.append(delimeter)
        }
    }
    return result
}

import Foundation

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

func twoSum(_ nums: [Int], _ target: Int) -> [Int] {
    for (i, num1) in nums.enumerated() {
        for (j, num2) in nums.enumerated() {
            if i != j && num1 + num2 == target {
                return [i, j]
            }
        }
    }
    return []
}

class ListNode {
    var val: Int
    var next: ListNode?
    init(_ val: Int) {
        self.val = val
        self.next = nil
    }
}
```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 (index, number) in numbers.enumerated() {
        result.append(number)
        if index < numbers.count - 1 {
            result.append(delimeter)
        }
    }
    return result
}

//: [Next](@next)<|endoftext|>//: [Previous](@previous)

import Foundation

//: # 2.1
//: ## 2.1.1
//: Write a function that takes a string as input and returns the string reversed.
//:
//: Example:
//: Given s = "hello", return "olleh".

//: ### Solution
//: 1. Convert the string to an array of characters.
//: 2. Reverse the array of characters.
//: 3. Convert the array of characters back to a string.

//: ### Implementation

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

//: ### Test

print(reverseString("hello"))

//: ## 2.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].

//: ### Solution
//: 1. Iterate over the array of integers.
//: 2. For each integer, iterate over the array of integers again.
//: 3. If the sum of the two integers is equal to the target, return the indices of the two integers.

//: ### Implementation

func twoSum(_ nums: [Int], _ target: Int) -> [Int] {
    for (i, num1) in nums.enumerated() {
        for (j, num2) in nums.enumerated() {
            if i != j && num1 + num2 == target {
                return [i, j]
            }
        }
    }
    return []
}

//: ### Test

print(twoSum([2, 7, 11, 15], 9))

//: ## 2.1.3
//: You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.
//:
//: You may assume the two numbers do not contain any leading zero, except the number 0 itself.
//:
//: Example
//: Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
//: Output: 7 -> 0 -> 8
//: Explanation: 342 + 465 = 807.

//: ### Solution
//: 1. Iterate over the two linked lists.
//: 2. For each node, add the value of the node to the value of the node in the other linked list.
//: 3. If the sum is greater than 9, set the carry to 1.
//: 4. Create a new node with the value of the sum.
//: 5. Add the new node to the linked list.

//: ### Implementation

class ListNode {
    var val: Int
    var next: ListNode?
    init(_ val: Int) {
        self.val = val
        self.next = nil
    }
}

func addTwoNumbers(_ l1: ListNode?, _ l2: ListNode?) -> ListNode? {
    var l1 = l1
    var l2 = l2
    var result = ListNode(0)
    var current = result
    var carry = 0
    while l1 != nil || l2 != nil {
        var sum = carry
        if l1 != nil {
            sum += l1!.val
            l1 = l1!.next
        }
        if l2

func intersperse(numbers: [Int], delimeter: Int) -> [Int] {
    var result = [Int]()
    for (index, number) in numbers.enumerated() {
        result.append(number)
        if index < numbers.count - 1 {
            result.append(delimeter)
        }
    }
    return result
}

import Foundation

func areEqual(numbers: [Int]) -> String {
    if numbers.count == 0 {
        return "empty"
    }

    var equal = true
    var previous = numbers[0]
    for number in numbers {
        if number != previous {
            equal = false
            break
        }
        previous = number
    }

    if equal {
        return "equal"
    } else {
        return "not equal"
    }
}

func transpose(matrix: [[Int]]) -> [[Int]] {
    var result = [[Int]](repeating: [Int](), count: matrix[0].count)
    for row in matrix {
        for (index, element) in row.enumerated() {
            result[index].append(element)
        }
    }
    return result
}

func printBooleanMatrix(matrix: [[Bool]]) {
    for (rowIndex, row) in matrix.enumerated() {
        print(rowIndex, terminator: " ")
        for element in row {
            if element {
                print("*", terminator: " ")
            } else {
                print(" ", terminator: " ")
            }
        }
        print()
    }
}
```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 (index, number) in numbers.enumerated() {
        result.append(number)
        if index < numbers.count - 1 {
            result.append(delimeter)
        }
    }
    return result
}

//: [Next](@next)<|endoftext|>//: [Previous](@previous)

import Foundation

//: # 1.1.1
//: Write a program that takes three integer command-line arguments and prints `equal` if all three are equal, and `not equal` otherwise.

func areEqual(numbers: [Int]) -> String {
    if numbers.count == 0 {
        return "empty"
    }

    var equal = true
    var previous = numbers[0]
    for number in numbers {
        if number != previous {
            equal = false
            break
        }
        previous = number
    }

    if equal {
        return "equal"
    } else {
        return "not equal"
    }
}

//: [Next](@next)<|endoftext|>//: [Previous](@previous)

import Foundation

//: # 1.1.13
//: Write a code fragment to print the transposition (rows and columns changed) of a two-dimensional array with M rows and N columns.

func transpose(matrix: [[Int]]) -> [[Int]] {
    var result = [[Int]](repeating: [Int](), count: matrix[0].count)
    for row in matrix {
        for (index, element) in row.enumerated() {
            result[index].append(element)
        }
    }
    return result
}

//: [Next](@next)<|endoftext|>//: [Previous](@previous)

import Foundation

//: # 1.1.11
//: Write a code fragment that prints the contents of a two-dimensional boolean array, using * to represent `true` and a space to represent `false`. Include row and column numbers.

func printBooleanMatrix(matrix: [[Bool]]) {
    for (rowIndex, row) in matrix.enumerated() {
        print(rowIndex, terminator: " ")
        for element in row {
            if element {
                print("*", terminator: " ")
            } else {
                print(" ", terminator: " ")
            }
        }
        print()
    }
}

//: [Next](@next)<|endoftext|>//: [Previous](@previous)

import Foundation

//: # 1.1.12
//: What does the following code fragment print?
//:
//: ```

func intersperse(numbers: [Int], delimeter: Int) -> [Int] {
    var result = [Int]()
    for (index, number) in numbers.enumerated() {
        result.append(number)
        if index < numbers.count - 1 {
            result.append(delimeter)
        }
    }
    return result
}

import Foundation

func equal(numbers: [Int]) -> String {
    if numbers.count == 0 {
        return ""
    }

    let first = numbers[0]
    for number in numbers {
        if number != first {
            return "not equal"
        }
    }
    return "equal"
}

func both(t: Bool, f: Bool) -> Bool {
    return t == f
}
```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 (index, number) in numbers.enumerated() {
        result.append(number)
        if index < numbers.count - 1 {
            result.append(delimeter)
        }
    }
    return result
}

//: [Next](@next)<|endoftext|>//: [Previous](@previous)

import Foundation

//: # 1.1.1
//: Write a program that takes three integer command-line arguments and prints `equal` if all three are equal, and `not equal` otherwise.

func equal(numbers: [Int]) -> String {
    if numbers.count == 0 {
        return ""
    }

    let first = numbers[0]
    for number in numbers {
        if number != first {
            return "not equal"
        }
    }
    return "equal"
}

//: # 1.1.2
//: Write a program that takes two int values `t` and `f` and prints `true` if both are true or if both are false; otherwise, print `false`.

func both(t: Bool, f: Bool) -> Bool {
    return t == f
}

//: # 1.1.3
//: Write a program that takes three integer command-line arguments and prints `equal` if all three are equal, and `not equal` otherwise.

func equal(numbers: [Int]) -> String {
    if numbers.count == 0 {
        return ""
    }

    let first = numbers[0]
    for number in numbers {
        if number != first {
            return "not equal"
        }
    }
    return "equal"
}

//: # 1.1.4
//: What (if anything) is wrong with each of the following statements?
//:
//: ```

func intersperse(numbers: [Int], delimeter: Int) -> [Int] {
    var result = [Int]()
    for (index, number) in numbers.enumerated() {
        result.append(number)
        if index != numbers.count - 1 {
            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 (index, number) in numbers.enumerated() {
        result.append(number)
        if index != numbers.count - 1 {
            result.append(delimeter)
        }
    }
    return result
}

//: ### 1.10.10
//: Write a function `transpose` that transposes a matrix.
//:
//: ```

func intersperse(numbers: [Int], delimeter: Int) -> [Int] {
    var result = [Int]()
    for (index, number) in numbers.enumerated() {
        result.append(number)
        if index < numbers.count - 1 {
            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 (index, number) in numbers.enumerated() {
        result.append(number)
        if index < numbers.count - 1 {
            result.append(delimeter)
        }
    }
    return result
}

let numbers = [1, 2, 3]
let delimeter = 4
let result = intersperse(numbers: numbers, delimeter: delimeter)
print(result)
// Output: [1, 4, 2, 4, 3]
```

func intersperse(numbers: [Int], delimeter: Int) -> [Int] {
    var result = [Int]()
    for (index, number) in numbers.enumerated() {
        result.append(number)
        if index < numbers.count - 1 {
            result.append(delimeter)
        }
    }
    return result
}

import Foundation

func spinWords(_ string: String) -> String {
    var result = ""
    let words = string.split(separator: " ")
    for word in words {
        if word.count >= 5 {
            result += String(word.reversed()) + " "
        } else {
            result += String(word) + " "
        }
    }
    return String(result.dropLast())
}

func twoSum(_ numbers: [Int], _ target: Int) -> (Int, Int) {
    for (index, number) in numbers.enumerated() {
        for (index2, number2) in numbers.enumerated() {
            if index != index2 && number + number2 == target {
                return (index, index2)
            }
        }
    }
    return (0, 0)
}
```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 (index, number) in numbers.enumerated() {
        result.append(number)
        if index < numbers.count - 1 {
            result.append(delimeter)
        }
    }
    return result
}

//: [Next](@next)<|endoftext|>//: [Previous](@previous)

import Foundation

//: # 1.1
//: Write a function that takes in a string of one or more words, and returns the same string, but with all five or more letter words reversed (Just like the name of this Kata). Strings passed in will consist of only letters and spaces. Spaces will be included only when more than one word is present.
//:
//: Examples: spinWords( "Hey fellow warriors" ) => returns "Hey wollef sroirraw" spinWords( "This is a test") => returns "This is a test" spinWords( "This is another test" )=> returns "This is rehtona test"

func spinWords(_ string: String) -> String {
    var result = ""
    let words = string.split(separator: " ")
    for word in words {
        if word.count >= 5 {
            result += String(word.reversed()) + " "
        } else {
            result += String(word) + " "
        }
    }
    return String(result.dropLast())
}

//: [Next](@next)<|endoftext|>//: [Previous](@previous)

import Foundation

//: # 1.1
//: Write a function that takes an array of numbers (integers for the tests) and a target number. It should find two different items in the array that, when added together, give the target value. The indices of these items should then be returned in a tuple / list (depending on your language) like so: (index1, index2).
//:
//: For the purposes of this kata, some tests may have multiple answers; any valid solutions will be accepted.
//:
//: The input will always be valid (numbers will be an array of length 2 or greater, and all of the items will be numbers; target will always be the sum of two different items from that array).
//:
//: Based on: http://oj.leetcode.com/problems/two-sum/
//:
//: twoSum [1, 2, 3] 4 === (0, 2)

func twoSum(_ numbers: [Int], _ target: Int) -> (Int, Int) {
    for (index, number) in numbers.enumerated() {
        for (index2, number2) in numbers.enumerated() {
            if index != index2 && number + number2 == target {
                return (index, index2)
            }
        }
    }
    return (0, 0)
}

//: [Next](@next)<|endoftext|>//: [Previous](@previous)

import Foundation

//: # 1.1
//: Write a function that takes in a string of one or more words, and returns the same string, but with all five or more letter words reversed (Just like the name of this Kata). Strings passed in will consist of only letters and spaces. Spaces will be included only when more than one word is present.
//:
//: Examples: spinWords( "Hey fellow warriors" ) => returns "Hey wollef sroirraw" spinWords( "This is a test") => returns "This is a test" spinWords( "This is another test" )=> returns "This is rehtona test"

func spinWords(_ string: String) -> String {
    var result = ""
    let words = string.split(separator: " ")
    for word in words {
        if word.count >= 5 {
            result += String(word.reversed()) + " "
        } else {
            result += String(word) + " "
        }
    }
    return String(result.dropLast())
}

//: [Next](@next)<|endoftext|>//: [Previous](@previous)

import Foundation

//: # 1.1
//: Write a function that takes an array of numbers (integers for the tests) and a target number. It should find two different items in the array

func parseNestedParens(parenString: String) -> [Int] {
    // ...
}
```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] {
    // ...
}
```
} // missing return in global function expected to return '[Int]'

func parseNestedParens(parenString: String) -> [Int] {
    var result: [Int] = []
    var maxDepth = 0
    var currentDepth = 0
    for char in parenString {
        if char == "(" {
            currentDepth += 1
            maxDepth = max(maxDepth, currentDepth)
        } else if char == ")" {
            currentDepth -= 1
        }
    }
    result.append(maxDepth)
    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 maxDepth = 0
    var currentDepth = 0
    for char in parenString {
        if char == "(" {
            currentDepth += 1
            maxDepth = max(maxDepth, currentDepth)
        } else if char == ")" {
            currentDepth -= 1
        }
    }
    result.append(maxDepth)
    return result
}

// Test cases
print(parseNestedParens(parenString: "(()()) ((())) () ((())()())"))
print(parseNestedParens(parenString: "(()(()))"))
print(parseNestedParens(parenString: "()"))
print(parseNestedParens(parenString: ""))
print(parseNestedParens(parenString: "((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
 // XCTAssertTrue failed

func parseNestedParens(parenString: String) -> [Int] {
    var result: [Int] = []
    var maxDepth = 0
    var currentDepth = 0
    for char in parenString {
        if char == "(" {
            currentDepth += 1
            maxDepth = max(maxDepth, currentDepth)
        } else if char == ")" {
            currentDepth -= 1
        }
    }
    result.append(maxDepth)
    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 maxDepth = 0
    var currentDepth = 0
    for char in parenString {
        if char == "(" {
            currentDepth += 1
            maxDepth = max(maxDepth, currentDepth)
        } else if char == ")" {
            currentDepth -= 1
        }
    }
    result.append(maxDepth)
    return result
}

// Example usage:
let input = "(()()) ((())) () ((())()())"
let output = parseNestedParens(parenString: input)
print(output) // [2, 3, 1, 3]

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

func parseNestedParens(parenString: String) -> [Int] {
    // TODO: Implement this function
    return []
}
```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] {
    // TODO: Implement this function
    return []
}
```
 // XCTAssertTrue failed

func parseNestedParens(parenString: String) -> [Int] {
    var result: [Int] = []
    var maxDepth = 0
    var depth = 0
    for c in parenString {
        if c == "(" {
            depth += 1
            maxDepth = max(maxDepth, depth)
        } else if c == ")" {
            depth -= 1
        }
    }
    result.append(maxDepth)
    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 maxDepth = 0
    var depth = 0
    for c in parenString {
        if c == "(" {
            depth += 1
            maxDepth = max(maxDepth, depth)
        } else if c == ")" {
            depth -= 1
        }
    }
    result.append(maxDepth)
    return result
}

print(parseNestedParens(parenString: "(()()) ((())) () ((())()())"))

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

func parseNestedParens(parenString: String) -> [Int] {
    var parenString = parenString
    var result: [Int] = []
    while parenString.count > 0 {
        let (parenString, maxDepth) = parseNestedParens(parenString: parenString)
        result.append(maxDepth)
    }
    return result
}

func parseNestedParens(parenString: String) -> (String, Int) {
    var parenString = parenString
    var maxDepth = 0
    var depth = 0
    var i = 0
    while i < parenString.count {
        if parenString[i] == "(" {
            depth += 1
            maxDepth = max(maxDepth, depth)
        } else if parenString[i] == ")" {
            depth -= 1
        } else {
            break
        }
        i += 1
    }
    parenString = String(parenString.dropFirst(i))
    return (parenString, maxDepth)
}
```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 parenString = parenString
    var result: [Int] = []
    while parenString.count > 0 {
        let (parenString, maxDepth) = parseNestedParens(parenString: parenString)
        result.append(maxDepth)
    }
    return result
}

func parseNestedParens(parenString: String) -> (String, Int) {
    var parenString = parenString
    var maxDepth = 0
    var depth = 0
    var i = 0
    while i < parenString.count {
        if parenString[i] == "(" {
            depth += 1
            maxDepth = max(maxDepth, depth)
        } else if parenString[i] == ")" {
            depth -= 1
        } else {
            break
        }
        i += 1
    }
    parenString = String(parenString.dropFirst(i))
    return (parenString, maxDepth)
}

print(parseNestedParens(parenString: "(()()) ((())) () ((())()())"))
```
var parenString = parenString // variable 'parenString' was never mutated; consider changing to 'let' constant
let (parenString, maxDepth) = parseNestedParens(parenString: parenString) // immutable value 'parenString' was never used; consider replacing with '_' or removing it
if parenString[i] == "(" { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
} else if parenString[i] == ")" { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.

func parseNestedParens(parenString: String) -> [Int] {
    // TODO: Implement this function
    return []
}
```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] {
    // TODO: Implement this function
    return []
}
```
 // XCTAssertTrue failed

func parseNestedParens(parenString: String) -> [Int] {
    var result: [Int] = []
    var maxDepth = 0
    var currentDepth = 0
    for char in parenString {
        if char == "(" {
            currentDepth += 1
            maxDepth = max(maxDepth, currentDepth)
        } else if char == ")" {
            currentDepth -= 1
        }
    }
    result.append(maxDepth)
    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 maxDepth = 0
    var currentDepth = 0
    for char in parenString {
        if char == "(" {
            currentDepth += 1
            maxDepth = max(maxDepth, currentDepth)
        } else if char == ")" {
            currentDepth -= 1
        }
    }
    result.append(maxDepth)
    return result
}

// Example usage:
print(parseNestedParens(parenString: "(()()) ((())) () ((())()())"))
// Output: [2, 3, 1, 3]

// Example usage:
print(parseNestedParens(parenString: "((()))"))
// Output: [3]

// Example usage:
print(parseNestedParens(parenString: "(()())"))
// Output: [2]

// Example usage:
print(parseNestedParens(parenString: "()"))
// Output: [1]

// Example usage:
print(parseNestedParens(parenString: ""))
// Output: []

// Example usage:
print(parseNestedParens(parenString: "(())(())"))
// Output: [1, 1]

// Example usage:
print(parseNestedParens(parenString: "(())(())"))
// Output: [1, 1]

// Example usage:
print(parseNestedParens(parenString: "(())(())"))
// Output: [1, 1]

// Example usage:
print(parseNestedParens(parenString: "(())(())"))
// Output: [1, 1]

// Example usage:
print(parseNestedParens(parenString: "(())(())"))
// Output: [1, 1]

// Example usage:
print(parseNestedParens(parenString: "(())(())"))
// Output: [1, 1]

// Example usage:
print(parseNestedParens(parenString: "(())(())"))
// Output: [1, 1]

// Example usage:
print(parseNestedParens(parenString: "(())(())"))
// Output: [1, 1]

// Example usage:
print(parseNestedParens(parenString: "(())(())"))
// Output: [1, 1]

// Example usage:
print(parseNestedParens(parenString: "(())(())"))
// Output: [1, 1]

// Example usage:
print(parseNestedParens(parenString: "(())(())"))
// Output: [1, 1]

// Example usage:
print(parseNestedParens(parenString: "(())(())"))
// Output: [1, 1]

// Example usage:
print(parseNestedParens(parenString: "(())(())"))
// Output: [1, 1]

// Example usage:
print(parseNestedParens(parenString: "(())(())"))
// Output: [1, 1]

// Example usage:
print(parseNestedParens(parenString: "(())(())"))
// Output: [1, 1]

// Example usage:
print(parseNestedParens(parenString: "(())(())"))
// Output: [1, 1]

// Example usage:
print(parseNestedParens(parenString: "(())(())"))
// Output: [1, 1]

// Example usage:
print(parseNestedParens(parenString: "(())(())"))
// Output: [1, 1]

// Example usage:
print(parseNestedParens(parenString: "(())(())"))
// Output: [1, 1]

// Example usage:
print(parseNestedParens(parenString: "(())(())"))
// Output: [1, 1]

// Example usage:
print(parseNestedParens(parenString: "(())(())"))
// Output:
 // XCTAssertTrue failed

func parseNestedParens(parenString: String) -> [Int] {
    var result: [Int] = []
    var maxDepth = 0
    var currentDepth = 0
    for char in parenString {
        if char == "(" {
            currentDepth += 1
            maxDepth = max(maxDepth, currentDepth)
        } else if char == ")" {
            currentDepth -= 1
        }
    }
    result.append(maxDepth)
    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 maxDepth = 0
    var currentDepth = 0
    for char in parenString {
        if char == "(" {
            currentDepth += 1
            maxDepth = max(maxDepth, currentDepth)
        } else if char == ")" {
            currentDepth -= 1
        }
    }
    result.append(maxDepth)
    return result
}

print(parseNestedParens(parenString: "(()()) ((())) () ((())()())"))

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

func parseNestedParens(parenString: String) -> [Int] {
    var result: [Int] = []
    var maxDepth = 0
    var currentDepth = 0
    for char in parenString {
        if char == "(" {
            currentDepth += 1
            maxDepth = max(maxDepth, currentDepth)
        } else if char == ")" {
            currentDepth -= 1
        }
    }
    result.append(maxDepth)
    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 maxDepth = 0
    var currentDepth = 0
    for char in parenString {
        if char == "(" {
            currentDepth += 1
            maxDepth = max(maxDepth, currentDepth)
        } else if char == ")" {
            currentDepth -= 1
        }
    }
    result.append(maxDepth)
    return result
}

// Example usage
print(parseNestedParens(parenString: "(()()) ((())) () ((())()())"))
// Output: [2, 3, 1, 3]
```
 // XCTAssertTrue failed

func filterBySubstring(strings: [String], substring: String) -> [String] {
    // write your code here
}
```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] {
    // write your code here
}
```
} // missing return in global function expected to return '[String]'

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] {
    // Write your code here
}
```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] {
    // Write your code here
}
```
} // missing return in global function expected to return '[String]'

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) }
}

// 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) }
}

// 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) }
}

// 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) }
}

// 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) }
}

// 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) }
}

// 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) }
}

// 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) }
}

// Filter an input array of strings only for ones that contain given substring
// filterBySubstring(strings: [] as [String], substring: "a") == [] as [String]
// filterBySubstring(strings: [

func filterBySubstring(strings: [String], substring: String) -> [String] {
    var filteredStrings = [String]()
    for string in strings {
        if string.contains(substring) {
            filteredStrings.append(string)
        }
    }
    return filteredStrings
}
```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] {
    var filteredStrings = [String]()
    for string in strings {
        if string.contains(substring) {
            filteredStrings.append(string)
        }
    }
    return filteredStrings
}

// 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] {
    var filteredStrings = [String]()
    for string in strings {
        if string.contains(substring) {
            filteredStrings.append(string)
        }
    }
    return filteredStrings
}

// 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] {
    var filteredStrings = [String]()
    for string in strings {
        if string.contains(substring) {
            filteredStrings.append(string)
        }
    }
    return filteredStrings
}

// 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] {
    var filteredStrings = [String]()
    for string in strings {
        if string.contains(substring) {
            filteredStrings.append(string)
        }
    }
    return filteredStrings
}

// 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] {
    var filteredStrings = [String]()
    for string in strings {
        if string.contains(substring) {
            filteredStrings.append(string)
        }
    }
    return filteredStrings
}

// 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] {
    var filteredStrings = [String]()
    for string in strings {
        if string.contains(substring) {
            filteredStrings.append(string)
        }
    }
    return filteredStrings
}

// 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

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) }
}

// 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) }
}

// 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) }
}

// 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) }
}

// 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) }
}

// 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) }
}

// 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) }
}

// 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) }
}

// Filter an input array of strings only for ones that contain given substring
// filterBySubstring(strings: [] as [String], substring: "a") == [] as [String]
// filterBySubstring(strings: [

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) }
}

// 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) }
}

// 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) }
}

// 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) }
}

// 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) }
}

// 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) }
}

// 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) }
}

// 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) }
}

// Filter an input array of strings only for ones that contain given substring
// filterBySubstring(strings: [] as [String], substring: "a") == [] as [String]
// filterBySubstring(strings: [

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 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)
}

// 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)
}

// 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)
}

// 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)
}

// 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)
}

// 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)
}

// 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)
}

// For a given array of integers, return a tuple consisting of a sum and a product of all the integers in an array.
// Em

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)
}

print(sumProduct(numbers: [1, 2, 3, 4]))
// Output: (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)
}
```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)
}

print(sumProduct(numbers: []))
print(sumProduct(numbers: [1, 2, 3, 4]))
```

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

import Foundation
```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)
}

//: [Next](@next)<|endoftext|>//: [Previous](@previous)

import Foundation

//: # 2.1
//: ## 2.1.1
//: - Write a function that takes an array of integers as input and returns the sum of all the integers in the array.
//: - Write a function that takes an array of integers as input and returns the product of all the integers in the array.
//: - Write a function that takes an array of integers as input and returns the largest integer in the array.
//: - Write a function that takes an array of integers as input and returns the smallest integer in the array.
//: - Write a function that takes an array of integers as input and returns the average of all the integers in the array.
//: - Write a function that takes an array of integers as input and returns the median of all the integers in the array.
//: - Write a function that takes an array of integers as input and returns the mode of all the integers in the array.
//: - Write a function that takes an array of integers as input and returns the range of all the integers in the array.
//: - Write a function that takes an array of integers as input and returns the standard deviation of all the integers in the array.
//: - Write a function that takes an array of integers as input and returns the variance of all the integers in the array.
//: - Write a function that takes an array of integers as input and returns the sum of all the even integers in the array.
//: - Write a function that takes an array of integers as input and returns the sum of all the odd integers in the array.
//: - Write a function that takes an array of integers as input and returns the sum of all the positive integers in the array.
//: - Write a function that takes an array of integers as input and returns the sum of all the negative integers in the array.
//: - Write a function that takes an array of integers as input and returns the sum of all the prime integers in the array.
//: - Write a function that takes an array of integers as input and returns the sum of all the composite integers in the array.
//: - Write a function that takes an array of integers as input and returns the sum of all the perfect integers in the array.
//: - Write a function that takes an array of integers as input and returns the sum of all the abundant integers in the array.
//: - Write a function that takes an array of integers as input and returns the sum of all the deficient integers in the array.
//: - Write a function that takes an array of integers as input and returns the sum of all the even integers in the array.
//: - Write a function that takes an array of integers as input and returns the sum of all the odd integers in the array.
//: - Write a function that takes an array of integers as input and returns the sum of all the positive integers in the array.
//: - Write a function that takes an array of integers as input and returns the sum of all the negative integers in the array.
//: - Write a function that takes an array of integers as input and returns the sum of all the prime integers in the array.
//: - Write a function that takes an array of integers as input and returns the sum of all the composite integers in the array.
//: - Write a function that takes an array of integers as input and returns the sum of all the perfect integers in the array.
//: - Write a function that takes an array of integers as input and returns the sum of all the abundant integers in the array.
//: - Write a function that takes an array of integers as input and returns the sum of all the deficient integers in the array.
//: - Write a function that takes an array of integers as input and returns the sum of all the even integers in the array.
//: - Write a function that takes an array of integers as input and returns the sum of all the odd integers in the array.
//: - Write a function that takes an array of integers as input and returns the sum of all the positive integers in the array.
//: - Write a function that takes an array of integers as input and returns the sum of all the negative integers in the array.
//: - Write a function that takes an array of integers as input and returns the sum of all the prime integers in the array.
//: - Write a function that takes an array of integers as input and returns the sum of all the

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

func minMax(numbers: [Int]) -> (Int, Int) {
    var min = 0
    var max = 0
    for number in numbers {
        if number < min {
            min = number
        }
        if number > max {
            max = number
        }
    }
    return (min, max)
}

func evenOddSum(numbers: [Int]) -> (Int, Int) {
    var evenSum = 0
    var oddSum = 0
    for number in numbers {
        if number % 2 == 0 {
            evenSum += number
        } else {
            oddSum += number
        }
    }
    return (evenSum, oddSum)
}

func positiveNegativeSum(numbers: [Int]) -> (Int, Int) {
    var positiveSum = 0
    var negativeSum = 0
    for number in numbers {
        if number > 0 {
            positiveSum += number
        } else {
            negativeSum += number
        }
    }
    return (positiveSum, negativeSum)
}

func evenOddSum(numbers: [Int]) -> (Int, Int) {
    var evenSum = 0
    var oddSum = 0
    for number in numbers {
        if number % 2 == 0 && number > 0 {
            evenSum += number
        } else if number % 2 != 0 && number < 0 {
            oddSum += number
        }
    }
    return (evenSum, oddSum)
}
```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 an array of integers, return a tuple consisting of the smallest and the largest number in an array.
// minMax(numbers: [1, 2, 3, 4]) == (1, 4)
// minMax(numbers: [1, 1, 1]) == (1, 1)
// minMax(numbers: []) == (0, 0)
func minMax(numbers: [Int]) -> (Int, Int) {
    var min = 0
    var max = 0
    for number in numbers {
        if number < min {
            min = number
        }
        if number > max {
            max = number
        }
    }
    return (min, max)
}

// 3.
// Given an array of integers, return a tuple consisting of the sum of even and the sum of odd numbers in an array.
// evenOddSum(numbers: [1, 2, 3, 4]) == (6, 4)
// evenOddSum(numbers: [1, 1, 1]) == (0, 3)
// evenOddSum(numbers: [2, 2, 2]) == (6, 0)
// evenOddSum(numbers: []) == (0, 0)
func evenOddSum(numbers: [Int]) -> (Int, Int) {
    var evenSum = 0
    var oddSum = 0
    for number in numbers {
        if number % 2 == 0 {
            evenSum += number
        } else {
            oddSum += number
        }
    }
    return (evenSum, oddSum)
}

// 4.
// Given an array of integers, return a tuple consisting of the sum of positive and the sum of negative numbers in an array.
// positiveNegativeSum(numbers: [1, 2, 3, 4]) == (10, 0)
// positiveNegativeSum(numbers: [-1, -2, -3, -4]) == (0, -10)
// positiveNegativeSum(numbers: [1, -1, 1, -1]) == (2, -2)
// positiveNegativeSum(numbers: []) == (0, 0)
func positiveNegativeSum(numbers: [Int]) -> (Int, Int) {
    var positiveSum = 0
    var negativeSum = 0
    for number in numbers {
        if number > 0 {
            positiveSum += number
        } else {
            negativeSum += number
        }
    }
    return (positiveSum, negativeSum)
}

// 5.
// Given an array of integers, return a tuple consisting of the sum of even positive numbers and the sum of odd negative numbers in an array.
// evenOddSum(numbers: [1, 2, 3, 4]) == (6, 4)
// evenOddSum(numbers: [1, 1, 1]) == (0, 3)
// evenOddSum(numbers: [2, 2, 2]) == (6, 0)
// evenOddSum(numbers: []) == (0, 0)
func evenOddSum(numbers: [Int]) -> (Int, Int) {
    var evenSum = 0
    var oddSum = 0
    for number in numbers {
        if number % 2 == 0 && number > 0 {
            evenSum += number
        } else if number % 2 != 0 && number < 0 {
            oddSum += number
        }
    }
    return (evenSum, oddSum)
}

// 6.
// Given an array of integers, return a tuple consisting of the sum of even positive numbers and the sum of odd negative numbers in an array.
// evenOddSum(numbers: [1, 2, 3, 4]) == (6, 4)
// evenOddSum(numbers: [1, 1, 1]) == (0, 3)
// evenOddSum(numbers: [2, 2, 2]) == (6, 0)
// evenOddSum(numbers: [])
func evenOddSum(numbers: [Int]) -> (Int, Int) { // invalid redeclaration of 'evenOddSum(numbers:)'

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 rollingMax(numbers: [Int]) -> [Int] {
    var result: [Int] = []
    var max = Int.min
    for number in numbers {
        max = 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.min
    for number in numbers {
        max = max(max, number)
        result.append(max)
    }
    return result
}

print(rollingMax(numbers: [1, 2, 3, 2, 3, 4, 2]))
// [1, 2, 3, 3, 3, 4, 4]
```
max = max(max, number) // cannot call value of non-function type 'Int'

func rollingMax(numbers: [Int]) -> [Int] {
    var result = [Int]()
    var max = Int.min
    for number in numbers {
        max = 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.min
    for number in numbers {
        max = max(max, number)
        result.append(max)
    }
    return result
}

print(rollingMax(numbers: [1, 2, 3, 2, 3, 4, 2]))
```
max = max(max, number) // cannot call value of non-function type 'Int'

func rollingMax(numbers: [Int]) -> [Int] {
    var result: [Int] = []
    var max = Int.min
    for number in numbers {
        max = 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.min
    for number in numbers {
        max = max(max, number)
        result.append(max)
    }
    return result
}
```
max = max(max, number) // cannot call value of non-function type 'Int'

func rollingMax(numbers: [Int]) -> [Int] {
    var result = [Int]()
    var max = Int.min
    for number in numbers {
        max = max > number ? 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.min
    for number in numbers {
        max = max > number ? max : number
        result.append(max)
    }
    return result
}
```

func rollingMax(numbers: [Int]) -> [Int] {
    var max = numbers[0]
    var result = [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 max = numbers[0]
    var result = [Int]()
    for number in numbers {
        if number > max {
            max = number
        }
        result.append(max)
    }
    return result
}

print(rollingMax(numbers: [1, 2, 3, 2, 3, 4, 2]))
```
 // Fatal error: Index out of range

func rollingMax(numbers: [Int]) -> [Int] {
    var result: [Int] = []
    var max = Int.min
    for number in numbers {
        max = 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.min
    for number in numbers {
        max = max(max, number)
        result.append(max)
    }
    return result
}

print(rollingMax(numbers: [1, 2, 3, 2, 3, 4, 2]))
// [1, 2, 3, 3, 3, 4, 4]
```
max = max(max, number) // cannot call value of non-function type 'Int'

func rollingMax(numbers: [Int]) -> [Int] {
    var result: [Int] = []
    var max = Int.min
    for number in numbers {
        max = max > number ? 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.min
    for number in numbers {
        max = max > number ? max : number
        result.append(max)
    }
    return result
}
```

func rollingMax(numbers: [Int]) -> [Int] {
    var result: [Int] = []
    var max = Int.min
    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.min
    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.min
    for number in numbers {
        max = max > number ? 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.min
    for number in numbers {
        max = max > number ? max : number
        result.append(max)
    }
    return result
}

print(rollingMax(numbers: [1, 2, 3, 2, 3, 4, 2]))
```

func rollingMax(numbers: [Int]) -> [Int] {
    var max = numbers.first ?? 0
    var result = [Int]()
    for number in numbers {
        max = max > number ? 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 max = numbers.first ?? 0
    var result = [Int]()
    for number in numbers {
        max = max > number ? max : number
        result.append(max)
    }
    return result
}
```

func makePalindrome(string: String) -> String {
    let string = Array(string)
    var i = 0
    while i < string.count && string[i] == string[string.count - 1 - i] {
        i += 1
    }
    return string.prefix(i) + string.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 string = Array(string)
    var i = 0
    while i < string.count && string[i] == string[string.count - 1 - i] {
        i += 1
    }
    return string.prefix(i) + string.reversed()
}

print(makePalindrome(string: ""))
print(makePalindrome(string: "cat"))
print(makePalindrome(string: "cata"))
```
return string.prefix(i) + string.reversed() // no '+' candidates produce the expected contextual result type 'String'

func makePalindrome(string: String) -> String {
    var result = string
    var i = 0
    while !isPalindrome(string: string[i..<string.count]) {
        result.append(string[i])
        i += 1
    }
    return result
}

func isPalindrome(string: String) -> Bool {
    var i = 0
    var j = string.count - 1
    while i < j {
        if string[i] != string[j] {
            return false
        }
        i += 1
        j -= 1
    }
    return true
}
```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 {
    var result = string
    var i = 0
    while !isPalindrome(string: string[i..<string.count]) {
        result.append(string[i])
        i += 1
    }
    return result
}

// Check if a string is a palindrome.
func isPalindrome(string: String) -> Bool {
    var i = 0
    var j = string.count - 1
    while i < j {
        if string[i] != string[j] {
            return false
        }
        i += 1
        j -= 1
    }
    return true
}

print(makePalindrome(string: ""))
print(makePalindrome(string: "cat"))
print(makePalindrome(string: "cata"))
```
while !isPalindrome(string: string[i..<string.count]) { // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.
result.append(string[i]) // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if string[i] != string[j] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if string[i] != string[j] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.

func makePalindrome(string: String) -> String {
    let string = Array(string)
    var i = string.count - 1
    while i >= 0 {
        if isPalindrome(string: string[0...i]) {
            break
        }
        i -= 1
    }
    return string + string[0...i].reversed()
}

func isPalindrome(string: String) -> Bool {
    let string = Array(string)
    var i = 0
    var j = string.count - 1
    while i < j {
        if string[i] != string[j] {
            return false
        }
        i += 1
        j -= 1
    }
    return true
}
```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 string = Array(string)
    var i = string.count - 1
    while i >= 0 {
        if isPalindrome(string: string[0...i]) {
            break
        }
        i -= 1
    }
    return string + string[0...i].reversed()
}

// Check if a string is a palindrome.
func isPalindrome(string: String) -> Bool {
    let string = Array(string)
    var i = 0
    var j = string.count - 1
    while i < j {
        if string[i] != string[j] {
            return false
        }
        i += 1
        j -= 1
    }
    return true
}

// Test cases.
print(makePalindrome(string: ""))
print(makePalindrome(string: "cat"))
print(makePalindrome(string: "cata"))
print(makePalindrome(string: "catac"))
print(makePalindrome(string: "catacac"))
print(makePalindrome(string: "catacacat"))
print(makePalindrome(string: "catacacata"))
print(makePalindrome(string: "catacacatac"))
print(makePalindrome(string: "catacacatacac"))
print(makePalindrome(string: "catacacatacacac"))
print(makePalindrome(string: "catacacatacacacat"))
print(makePalindrome(string: "catacacatacacacata"))
print(makePalindrome(string: "catacacatacacacatac"))
print(makePalindrome(string: "catacacatacacacatacac"))
print(makePalindrome(string: "catacacatacacacatacacac"))
print(makePalindrome(string: "catacacatacacacatacacacat"))
print(makePalindrome(string: "catacacatacacacatacacacata"))
print(makePalindrome(string: "catacacatacacacatacacacatac"))
print(makePalindrome(string: "catacacatacacacatacacacatacac"))
print(makePalindrome(string: "catacacatacacacatacacacatacacac"))
print(makePalindrome(string: "catacacatacacacatacacacatacacacat"))
print(makePalindrome(string: "catacacatacacacatacacacatacacacata"))
print(makePalindrome(string: "catacacatacacacatacacacatacacacatac"))
print(makePalindrome(string: "catacacatacacacatacacacatacacacatacac"))
print(makePalindrome(string: "catacacatacacacatacacacatacacacatacacac"))
print(makePalindrome(string: "catacacatacacacatacacacatacacacatacacacat"))
print(makePalindrome(string: "catacacatacacacatacacacatacacacatacacacata"))
print(makePalindrome(string: "catacacatacacacatacacacatacacacatacacacatac"))
print(makePalindrome(string: "catacacatacacacatacacacatacacacatacacacatacac"))
print(makePalindrome(string: "catacacatacacacatacacacatacacacatacacacatacacac"))
print(makePalindrome(string: "catacacatacacacatacacacatacacacatacacacatacacacat"))
print(makePalindrome(string: "catacacatacacacatacacacatacacacatacacacatacacacata"))
if isPalindrome(string: string[0...i]) { // cannot convert value of type 'Array<String.Element>.SubSequence' (aka 'ArraySlice<Character>') to expected argument type 'String'
return string + string[0...i].reversed() // cannot convert return expression of type '[String.Element]' (aka 'Array<Character>') to return type 'String'

func makePalindrome(string: String) -> String {
    var result = string
    var i = 0
    while i < result.count {
        if isPalindrome(string: result.suffix(from: i)) {
            break
        }
        i += 1
    }
    result.append(contentsOf: result.prefix(upTo: i).reversed())
    return result
}

func isPalindrome(string: String) -> Bool {
    var i = 0
    var j = string.count - 1
    while i < j {
        if string[string.index(string.startIndex, offsetBy: i)] != string[string.index(string.startIndex, offsetBy: j)] {
            return false
        }
        i += 1
        j -= 1
    }
    return true
}
```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 {
    var result = string
    var i = 0
    while i < result.count {
        if isPalindrome(string: result.suffix(from: i)) {
            break
        }
        i += 1
    }
    result.append(contentsOf: result.prefix(upTo: i).reversed())
    return result
}

// Check if a string is a palindrome.
func isPalindrome(string: String) -> Bool {
    var i = 0
    var j = string.count - 1
    while i < j {
        if string[string.index(string.startIndex, offsetBy: i)] != string[string.index(string.startIndex, offsetBy: j)] {
            return false
        }
        i += 1
        j -= 1
    }
    return true
}

// Test cases.
print(makePalindrome(string: "") == "")
print(makePalindrome(string: "a") == "a")
print(makePalindrome(string: "ab") == "aba")
print(makePalindrome(string: "abc") == "abcba")
print(makePalindrome(string: "abcd") == "abcdcba")
print(makePalindrome(string: "abcde") == "abcdedcba")
print(makePalindrome(string: "abcdef") == "abcdefedcba")
print(makePalindrome(string: "abcdefg") == "abcdefgfedcba")
print(makePalindrome(string: "abcdefgh") == "abcdefghhgfedcba")
print(makePalindrome(string: "abcdefghi") == "abcdefghihgfedcba")
print(makePalindrome(string: "abcdefghij") == "abcdefghijjihgfedcba")
print(makePalindrome(string: "abcdefghijk") == "abcdefghijkkjihgfedcba")
print(makePalindrome(string: "abcdefghijkl") == "abcdefghijklkjihgfedcba")
print(makePalindrome(string: "abcdefghijklm") == "abcdefghijklmmlkjihgfedcba")
print(makePalindrome(string: "abcdefghijklmn") == "abcdefghijklmnnmkjihgfedcba")
print(makePalindrome(string: "abcdefghijklmno") == "abcdefghijklmnoonmlkjihgfedcba")
print(makePalindrome(string: "abcdefghijklmnop") == "abcdefghijklmnopopmlkjihgfedcba")
print(makePalindrome(string: "abcdefghijklmnopq") == "abcdefghijklmnopqpqmlkjihgfedcba")
print(makePalindrome(string: "abcdefghijklmnopqr") == "abcdefghijklmnopqrrqpmlkjihgfedcba")
print(makePalindrome(string: "abcdefghijklmnopqrs") == "abcdefghijklmnopqrssrqpmlkjihgfedcba")
print(makePalindrome(string: "abcdefghijklmnopqrst") == "abcdefghijklmnopqrsttsrqpmlkjihgfedcba")
print(makePalindrome(string: "abcdefghijklmnopqrstu") == "abcdefghijklmnopqrstuutsrqpmlkjihgfedcba")
print(makePalindrome(string: "abcdefghijklmnopqrstuv") == "abcdefghijklmnopqrstuvvutsrqpmlkjihgfedcba")
print(makePalindrome(string: "abcdefghijklmnopqrstuvw") == "abcdefghijklmnopqrstuvwwvutsrqpmlkjihgfedcba")
print(makePalindrome(string: "abcdefghijklmnopqrstuvwx") == "abc
if isPalindrome(string: result.suffix(from: i)) { // cannot convert value of type 'Int' to expected argument type 'String.Index'
if isPalindrome(string: result.suffix(from: i)) { // cannot convert value of type 'String.SubSequence' (aka 'Substring') to expected argument type 'String'
result.append(contentsOf: result.prefix(upTo: i).reversed()) // cannot convert value of type 'Int' to expected argument type 'String.Index'

func makePalindrome(string: String) -> String {
    // 1. Find the longest postfix of supplied string that is a palindrome.
    let longestPalindromicSuffix = findLongestPalindromicSuffix(string: string)
    // 2. Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.
    let prefix = string.prefix(upTo: longestPalindromicSuffix.startIndex)
    let reversedPrefix = String(prefix.reversed())
    return string + reversedPrefix
}

func findLongestPalindromicSuffix(string: String) -> Substring {
    // 1. Find the longest palindromic substring of the string.
    let longestPalindromicSubstring = findLongestPalindromicSubstring(string: string)
    // 2. Find the longest postfix of the string that is equal to the palindromic substring.
    let longestPalindromicSuffix = findLongestSuffix(string: string, substring: longestPalindromicSubstring)
    return longestPalindromicSuffix
}

func findLongestPalindromicSubstring(string: String) -> Substring {
    // 1. Find the longest palindromic substring of the string.
    let longestPalindromicSubstring = findLongestPalindromicSubstring(string: string)
    // 2. Find the longest postfix of the string that is equal to the palindromic substring.
    let longestPalindromicSuffix = findLongestSuffix(string: string, substring: longestPalindromicSubstring)
    return longestPalindromicSuffix
}
```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 {
    // 1. Find the longest postfix of supplied string that is a palindrome.
    let longestPalindromicSuffix = findLongestPalindromicSuffix(string: string)
    // 2. Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.
    let prefix = string.prefix(upTo: longestPalindromicSuffix.startIndex)
    let reversedPrefix = String(prefix.reversed())
    return string + reversedPrefix
}

// Find the longest postfix of supplied string that is a palindrome.
func findLongestPalindromicSuffix(string: String) -> Substring {
    // 1. Find the longest palindromic substring of the string.
    let longestPalindromicSubstring = findLongestPalindromicSubstring(string: string)
    // 2. Find the longest postfix of the string that is equal to the palindromic substring.
    let longestPalindromicSuffix = findLongestSuffix(string: string, substring: longestPalindromicSubstring)
    return longestPalindromicSuffix
}

// Find the longest palindromic substring of supplied string.
func findLongestPalindromicSubstring(string: String) -> Substring {
    // 1. Find the longest palindromic substring of the string.
    let longestPalindromicSubstring = findLongestPalindromicSubstring(string: string)
    // 2. Find the longest postfix of the string that is equal to the palindromic substring.
    let longestPalindromicSuffix = findLongestSuffix(string: string, substring: longestPalindromicSubstring)
    return longestPalindromicSuffix
}

// Find the longest palindromic substring of supplied string.
func findLongestPalindromicSubstring(string: String) -> Substring {
    // 1. Find the longest palindromic substring of the string.
    let longestPalindromicSubstring = findLongestPalindromicSubstring(string: string)
    // 2. Find the longest postfix of the string that is equal to the palindromic substring.
    let longestPalindromicSuffix = findLongestSuffix(string: string, substring: longestPalindromicSubstring)
    return longestPalindromicSuffix
}

// Find the longest palindromic substring of supplied string.
func findLongestPalindromicSubstring(string: String) -> Substring {
    // 1. Find the longest palindromic substring of the string.
    let longestPalindromicSubstring = findLongestPalindromicSubstring(string: string)
    // 2. Find the longest postfix of the string that is equal to the palindromic substring.
    let longestPalindromicSuffix = findLongestSuffix(string: string, substring: longestPalindromicSubstring)
    return longestPalindromicSuffix
}

// Find the longest palindromic substring of supplied string.
func findLongestPalindromicSubstring(string: String) -> Substring {
    // 1. Find the longest palindromic substring of the string.
    let longestPalindromicSubstring = findLongestPalindromicSubstring(string: string)
    // 2. Find the longest postfix of the string that is equal to the palindromic substring.
    let longestPalindromicSuffix = findLongestSuffix(string: string, substring: longestPalindromicSubstring)
    return longestPalindromicSuffix
}

// Find the longest palindromic substring of supplied string.
func findLongestPalindromicSubstring(string: String) -> Substring {
    // 1. Find the longest palindromic substring of the string.
    let longestPalindromicSubstring = findLongestPalindromicSubstring(string: string)
    // 2. Find the longest postfix of the string that is equal to the palindromic substring.
    let longestPalindromicSuffix = findLongestSuffix(string: string, substring: longest
let longestPalindromicSuffix = findLongestSuffix(string: string, substring: longestPalindromicSubstring) // cannot find 'findLongestSuffix' in scope
let longestPalindromicSuffix = findLongestSuffix(string: string, substring: longestPalindromicSubstring) // cannot find 'findLongestSuffix' in scope

func makePalindrome(string: String) -> String {
    let stringArray = Array(string)
    var longestPalindrome = ""
    for i in 0..<stringArray.count {
        let substring = String(stringArray[i..<stringArray.count])
        if substring.isPalindrome {
            longestPalindrome = substring
            break
        }
    }
    let prefix = String(stringArray[0..<stringArray.count - longestPalindrome.count])
    return prefix + longestPalindrome + 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 stringArray = Array(string)
    var longestPalindrome = ""
    for i in 0..<stringArray.count {
        let substring = String(stringArray[i..<stringArray.count])
        if substring.isPalindrome {
            longestPalindrome = substring
            break
        }
    }
    let prefix = String(stringArray[0..<stringArray.count - longestPalindrome.count])
    return prefix + longestPalindrome + prefix.reversed()
}

// Test cases
print(makePalindrome(string: "") == "")
print(makePalindrome(string: "cat") == "catac")
print(makePalindrome(string: "cata") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(makePalindrome(string: "catac") == "catac")
print(
if substring.isPalindrome { // value of type 'String' has no member 'isPalindrome'

func makePalindrome(string: String) -> String {
    let string = Array(string)
    var i = string.count - 1
    while i >= 0 {
        if isPalindrome(string: string[0...i]) {
            break
        }
        i -= 1
    }
    return string + string[0...i].reversed()
}

func isPalindrome(string: String) -> Bool {
    let string = Array(string)
    var i = 0
    var j = string.count - 1
    while i < j {
        if string[i] != string[j] {
            return false
        }
        i += 1
        j -= 1
    }
    return true
}
```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 string = Array(string)
    var i = string.count - 1
    while i >= 0 {
        if isPalindrome(string: string[0...i]) {
            break
        }
        i -= 1
    }
    return string + string[0...i].reversed()
}

// Check if a string is a palindrome.
func isPalindrome(string: String) -> Bool {
    let string = Array(string)
    var i = 0
    var j = string.count - 1
    while i < j {
        if string[i] != string[j] {
            return false
        }
        i += 1
        j -= 1
    }
    return true
}

// Tests
print(makePalindrome(string: "") == "")
print(makePalindrome(string: "a") == "a")
print(makePalindrome(string: "ab") == "aba")
print(makePalindrome(string: "abc") == "abcba")
print(makePalindrome(string: "abba") == "abba")
print(makePalindrome(string: "abbb") == "abbba")
print(makePalindrome(string: "abbba") == "abbba")
print(makePalindrome(string: "abbbb") == "abbbba")
print(makePalindrome(string: "abbbbb") == "abbbbba")
print(makePalindrome(string: "abbbbba") == "abbbbba")
print(makePalindrome(string: "abbbbbb") == "abbbbbba")
print(makePalindrome(string: "abbbbbbb") == "abbbbbbba")
print(makePalindrome(string: "abbbbbbba") == "abbbbbbba")
print(makePalindrome(string: "abbbbbbbb") == "abbbbbbbba")
print(makePalindrome(string: "abbbbbbbbb") == "abbbbbbbbba")
print(makePalindrome(string: "abbbbbbbbba") == "abbbbbbbbba")
print(makePalindrome(string: "abbbbbbbbbb") == "abbbbbbbbbba")
print(makePalindrome(string: "abbbbbbbbbbb") == "abbbbbbbbbbba")
print(makePalindrome(string: "abbbbbbbbbbba") == "abbbbbbbbbbba")
print(makePalindrome(string: "abbbbbbbbbbbb") == "abbbbbbbbbbbba")
print(makePalindrome(string: "abbbbbbbbbbbbb") == "abbbbbbbbbbbbba")
print(makePalindrome(string: "abbbbbbbbbbbbba") == "abbbbbbbbbbbbba")
print(makePalindrome(string: "abbbbbbbbbbbbbb") == "abbbbbbbbbbbbbba")
print(makePalindrome(string: "abbbbbbbbbbbbbbb") == "abbbbbbbbbbbbbbba")
print(makePalindrome(string: "abbbbbbbbbbbbbbba") == "abbbbbbbbbbbbbbba")
print(makePalindrome(string: "abbbbbbbbbbbbbbbb") == "abbbbbbbbbbbbbbbba")
print(makePalindrome(string: "abbbbbbbbbbbbbbbbb") == "abbbbbbbbbbbbbbbbba")
print(makePalindrome(string: "abbbbbbbbbbbbbbbbba") == "abbbbbbbbbbbbbbbbba")
print(makePalindrome(string: "abbbbbbbbbbbbbbbbbb") == "abbbbbbbbbbbbbbbbbba")
print(makePalindrome(string: "abbbbbbbbbbbbbbbbbbb") == "ab
if isPalindrome(string: string[0...i]) { // cannot convert value of type 'Array<String.Element>.SubSequence' (aka 'ArraySlice<Character>') to expected argument type 'String'
return string + string[0...i].reversed() // cannot convert return expression of type '[String.Element]' (aka 'Array<Character>') to return type 'String'

func makePalindrome(string: String) -> String {
    // 1. Find the longest postfix of supplied string that is a palindrome.
    let longestPalindromicSuffix = findLongestPalindromicSuffix(string: string)
    // 2. Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.
    let prefix = String(string.prefix(string.count - longestPalindromicSuffix.count))
    return prefix + longestPalindromicSuffix
}

func findLongestPalindromicSuffix(string: String) -> String {
    // 1. Find the longest prefix of a reversed string that is a palindrome.
    let reversedString = String(string.reversed())
    let longestPalindromicPrefix = findLongestPalindromicPrefix(string: reversedString)
    // 2. Return the longest palindromic prefix of a reversed string.
    return String(longestPalindromicPrefix.reversed())
}

func findLongestPalindromicPrefix(string: String) -> String {
    // 1. Find the longest prefix of a string that is a palindrome.
    let longestPalindromicPrefix = findLongestPrefix(string: string, isPalindrome: true)
    // 2. Return the longest palindromic prefix of a string.
    return longestPalindromicPrefix
}

func findLongestPrefix(string: String, isPalindrome: Bool) -> String {
    // 1. Find the longest prefix of a string that satisfies a predicate.
    let longestPrefix = findLongestPrefix(string: string, satisfies: isPalindrome)
    // 2. Return the longest prefix of a string that satisfies a predicate.
    return longestPrefix
}

func findLongestPrefix(string: String, satisfies: Bool) -> String {
    // 1. Find the longest prefix of a string that satisfies a predicate.
    var longestPrefix = ""
    for index in 0..<string.count {
        let prefix = String(string.prefix(index + 1))
        if satisfies(prefix) {
            longestPrefix = prefix
        }
    }
    // 2. Return the longest prefix of a string that satisfies a predicate.
    return longestPrefix
}
```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 {
    // 1. Find the longest postfix of supplied string that is a palindrome.
    let longestPalindromicSuffix = findLongestPalindromicSuffix(string: string)
    // 2. Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.
    let prefix = String(string.prefix(string.count - longestPalindromicSuffix.count))
    return prefix + longestPalindromicSuffix
}

// Find the longest palindromic suffix of a supplied string.
// Algorithm idea is simple:
// - Find the longest prefix of a reversed string that is a palindrome.
// findLongestPalindromicSuffix(string: "") == ""
// findLongestPalindromicSuffix(string: "cat") == "t"
// findLongestPalindromicSuffix(string: "cata") == "a"
func findLongestPalindromicSuffix(string: String) -> String {
    // 1. Find the longest prefix of a reversed string that is a palindrome.
    let reversedString = String(string.reversed())
    let longestPalindromicPrefix = findLongestPalindromicPrefix(string: reversedString)
    // 2. Return the longest palindromic prefix of a reversed string.
    return String(longestPalindromicPrefix.reversed())
}

// Find the longest palindromic prefix of a supplied string.
// Algorithm idea is simple:
// - Find the longest prefix of a string that is a palindrome.
// findLongestPalindromicPrefix(string: "") == ""
// findLongestPalindromicPrefix(string: "cat") == "c"
// findLongestPalindromicPrefix(string: "cata") == "ca"
func findLongestPalindromicPrefix(string: String) -> String {
    // 1. Find the longest prefix of a string that is a palindrome.
    let longestPalindromicPrefix = findLongestPrefix(string: string, isPalindrome: true)
    // 2. Return the longest palindromic prefix of a string.
    return longestPalindromicPrefix
}

// Find the longest prefix of a supplied string that satisfies a supplied predicate.
// Algorithm idea is simple:
// - Find the longest prefix of a string that satisfies a predicate.
// findLongestPrefix(string: "", isPalindrome: true) == ""
// findLongestPrefix(string: "cat", isPalindrome: true) == "c"
// findLongestPrefix(string: "cata", isPalindrome: true) == "ca"
func findLongestPrefix(string: String, isPalindrome: Bool) -> String {
    // 1. Find the longest prefix of a string that satisfies a predicate.
    let longestPrefix = findLongestPrefix(string: string, satisfies: isPalindrome)
    // 2. Return the longest prefix of a string that satisfies a predicate.
    return longestPrefix
}

// Find the longest prefix of a supplied string that satisfies a supplied predicate.
// Algorithm idea is simple:
// - Find the longest prefix of a string that satisfies a predicate.
// findLongestPrefix(string: "", satisfies: true) == ""
// findLongestPrefix(string: "cat", satisfies: true) == "c"
// findLongestPrefix(string: "cata", satisfies: true) == "ca"
func findLongestPrefix(string: String, satisfies: Bool) -> String {
    // 1. Find the longest prefix of a string that satisfies a predicate.
    var longestPrefix = ""
    for index in 0..<string.count {
        let prefix = String(string.prefix(index + 1))
        if satisfies(prefix) {
            longestPrefix = prefix
        }
    }
    // 2. Return the longest prefix of a string that satisfies a predicate.
    return longestPrefix
}

// Check if a supplied string is a palindrome.
// Algorithm idea is simple:
// - Check if a string is equal to a reversed string.
// isPalindrome(string: "") == true
// isPalindrome(string: "c") == true
// isPal
if satisfies(prefix) { // cannot call value of non-function type 'Bool'

func makePalindrome(string: String) -> String {
    let prefix = string.prefix(while: { $0 == $0.reversed().prefix(while: { $0 }).last })
    return prefix + string.dropFirst(prefix.count).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 prefix = string.prefix(while: { $0 == $0.reversed().prefix(while: { $0 }).last })
    return prefix + string.dropFirst(prefix.count).reversed()
}

print(makePalindrome(string: ""))
print(makePalindrome(string: "cat"))
print(makePalindrome(string: "cata"))
```
let prefix = string.prefix(while: { $0 == $0.reversed().prefix(while: { $0 }).last }) // value of type 'String.Element' (aka 'Character') has no member 'reversed'

func makePalindrome(string: String) -> String {
    let string = Array(string)
    let prefix = string.prefix(while: { $0 == $0.reversed().first })
    let postfix = string.suffix(while: { $0 == $0.reversed().first })
    let prefixReversed = prefix.reversed()
    return prefix + postfix + prefixReversed
}
```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 string = Array(string)
    let prefix = string.prefix(while: { $0 == $0.reversed().first })
    let postfix = string.suffix(while: { $0 == $0.reversed().first })
    let prefixReversed = prefix.reversed()
    return prefix + postfix + prefixReversed
}
```
let prefix = string.prefix(while: { $0 == $0.reversed().first }) // value of type 'String.Element' (aka 'Character') has no member 'reversed'
let postfix = string.suffix(while: { $0 == $0.reversed().first }) // no exact matches in call to instance method 'suffix'

func stringXor(a: String, b: String) -> String {
    // ...
}
```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 {
    // ...
}
```
} // missing return in global function expected to return 'String'

func stringXor(a: String, b: String) -> String {
    // ...
}
```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 {
    // ...
}
```
} // missing return in global function expected to return 'String'

func stringXor(a: String, b: String) -> String {
    // ...
}
```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 {
    // ...
}
```
} // missing return in global function expected to return 'String'

func stringXor(a: String, b: String) -> String {
    // your code here
}
```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 {
    // your code here
}
```
} // missing return in global function expected to return 'String'

func stringXor(a: String, b: String) -> String {
    // ...
}
```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 {
    // ...
}
```
} // missing return in global function expected to return 'String'

func stringXor(a: String, b: String) -> String {
    // ...
}
```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 {
    // ...
}
```
} // missing return in global function expected to return 'String'

func stringXor(a: String, b: String) -> String {
    // ...
}
```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 {
    // ...
}
```
} // missing return in global function expected to return 'String'

func stringXor(a: String, b: String) -> String {
    var result = ""
    for (a, b) in zip(a, b) {
        if a == b {
            result += "0"
        } else {
            result += "1"
        }
    }
    return result
}

func isMajorityOne(input: String) -> Bool {
    var count = 0
    for c in input {
        if c == "1" {
            count += 1
        } else {
            count -= 1
        }
    }
    return count > 0
}

func isEqualNumberOfOneAndZero(input: String) -> Bool {
    var count = 0
    for c in input {
        if c == "1" {
            count += 1
        } else {
            count -= 1
        }
    }
    return count == 0
}

func isMajorityZero(input: String) -> Bool {
    var count = 0
    for c in input {
        if c == "1" {
            count += 1
        } else {
            count -= 1
        }
    }
    return count < 0
}

func isGreaterOrEqual(input: String) -> Bool {
    var count = 0
    for c in input {
        if c == "1" {
            count += 1
        } else {
            count -= 1
        }
    }
    return count >= 0
}

func isLessOrEqual(input: String) -> Bool {
    var count = 0
    for c in input {
        if c == "1" {
            count += 1
        } else {
            count -= 1
        }
    }
    return count <= 0
}
```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 (a, b) in zip(a, b) {
        if a == b {
            result += "0"
        } else {
            result += "1"
        }
    }
    return result
}

// Input is a string consisting only of 1s and 0s.
// Return true if number of 1s is greater than number of 0s, otherwise return false.
// isMajorityOne(input: "1011") == true
func isMajorityOne(input: String) -> Bool {
    var count = 0
    for c in input {
        if c == "1" {
            count += 1
        } else {
            count -= 1
        }
    }
    return count > 0
}

// Input is a string consisting only of 1s and 0s.
// Return true if number of 1s is equal to number of 0s, otherwise return false.
// isEqualNumberOfOneAndZero(input: "1011") == false
func isEqualNumberOfOneAndZero(input: String) -> Bool {
    var count = 0
    for c in input {
        if c == "1" {
            count += 1
        } else {
            count -= 1
        }
    }
    return count == 0
}

// Input is a string consisting only of 1s and 0s.
// Return true if number of 1s is less than number of 0s, otherwise return false.
// isMajorityZero(input: "1011") == false
func isMajorityZero(input: String) -> Bool {
    var count = 0
    for c in input {
        if c == "1" {
            count += 1
        } else {
            count -= 1
        }
    }
    return count < 0
}

// Input is a string consisting only of 1s and 0s.
// Return true if number of 1s is greater than or equal to number of 0s, otherwise return false.
// isGreaterOrEqual(input: "1011") == true
func isGreaterOrEqual(input: String) -> Bool {
    var count = 0
    for c in input {
        if c == "1" {
            count += 1
        } else {
            count -= 1
        }
    }
    return count >= 0
}

// Input is a string consisting only of 1s and 0s.
// Return true if number of 1s is less than or equal to number of 0s, otherwise return false.
// isLessOrEqual(input: "1011") == false
func isLessOrEqual(input: String) -> Bool {
    var count = 0
    for c in input {
        if c == "1" {
            count += 1
        } else {
            count -= 1
        }
    }
    return count <= 0
}

// Input is a string consisting only of 1s and 0s.
// Return true if number of 1s is greater than number of 0s, otherwise return false.
// isMajorityOne(input: "1011") == true
func isMajorityOne(input: String) -> Bool {
    var count = 0
    for c in input {
        if c == "1" {
            count += 1
        } else {
            count -= 1
        }
    }
    return count > 0
}

// Input is a string consisting only of 1s and 0s.
// Return true if number of 1s is equal to number of 0s, otherwise return false.
// isEqualNumberOfOneAndZero(input: "1011") == false
func isEqualNumberOfOneAndZero(input: String) -> Bool {
    var count = 0
    for c in input {
        if c == "1" {
            count += 1
        } else {
            count -= 1
        }
    }
    return count == 0
}

// Input is a string consisting only of 1s and 0s.
// Return true if number of 1s is less than number of 0s, otherwise return false

func stringXor(a: String, b: String) -> String {
    return ""
}
```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 {
    return ""
}
```
 // XCTAssertTrue failed

func stringXor(a: String, b: String) -> String {
    return ""
}
```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 {
    return ""
}
```
 // XCTAssertTrue failed

func longest(strings: [String]) -> 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? {
    // ...
}
```
} // missing return in global function expected to return 'String?'

func longest(strings: [String]) -> 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? {
    // ...
}
```
} // missing return in global function expected to return 'String?'

func longest(strings: [String]) -> 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? {
    // ...
}
```
} // missing return in global function expected to return 'String?'

func longest(strings: [String]) -> 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? {
    // ...
}
```
} // missing return in global function expected to return 'String?'

func longest(strings: [String]) -> 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? {
    // ...
}
```
} // missing return in global function expected to return 'String?'

func longest(strings: [String]) -> 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? {
    // ...
}
```
} // missing return in global function expected to return 'String?'

func longest(strings: [String]) -> 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? {
    // ...
}
```
} // missing return in global function expected to return 'String?'

func longest(strings: [String]) -> String? {
    // Your code here
}
```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? {
    // Your code here
}
```
} // missing return in global function expected to return 'String?'

func longest(strings: [String]) -> 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? {
    // ...
}
```
} // missing return in global function expected to return 'String?'

func longest(strings: [String]) -> String? {
    // TODO: Implement
    return nil
}
```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? {
    // TODO: Implement
    return nil
}
```
 // XCTAssertTrue failed

func greatestCommonDivisor(a: Int, b: Int) -> Int {
    // 1. Implement the function
}
```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 {
    // 1. Implement the function
}
```
} // missing return in global function expected to return 'Int'

func greatestCommonDivisor(a: Int, b: Int) -> Int {
    if b == 0 {
        return a
    }
    return greatestCommonDivisor(a: b, b: a % b)
}

func leastCommonMultiple(a: Int, b: Int) -> Int {
    return (a * b) / greatestCommonDivisor(a: a, b: b)
}

func greatestCommonDivisor(_ numbers: [Int]) -> Int {
    if numbers.count == 0 {
        return 1
    }
    if numbers.count == 1 {
        return numbers[0]
    }
    if numbers.count == 2 {
        return greatestCommonDivisor(a: numbers[0], b: numbers[1])
    }
    return greatestCommonDivisor(a: numbers[0], b: greatestCommonDivisor(numbers[1...]))
}

func leastCommonMultiple(_ numbers: [Int]) -> Int {
    if numbers.count == 0 {
        return 1
    }
    if numbers.count == 1 {
        return numbers[0]
    }
    if numbers.count == 2 {
        return leastCommonMultiple(a: numbers[0], b: numbers[1])
    }
    return leastCommonMultiple(a: numbers[0], b: leastCommonMultiple(numbers[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 {
    if b == 0 {
        return a
    }
    return greatestCommonDivisor(a: b, b: a % b)
}

// Return a least common multiple of two integers a and b
// leastCommonMultiple(a: 3, b: 5) == 15
// leastCommonMultiple(a: 25, b: 15) == 75
func leastCommonMultiple(a: Int, b: Int) -> Int {
    return (a * b) / greatestCommonDivisor(a: a, b: b)
}

// Return a greatest common divisor of an array of integers
// greatestCommonDivisor([3, 5]) == 1
// greatestCommonDivisor([25, 15]) == 5
func greatestCommonDivisor(_ numbers: [Int]) -> Int {
    if numbers.count == 0 {
        return 1
    }
    if numbers.count == 1 {
        return numbers[0]
    }
    if numbers.count == 2 {
        return greatestCommonDivisor(a: numbers[0], b: numbers[1])
    }
    return greatestCommonDivisor(a: numbers[0], b: greatestCommonDivisor(numbers[1...]))
}

// Return a least common multiple of an array of integers
// leastCommonMultiple([3, 5]) == 15
// leastCommonMultiple([25, 15]) == 75
func leastCommonMultiple(_ numbers: [Int]) -> Int {
    if numbers.count == 0 {
        return 1
    }
    if numbers.count == 1 {
        return numbers[0]
    }
    if numbers.count == 2 {
        return leastCommonMultiple(a: numbers[0], b: numbers[1])
    }
    return leastCommonMultiple(a: numbers[0], b: leastCommonMultiple(numbers[1...]))
}

// Return a greatest common divisor of an array of integers
// greatestCommonDivisor([3, 5]) == 1
// greatestCommonDivisor([25, 15]) == 5
func greatestCommonDivisor(_ numbers: [Int]) -> Int {
    if numbers.count == 0 {
        return 1
    }
    if numbers.count == 1 {
        return numbers[0]
    }
    if numbers.count == 2 {
        return greatestCommonDivisor(a: numbers[0], b: numbers[1])
    }
    return greatestCommonDivisor(a: numbers[0], b: greatestCommonDivisor(numbers[1...]))
}

// Return a least common multiple of an array of integers
// leastCommonMultiple([3, 5]) == 15
// leastCommonMultiple([25, 15]) == 75
func leastCommonMultiple(_ numbers: [Int]) -> Int {
    if numbers.count == 0 {
        return 1
    }
    if numbers.count == 1 {
        return numbers[0]
    }
    if numbers.count == 2 {
        return leastCommonMultiple(a: numbers[0], b: numbers[1])
    }
    return leastCommonMultiple(a: numbers[0], b: leastCommonMultiple(numbers[1...]))
}

// Return a greatest common divisor of an array of integers
// greatestCommonDivisor([3, 5]) == 1
// greatestCommonDivisor([25, 15]) == 5
func greatestCommonDivisor(_ numbers: [Int]) -> Int {
    if numbers.count == 0 {
        return 1
    }
    if numbers.count == 1 {
        return numbers[0]
    }
    if numbers.count == 2 {
        return greatestCommonDivisor(a: numbers[0], b: numbers[1])
    }
    return greatestCommonDivisor(a: numbers[0], b: greatestCommonDivisor(numbers[1...]))
}

// Return a least common multiple of an array of integers
// leastCommonMultiple([3, 5]) == 15
// leastCommonMultiple([25, 15]) == 75
func leastCommonMultiple(_ numbers: [Int]) -> Int {
    if numbers.count == 0 {
        return 1
    }
    if numbers.count == 
return greatestCommonDivisor(a: numbers[0], b: greatestCommonDivisor(numbers[1...])) // cannot convert value of type 'Array<Int>.SubSequence' (aka 'ArraySlice<Int>') to expected argument type '[Int]'
return leastCommonMultiple(a: numbers[0], b: leastCommonMultiple(numbers[1...])) // cannot convert value of type 'Array<Int>.SubSequence' (aka 'ArraySlice<Int>') to expected argument type '[Int]'

func greatestCommonDivisor(a: Int, b: Int) -> Int {
    if b == 0 {
        return a
    }
    return greatestCommonDivisor(a: b, b: a % b)
}

func leastCommonMultiple(a: Int, b: Int) -> Int {
    return a * b / greatestCommonDivisor(a: a, b: b)
}

func greatestCommonDivisor(_ array: [Int]) -> Int {
    if array.count == 1 {
        return array[0]
    }
    return greatestCommonDivisor(a: array[0], b: greatestCommonDivisor(Array(array.dropFirst())))
}

func leastCommonMultiple(_ array: [Int]) -> Int {
    if array.count == 1 {
        return array[0]
    }
    return leastCommonMultiple(a: array[0], b: leastCommonMultiple(Array(array.dropFirst())))
}

func greatestCommonDivisor(_ array: [Int]) -> Int {
    return array.reduce(1, greatestCommonDivisor)
}

func leastCommonMultiple(_ array: [Int]) -> Int {
    return array.reduce(1, leastCommonMultiple)
}

func greatestCommonDivisor(_ array: [Int]) -> Int {
    return array.reduce(1, { $0 / greatestCommonDivisor(a: $0, b: $1) * $1 })
}

func leastCommonMultiple(_ array: [Int]) -> Int {
    return array.reduce(1, { $0 * leastCommonDivisor(a: $0, b: $1) / $1 })
}

func greatestCommonDivisor(_ array: [Int]) -> Int {
    return array.reduce(1, { $0 / leastCommonMultiple(a: $0, b: $1) * $1 })
}

func leastCommonMultiple(_ array: [Int]) -> Int {
    return array.reduce(1, { $0 * greatestCommonDivisor(a: $0, b: $1) / $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 {
    if b == 0 {
        return a
    }
    return greatestCommonDivisor(a: b, b: a % b)
}

// Return a least common multiple of two integers a and b
// leastCommonMultiple(a: 3, b: 5) == 15
// leastCommonMultiple(a: 25, b: 15) == 75
func leastCommonMultiple(a: Int, b: Int) -> Int {
    return a * b / greatestCommonDivisor(a: a, b: b)
}

// Return a greatest common divisor of an array of integers
// greatestCommonDivisor([3, 5]) == 1
// greatestCommonDivisor([25, 15]) == 5
func greatestCommonDivisor(_ array: [Int]) -> Int {
    if array.count == 1 {
        return array[0]
    }
    return greatestCommonDivisor(a: array[0], b: greatestCommonDivisor(Array(array.dropFirst())))
}

// Return a least common multiple of an array of integers
// leastCommonMultiple([3, 5]) == 15
// leastCommonMultiple([25, 15]) == 75
func leastCommonMultiple(_ array: [Int]) -> Int {
    if array.count == 1 {
        return array[0]
    }
    return leastCommonMultiple(a: array[0], b: leastCommonMultiple(Array(array.dropFirst())))
}

// Return a greatest common divisor of an array of integers
// greatestCommonDivisor([3, 5]) == 1
// greatestCommonDivisor([25, 15]) == 5
func greatestCommonDivisor(_ array: [Int]) -> Int {
    return array.reduce(1, greatestCommonDivisor)
}

// Return a least common multiple of an array of integers
// leastCommonMultiple([3, 5]) == 15
// leastCommonMultiple([25, 15]) == 75
func leastCommonMultiple(_ array: [Int]) -> Int {
    return array.reduce(1, leastCommonMultiple)
}

// Return a greatest common divisor of an array of integers
// greatestCommonDivisor([3, 5]) == 1
// greatestCommonDivisor([25, 15]) == 5
func greatestCommonDivisor(_ array: [Int]) -> Int {
    return array.reduce(1, { $0 / greatestCommonDivisor(a: $0, b: $1) * $1 })
}

// Return a least common multiple of an array of integers
// leastCommonMultiple([3, 5]) == 15
// leastCommonMultiple([25, 15]) == 75
func leastCommonMultiple(_ array: [Int]) -> Int {
    return array.reduce(1, { $0 * leastCommonDivisor(a: $0, b: $1) / $1 })
}

// Return a greatest common divisor of an array of integers
// greatestCommonDivisor([3, 5]) == 1
// greatestCommonDivisor([25, 15]) == 5
func greatestCommonDivisor(_ array: [Int]) -> Int {
    return array.reduce(1, { $0 / leastCommonMultiple(a: $0, b: $1) * $1 })
}

// Return a least common multiple of an array of integers
// leastCommonMultiple([3, 5]) == 15
// leastCommonMultiple([25, 15]) == 75
func leastCommonMultiple(_ array: [Int]) -> Int {
    return array.reduce(1, { $0 * greatestCommonDivisor(a: $0, b: $1) / $1 })
}

// Return a greatest common divisor of an array of integers
// greatestCommonDivisor([3, 5]) == 1
// greatestCommonDivisor([25, 15]) == 5
func greatestCommonDivisor(_ array: [Int]) -> Int {
    return array.reduce(1, { $0 / leastCommonMultiple(a: $0, b: $1) * $1 })
}

// Return a least common multiple of an array of integers
// leastCommonMultiple([3, 5]) == 15
// leastCommonMultiple([25, 15]) == 75
func leastCommonMultiple(_ array: [Int]) ->
func greatestCommonDivisor(_ array: [Int]) -> Int { // invalid redeclaration of 'greatestCommonDivisor'
func leastCommonMultiple(_ array: [Int]) -> Int { // invalid redeclaration of 'leastCommonMultiple'
func greatestCommonDivisor(_ array: [Int]) -> Int { // invalid redeclaration of 'greatestCommonDivisor'
func leastCommonMultiple(_ array: [Int]) -> Int { // invalid redeclaration of 'leastCommonMultiple'
return array.reduce(1, { $0 * leastCommonDivisor(a: $0, b: $1) / $1 }) // cannot find 'leastCommonDivisor' in scope
func greatestCommonDivisor(_ array: [Int]) -> Int { // invalid redeclaration of 'greatestCommonDivisor'
func leastCommonMultiple(_ array: [Int]) -> Int { // invalid redeclaration of 'leastCommonMultiple'

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 b != 0 {
        let t = b
        b = a % b
        a = t
    }
    return a
}

func greatestCommonDivisor(a: Int, b: Int) -> Int {
    if b == 0 {
        return a
    } else {
        return greatestCommonDivisor(a: b, b: a % b)
    }
}

func greatestCommonDivisor(a: Int, b: Int) -> Int {
    return b == 0 ? a : greatestCommonDivisor(a: b, b: a % b)
}
```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
}

// 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 b != 0 {
        let t = b
        b = a % b
        a = t
    }
    return a
}

// 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 b == 0 {
        return a
    } else {
        return greatestCommonDivisor(a: b, b: a % b)
    }
}

// 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 {
    return b == 0 ? a : greatestCommonDivisor(a: b, b: a % b)
}

// 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 {
    return b == 0 ? a : greatestCommonDivisor(a: b, b: a % b)
}

// 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 {
    return b == 0 ? a : greatestCommonDivisor(a: b, b: a % b)
}

// 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 {
    return b == 0 ? a : greatestCommonDivisor(a: b, b: a % b)
}

// 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 {
    return b == 0 ? a : greatestCommonDivisor(a: b, b: a % b)
}

// 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 {
    return b == 0 ? a : greatestCommonDivisor(a: b, b: a % b)
}

// 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 {
    return b == 0 ? a : greatestCommonDivisor(a: b, b: a % b)
}

// Return a greatest common divisor of two integers a and b
// greatestCommon
func greatestCommonDivisor(a: Int, b: Int) -> Int { // invalid redeclaration of 'greatestCommonDivisor(a:b:)'
func greatestCommonDivisor(a: Int, b: Int) -> Int { // invalid redeclaration of 'greatestCommonDivisor(a:b:)'
func greatestCommonDivisor(a: Int, b: Int) -> Int { // invalid redeclaration of 'greatestCommonDivisor(a:b:)'

func greatestCommonDivisor(a: Int, b: Int) -> Int {
    if b == 0 {
        return a
    }
    return greatestCommonDivisor(a: b, b: a % b)
}

func leastCommonMultiple(a: Int, b: Int) -> Int {
    return a * b / greatestCommonDivisor(a: a, b: b)
}

func greatestCommonDivisor(_ array: [Int]) -> Int {
    if array.count == 1 {
        return array[0]
    }
    return greatestCommonDivisor(a: array[0], b: greatestCommonDivisor(Array(array.dropFirst())))
}

func leastCommonMultiple(_ array: [Int]) -> Int {
    if array.count == 1 {
        return array[0]
    }
    return leastCommonMultiple(a: array[0], b: leastCommonMultiple(Array(array.dropFirst())))
}
```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 b == 0 {
        return a
    }
    return greatestCommonDivisor(a: b, b: a % b)
}

// Return a least common multiple of two integers a and b
// leastCommonMultiple(a: 3, b: 5) == 15
// leastCommonMultiple(a: 25, b: 15) == 75
func leastCommonMultiple(a: Int, b: Int) -> Int {
    return a * b / greatestCommonDivisor(a: a, b: b)
}

// Return a greatest common divisor of an array of integers
// greatestCommonDivisor([3, 5]) == 1
// greatestCommonDivisor([25, 15]) == 5
func greatestCommonDivisor(_ array: [Int]) -> Int {
    if array.count == 1 {
        return array[0]
    }
    return greatestCommonDivisor(a: array[0], b: greatestCommonDivisor(Array(array.dropFirst())))
}

// Return a least common multiple of an array of integers
// leastCommonMultiple([3, 5]) == 15
// leastCommonMultiple([25, 15]) == 75
func leastCommonMultiple(_ array: [Int]) -> Int {
    if array.count == 1 {
        return array[0]
    }
    return leastCommonMultiple(a: array[0], b: leastCommonMultiple(Array(array.dropFirst())))
}

// Return a greatest common divisor of an array of integers
// greatestCommonDivisor([3, 5]) == 1
// greatestCommonDivisor([25, 15]) == 5
func greatestCommonDivisor(_ array: [Int]) -> Int {
    if array.count == 1 {
        return array[0]
    }
    return greatestCommonDivisor(a: array[0], b: greatestCommonDivisor(Array(array.dropFirst())))
}

// Return a least common multiple of an array of integers
// leastCommonMultiple([3, 5]) == 15
// leastCommonMultiple([25, 15]) == 75
func leastCommonMultiple(_ array: [Int]) -> Int {
    if array.count == 1 {
        return array[0]
    }
    return leastCommonMultiple(a: array[0], b: leastCommonMultiple(Array(array.dropFirst())))
}

// Return a greatest common divisor of an array of integers
// greatestCommonDivisor([3, 5]) == 1
// greatestCommonDivisor([25, 15]) == 5
func greatestCommonDivisor(_ array: [Int]) -> Int {
    if array.count == 1 {
        return array[0]
    }
    return greatestCommonDivisor(a: array[0], b: greatestCommonDivisor(Array(array.dropFirst())))
}

// Return a least common multiple of an array of integers
// leastCommonMultiple([3, 5]) == 15
// leastCommonMultiple([25, 15]) == 75
func leastCommonMultiple(_ array: [Int]) -> Int {
    if array.count == 1 {
        return array[0]
    }
    return leastCommonMultiple(a: array[0], b: leastCommonMultiple(Array(array.dropFirst())))
}

// Return a greatest common divisor of an array of integers
// greatestCommonDivisor([3, 5]) == 1
// greatestCommonDivisor([25, 15]) == 5
func greatestCommonDivisor(_ array: [Int]) -> Int {
    if array.count == 1 {
        return array[0]
    }
    return greatestCommonDivisor(a: array[0], b: greatestCommonDivisor(Array(array.dropFirst())))
}

// Return a least common multiple of an array of integers
// leastCommonMultiple([3, 5]) == 15
// leastCommonMultiple([25, 15]) == 75
func leastCommonMultiple(_ array: [Int]) -> Int {
    if array.count == 1 {
        return array[0]
    }
    return leastCommonMultiple(a: array[0], b: leastCommonMultiple(Array(array.dropFirst())))
}

// Return a greatest common divisor of an

func greatestCommonDivisor(a: Int, b: Int) -> Int {
    var a = a
    var b = b
    while b != 0 {
        let temp = b
        b = a % b
        a = temp
    }
    return a
}

func leastCommonMultiple(a: Int, b: Int) -> Int {
    return (a * b) / greatestCommonDivisor(a: a, b: b)
}

func greatestCommonDivisor(_ numbers: [Int]) -> Int {
    var result = numbers[0]
    for number in numbers {
        result = greatestCommonDivisor(a: result, b: number)
    }
    return result
}

func leastCommonMultiple(_ numbers: [Int]) -> Int {
    var result = numbers[0]
    for number in numbers {
        result = leastCommonMultiple(a: result, b: number)
    }
    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 a = a
    var b = b
    while b != 0 {
        let temp = b
        b = a % b
        a = temp
    }
    return a
}

// Return a least common multiple of two integers a and b
// leastCommonMultiple(a: 3, b: 5) == 15
// leastCommonMultiple(a: 25, b: 15) == 75
func leastCommonMultiple(a: Int, b: Int) -> Int {
    return (a * b) / greatestCommonDivisor(a: a, b: b)
}

// Return a greatest common divisor of an array of integers
// greatestCommonDivisor([3, 5]) == 1
// greatestCommonDivisor([25, 15]) == 5
func greatestCommonDivisor(_ numbers: [Int]) -> Int {
    var result = numbers[0]
    for number in numbers {
        result = greatestCommonDivisor(a: result, b: number)
    }
    return result
}

// Return a least common multiple of an array of integers
// leastCommonMultiple([3, 5]) == 15
// leastCommonMultiple([25, 15]) == 75
func leastCommonMultiple(_ numbers: [Int]) -> Int {
    var result = numbers[0]
    for number in numbers {
        result = leastCommonMultiple(a: result, b: number)
    }
    return result
}

// Return a greatest common divisor of an array of integers
// greatestCommonDivisor([3, 5]) == 1
// greatestCommonDivisor([25, 15]) == 5
func greatestCommonDivisor(_ numbers: [Int]) -> Int {
    var result = numbers[0]
    for number in numbers {
        result = greatestCommonDivisor(a: result, b: number)
    }
    return result
}

// Return a least common multiple of an array of integers
// leastCommonMultiple([3, 5]) == 15
// leastCommonMultiple([25, 15]) == 75
func leastCommonMultiple(_ numbers: [Int]) -> Int {
    var result = numbers[0]
    for number in numbers {
        result = leastCommonMultiple(a: result, b: number)
    }
    return result
}

// Return a greatest common divisor of an array of integers
// greatestCommonDivisor([3, 5]) == 1
// greatestCommonDivisor([25, 15]) == 5
func greatestCommonDivisor(_ numbers: [Int]) -> Int {
    var result = numbers[0]
    for number in numbers {
        result = greatestCommonDivisor(a: result, b: number)
    }
    return result
}

// Return a least common multiple of an array of integers
// leastCommonMultiple([3, 5]) == 15
// leastCommonMultiple([25, 15]) == 75
func leastCommonMultiple(_ numbers: [Int]) -> Int {
    var result = numbers[0]
    for number in numbers {
        result = leastCommonMultiple(a: result, b: number)
    }
    return result
}

// Return a greatest common divisor of an array of integers
// greatestCommonDivisor([3, 5]) == 1
// greatestCommonDivisor([25, 15]) == 5
func greatestCommonDivisor(_ numbers: [Int]) -> Int {
    var result = numbers[0]
    for number in numbers {
        result = greatestCommonDivisor(a: result, b: number)
    }
    return result
}

// Return a least common multiple of an array of integers
// leastCommonMultiple([3, 5]) == 15
// leastCommonMultiple([25, 15]) == 75
func leastCommonMultiple(_ numbers: [Int]) -> Int {
    var result = numbers[0]
    for number in numbers {
        result = leastCommonMultiple(a: result, b: number)
    }
    return result
}

// Return a greatest common divisor of an array of integers
// greatestCommonDivisor([3, 5]) == 1
// greatestCommonDivisor([25, 15]) == 5
func greatestCommonDivisor(_ numbers: [Int]) -> Int {
    var result = numbers[0]

func greatestCommonDivisor(a: Int, b: Int) -> Int {
    // 1. Implement the function
    return 0
}
```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 {
    // 1. Implement the function
    return 0
}
```
 // XCTAssertTrue failed

func greatestCommonDivisor(a: Int, b: Int) -> Int {
    // 1. Implement the function
    return 0
}
```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 {
    // 1. Implement the function
    return 0
}
```
 // XCTAssertTrue failed

func greatestCommonDivisor(a: Int, b: Int) -> Int {
    if a == 0 { return b }
    if b == 0 { return a }
    if a == b { return a }
    if a > b { return greatestCommonDivisor(a: a - b, b: b) }
    return greatestCommonDivisor(a: a, b: b - a)
}

func leastCommonMultiple(a: Int, b: Int) -> Int {
    return a * b / greatestCommonDivisor(a: a, b: b)
}

func greatestCommonDivisor(_ array: [Int]) -> Int {
    if array.count == 0 { return 0 }
    if array.count == 1 { return array[0] }
    var result = array[0]
    for i in 1..<array.count {
        result = greatestCommonDivisor(a: result, b: array[i])
    }
    return result
}

func leastCommonMultiple(_ array: [Int]) -> Int {
    if array.count == 0 { return 0 }
    if array.count == 1 { return array[0] }
    var result = array[0]
    for i in 1..<array.count {
        result = leastCommonMultiple(a: result, b: array[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 {
    if a == 0 { return b }
    if b == 0 { return a }
    if a == b { return a }
    if a > b { return greatestCommonDivisor(a: a - b, b: b) }
    return greatestCommonDivisor(a: a, b: b - a)
}

// Return a least common multiple of two integers a and b
// leastCommonMultiple(a: 3, b: 5) == 15
// leastCommonMultiple(a: 25, b: 15) == 75
func leastCommonMultiple(a: Int, b: Int) -> Int {
    return a * b / greatestCommonDivisor(a: a, b: b)
}

// Return a greatest common divisor of an array of integers
// greatestCommonDivisor([3, 5, 9]) == 1
// greatestCommonDivisor([25, 15, 30]) == 5
func greatestCommonDivisor(_ array: [Int]) -> Int {
    if array.count == 0 { return 0 }
    if array.count == 1 { return array[0] }
    var result = array[0]
    for i in 1..<array.count {
        result = greatestCommonDivisor(a: result, b: array[i])
    }
    return result
}

// Return a least common multiple of an array of integers
// leastCommonMultiple([3, 5, 9]) == 45
// leastCommonMultiple([25, 15, 30]) == 75
func leastCommonMultiple(_ array: [Int]) -> Int {
    if array.count == 0 { return 0 }
    if array.count == 1 { return array[0] }
    var result = array[0]
    for i in 1..<array.count {
        result = leastCommonMultiple(a: result, b: array[i])
    }
    return result
}

// Return a greatest common divisor of an array of integers
// greatestCommonDivisor([3, 5, 9]) == 1
// greatestCommonDivisor([25, 15, 30]) == 5
func greatestCommonDivisor(_ array: [Int]) -> Int {
    if array.count == 0 { return 0 }
    if array.count == 1 { return array[0] }
    var result = array[0]
    for i in 1..<array.count {
        result = greatestCommonDivisor(a: result, b: array[i])
    }
    return result
}

// Return a least common multiple of an array of integers
// leastCommonMultiple([3, 5, 9]) == 45
// leastCommonMultiple([25, 15, 30]) == 75
func leastCommonMultiple(_ array: [Int]) -> Int {
    if array.count == 0 { return 0 }
    if array.count == 1 { return array[0] }
    var result = array[0]
    for i in 1..<array.count {
        result = leastCommonMultiple(a: result, b: array[i])
    }
    return result
}

// Return a greatest common divisor of an array of integers
// greatestCommonDivisor([3, 5, 9]) == 1
// greatestCommonDivisor([25, 15, 30]) == 5
func greatestCommonDivisor(_ array: [Int]) -> Int {
    if array.count == 0 { return 0 }
    if array.count == 1 { return array[0] }
    var result = array[0]
    for i in 1..<array.count {
        result = greatestCommonDivisor(a: result, b: array[i])
    }
    return result
}

// Return a least common multiple of an array of integers
// leastCommonMultiple([3, 5, 9]) == 45
// leastCommonMultiple([25, 15, 30]) == 75
func leastCommonMultiple(_ array: [Int]) -> Int {
    if array.count == 0 { return 0 }
    if array.count == 1 { return array[0] }
    var result = array[0]
    for i in 1..<array.

func greatestCommonDivisor(a: Int, b: Int) -> Int {
    var a = a
    var b = b
    while b != 0 {
        let t = b
        b = a % b
        a = t
    }
    return a
}

func leastCommonMultiple(a: Int, b: Int) -> Int {
    return a * b / greatestCommonDivisor(a: a, b: b)
}

func greatestCommonDivisor(_ array: [Int]) -> Int {
    var result = array[0]
    for i in 1..<array.count {
        result = greatestCommonDivisor(a: result, b: array[i])
    }
    return result
}

func leastCommonMultiple(_ array: [Int]) -> Int {
    var result = array[0]
    for i in 1..<array.count {
        result = leastCommonMultiple(a: result, b: array[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 a = a
    var b = b
    while b != 0 {
        let t = b
        b = a % b
        a = t
    }
    return a
}

// Return a least common multiple of two integers a and b
// leastCommonMultiple(a: 3, b: 5) == 15
// leastCommonMultiple(a: 25, b: 15) == 75
func leastCommonMultiple(a: Int, b: Int) -> Int {
    return a * b / greatestCommonDivisor(a: a, b: b)
}

// Return a greatest common divisor of an array of integers
// greatestCommonDivisor([3, 5]) == 1
// greatestCommonDivisor([25, 15]) == 5
func greatestCommonDivisor(_ array: [Int]) -> Int {
    var result = array[0]
    for i in 1..<array.count {
        result = greatestCommonDivisor(a: result, b: array[i])
    }
    return result
}

// Return a least common multiple of an array of integers
// leastCommonMultiple([3, 5]) == 15
// leastCommonMultiple([25, 15]) == 75
func leastCommonMultiple(_ array: [Int]) -> Int {
    var result = array[0]
    for i in 1..<array.count {
        result = leastCommonMultiple(a: result, b: array[i])
    }
    return result
}

// Return a greatest common divisor of an array of integers
// greatestCommonDivisor([3, 5]) == 1
// greatestCommonDivisor([25, 15]) == 5
func greatestCommonDivisor(_ array: [Int]) -> Int {
    var result = array[0]
    for i in 1..<array.count {
        result = greatestCommonDivisor(a: result, b: array[i])
    }
    return result
}

// Return a least common multiple of an array of integers
// leastCommonMultiple([3, 5]) == 15
// leastCommonMultiple([25, 15]) == 75
func leastCommonMultiple(_ array: [Int]) -> Int {
    var result = array[0]
    for i in 1..<array.count {
        result = leastCommonMultiple(a: result, b: array[i])
    }
    return result
}

// Return a greatest common divisor of an array of integers
// greatestCommonDivisor([3, 5]) == 1
// greatestCommonDivisor([25, 15]) == 5
func greatestCommonDivisor(_ array: [Int]) -> Int {
    var result = array[0]
    for i in 1..<array.count {
        result = greatestCommonDivisor(a: result, b: array[i])
    }
    return result
}

// Return a least common multiple of an array of integers
// leastCommonMultiple([3, 5]) == 15
// leastCommonMultiple([25, 15]) == 75
func leastCommonMultiple(_ array: [Int]) -> Int {
    var result = array[0]
    for i in 1..<array.count {
        result = leastCommonMultiple(a: result, b: array[i])
    }
    return result
}

// Return a greatest common divisor of an array of integers
// greatestCommonDivisor([3, 5]) == 1
// greatestCommonDivisor([25, 15]) == 5
func greatestCommonDivisor(_ array: [Int]) -> Int {
    var result = array[0]
    for i in 1..<array.count {
        result = greatestCommonDivisor(a: result, b: array[i])
    }
    return result
}

// Return a least common multiple of an array of integers
// leastCommonMultiple([3, 5]) == 15
// leastCommonMultiple([25, 15]) == 75
func leastCommonMultiple(_ array: [Int]) -> Int {
    var result = array[0]
    for i in 1..<array.count {
        result = leastCommonMultiple(a: result, b: array[i])
    }
    return result
}

func allPrefixes(string: String) -> [String] {
    var result: [String] = []
    for index in 0..<string.count {
        let prefix = String(string[string.startIndex..<string.index(after: string.startIndex.advanced(by: index))])
        result.append(prefix)
    }
    return result
}

func allSuffixes(string: String) -> [String] {
    var result: [String] = []
    for index in 0..<string.count {
        let suffix = String(string[string.index(after: string.startIndex.advanced(by: index))..<string.endIndex])
        result.append(suffix)
    }
    return result
}

func allSubstrings(string: String) -> [String] {
    var result: [String] = []
    for index in 0..<string.count {
        let substring = String(string[string.startIndex..<string.index(after: string.startIndex.advanced(by: index))])
        result.append(substring)
        for index in 0..<string.count {
            let substring = String(string[string.index(after: string.startIndex.advanced(by: index))..<string.endIndex])
            result.append(substring)
        }
    }
    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 result: [String] = []
    for index in 0..<string.count {
        let prefix = String(string[string.startIndex..<string.index(after: string.startIndex.advanced(by: index))])
        result.append(prefix)
    }
    return result
}

// Return array of all suffixes from shortest to longest of the input string
// allSuffixes(string: "abc") == ["c", "bc", "abc"]
func allSuffixes(string: String) -> [String] {
    var result: [String] = []
    for index in 0..<string.count {
        let suffix = String(string[string.index(after: string.startIndex.advanced(by: index))..<string.endIndex])
        result.append(suffix)
    }
    return result
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var result: [String] = []
    for index in 0..<string.count {
        let substring = String(string[string.startIndex..<string.index(after: string.startIndex.advanced(by: index))])
        result.append(substring)
        for index in 0..<string.count {
            let substring = String(string[string.index(after: string.startIndex.advanced(by: index))..<string.endIndex])
            result.append(substring)
        }
    }
    return result
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var result: [String] = []
    for index in 0..<string.count {
        let substring = String(string[string.startIndex..<string.index(after: string.startIndex.advanced(by: index))])
        result.append(substring)
        for index in 0..<string.count {
            let substring = String(string[string.index(after: string.startIndex.advanced(by: index))..<string.endIndex])
            result.append(substring)
        }
    }
    return result
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var result: [String] = []
    for index in 0..<string.count {
        let substring = String(string[string.startIndex..<string.index(after: string.startIndex.advanced(by: index))])
        result.append(substring)
        for index in 0..<string.count {
            let substring = String(string[string.index(after: string.startIndex.advanced(by: index))..<string.endIndex])
            result.append(substring)
        }
    }
    return result
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var result: [String] = []
    for index in 0..<string.count {
        let substring = String(string[string.startIndex..<string.index(after: string.startIndex.advanced(by: index))])
        result.append(substring)
        for index in 0..<string.count {
            let substring = String(string[string.index(after: string.startIndex.advanced(by: index))..<string.
let prefix = String(string[string.startIndex..<string.index(after: string.startIndex.advanced(by: index))]) // value of type 'String.Index' has no member 'advanced'
let suffix = String(string[string.index(after: string.startIndex.advanced(by: index))..<string.endIndex]) // value of type 'String.Index' has no member 'advanced'
let substring = String(string[string.startIndex..<string.index(after: string.startIndex.advanced(by: index))]) // value of type 'String.Index' has no member 'advanced'
let substring = String(string[string.index(after: string.startIndex.advanced(by: index))..<string.endIndex]) // value of type 'String.Index' has no member 'advanced'

func allPrefixes(string: String) -> [String] {
    var result: [String] = []
    for i in 0...string.count {
        result.append(String(string[..<i]))
    }
    return result
}

func allSuffixes(string: String) -> [String] {
    var result: [String] = []
    for i in 0...string.count {
        result.append(String(string[i...]))
    }
    return result
}

func allSubstrings(string: String) -> [String] {
    var result: [String] = []
    for i in 0...string.count {
        for j in i...string.count {
            result.append(String(string[i..<j]))
        }
    }
    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 result: [String] = []
    for i in 0...string.count {
        result.append(String(string[..<i]))
    }
    return result
}

// Return array of all suffixes from shortest to longest of the input string
// allSuffixes(string: "abc") == ["c", "bc", "abc"]
func allSuffixes(string: String) -> [String] {
    var result: [String] = []
    for i in 0...string.count {
        result.append(String(string[i...]))
    }
    return result
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var result: [String] = []
    for i in 0...string.count {
        for j in i...string.count {
            result.append(String(string[i..<j]))
        }
    }
    return result
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var result: [String] = []
    for i in 0...string.count {
        for j in i...string.count {
            result.append(String(string[i..<j]))
        }
    }
    return result
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var result: [String] = []
    for i in 0...string.count {
        for j in i...string.count {
            result.append(String(string[i..<j]))
        }
    }
    return result
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var result: [String] = []
    for i in 0...string.count {
        for j in i...string.count {
            result.append(String(string[i..<j]))
        }
    }
    return result
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var result: [String] = []
    for i in 0...string.count {
        for j in i...string.count {
            result.append(String(string[i..<j]))
        }
    }
    return result
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var result: [String] = []
    for i in 0...string.count {
        for j in i...string.count {
            result.append(String(string[i..<j]))
        }
    }
    return result
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
result.append(String(string[..<i])) // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.
result.append(String(string[i...])) // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.
result.append(String(string[i..<j])) // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.

func allPrefixes(string: String) -> [String] {
    var result: [String] = []
    for i in 0...string.count {
        result.append(String(string[string.startIndex..<string.index(string.startIndex, offsetBy: i)]))
    }
    return result
}

func allSuffixes(string: String) -> [String] {
    var result: [String] = []
    for i in 0...string.count {
        result.append(String(string[string.index(string.endIndex, offsetBy: -i)..<string.endIndex]))
    }
    return result
}

func allSubstrings(string: String) -> [String] {
    var result: [String] = []
    for i in 0...string.count {
        for j in i...string.count {
            result.append(String(string[string.index(string.startIndex, offsetBy: i)..<string.index(string.startIndex, offsetBy: j)]))
        }
    }
    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 result: [String] = []
    for i in 0...string.count {
        result.append(String(string[string.startIndex..<string.index(string.startIndex, offsetBy: i)]))
    }
    return result
}

// Return array of all suffixes from shortest to longest of the input string
// allSuffixes(string: "abc") == ["c", "bc", "abc"]
func allSuffixes(string: String) -> [String] {
    var result: [String] = []
    for i in 0...string.count {
        result.append(String(string[string.index(string.endIndex, offsetBy: -i)..<string.endIndex]))
    }
    return result
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var result: [String] = []
    for i in 0...string.count {
        for j in i...string.count {
            result.append(String(string[string.index(string.startIndex, offsetBy: i)..<string.index(string.startIndex, offsetBy: j)]))
        }
    }
    return result
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var result: [String] = []
    for i in 0...string.count {
        for j in i...string.count {
            result.append(String(string[string.index(string.startIndex, offsetBy: i)..<string.index(string.startIndex, offsetBy: j)]))
        }
    }
    return result
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var result: [String] = []
    for i in 0...string.count {
        for j in i...string.count {
            result.append(String(string[string.index(string.startIndex, offsetBy: i)..<string.index(string.startIndex, offsetBy: j)]))
        }
    }
    return result
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var result: [String] = []
    for i in 0...string.count {
        for j in i...string.count {
            result.append(String(string[string.index(string.startIndex, offsetBy: i)..<string.index(string.startIndex, offsetBy: j)]))
        }
    }
    return result
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var result: [String] = []
    for i in 0...string.count {
        for j in i...string.count {
            result.append(String(string[string.index(string.startIndex, offsetBy: i)..<string.index(string.startIndex, offsetBy: j)]))
        }
    }
    return result
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "
 // XCTAssertTrue failed

func allPrefixes(string: String) -> [String] {
    var prefixes = [String]()
    for i in 0..<string.count {
        prefixes.append(String(string[string.startIndex..<string.index(after: string.startIndex, offsetBy: i + 1)]))
    }
    return prefixes
}

func allSuffixes(string: String) -> [String] {
    var suffixes = [String]()
    for i in 0..<string.count {
        suffixes.append(String(string[string.index(after: string.startIndex, offsetBy: i)...string.endIndex]))
    }
    return suffixes
}

func allSubstrings(string: String) -> [String] {
    var substrings = [String]()
    for i in 0..<string.count {
        for j in i..<string.count {
            substrings.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]))
        }
    }
    return substrings
}
```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(string[string.startIndex..<string.index(after: string.startIndex, offsetBy: i + 1)]))
    }
    return prefixes
}

// Return array of all suffixes from shortest to longest of the input string
// allSuffixes(string: "abc") == ["c", "bc", "abc"]
func allSuffixes(string: String) -> [String] {
    var suffixes = [String]()
    for i in 0..<string.count {
        suffixes.append(String(string[string.index(after: string.startIndex, offsetBy: i)...string.endIndex]))
    }
    return suffixes
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var substrings = [String]()
    for i in 0..<string.count {
        for j in i..<string.count {
            substrings.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]))
        }
    }
    return substrings
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var substrings = [String]()
    for i in 0..<string.count {
        for j in i..<string.count {
            substrings.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]))
        }
    }
    return substrings
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var substrings = [String]()
    for i in 0..<string.count {
        for j in i..<string.count {
            substrings.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]))
        }
    }
    return substrings
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var substrings = [String]()
    for i in 0..<string.count {
        for j in i..<string.count {
            substrings.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]))
        }
    }
    return substrings
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var substrings = [String]()
    for i in 0..<string.count {
        for j in i..<string.count {
            substrings.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index
prefixes.append(String(string[string.startIndex..<string.index(after: string.startIndex, offsetBy: i + 1)])) // extraneous argument label 'after:' in call
suffixes.append(String(string[string.index(after: string.startIndex, offsetBy: i)...string.endIndex])) // extraneous argument label 'after:' in call
substrings.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)])) // extraneous argument label 'after:' in call
substrings.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)])) // extraneous argument label 'after:' in call

func allPrefixes(string: String) -> [String] {
    var result = [String]()
    for i in 0..<string.count {
        result.append(String(string[string.startIndex..<string.index(after: string.startIndex, offsetBy: i + 1)]))
    }
    return result
}

func allSuffixes(string: String) -> [String] {
    var result = [String]()
    for i in 0..<string.count {
        result.append(String(string[string.index(after: string.startIndex, offsetBy: i)...string.endIndex]))
    }
    return result
}

func allSubstrings(string: String) -> [String] {
    var result = [String]()
    for i in 0..<string.count {
        for j in i..<string.count {
            result.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 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 result = [String]()
    for i in 0..<string.count {
        result.append(String(string[string.startIndex..<string.index(after: string.startIndex, offsetBy: i + 1)]))
    }
    return result
}

// Return array of all suffixes from shortest to longest of the input string
// allSuffixes(string: "abc") == ["c", "bc", "abc"]
func allSuffixes(string: String) -> [String] {
    var result = [String]()
    for i in 0..<string.count {
        result.append(String(string[string.index(after: string.startIndex, offsetBy: i)...string.endIndex]))
    }
    return result
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var result = [String]()
    for i in 0..<string.count {
        for j in i..<string.count {
            result.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]))
        }
    }
    return result
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var result = [String]()
    for i in 0..<string.count {
        for j in i..<string.count {
            result.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]))
        }
    }
    return result
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var result = [String]()
    for i in 0..<string.count {
        for j in i..<string.count {
            result.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]))
        }
    }
    return result
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var result = [String]()
    for i in 0..<string.count {
        for j in i..<string.count {
            result.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]))
        }
    }
    return result
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var result = [String]()
    for i in 0..<string.count {
        for j in i..<string.count {
            result.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]))
        }
result.append(String(string[string.startIndex..<string.index(after: string.startIndex, offsetBy: i + 1)])) // extraneous argument label 'after:' in call
result.append(String(string[string.index(after: string.startIndex, offsetBy: i)...string.endIndex])) // extraneous argument label 'after:' in call
result.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)])) // extraneous argument label 'after:' in call
result.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)])) // extraneous argument label 'after:' in call

func allPrefixes(string: String) -> [String] {
    var prefixes: [String] = []
    for i in 0..<string.count {
        prefixes.append(String(string[string.startIndex..<string.index(after: string.startIndex, offsetBy: i + 1)]))
    }
    return prefixes
}

func allSuffixes(string: String) -> [String] {
    var suffixes: [String] = []
    for i in 0..<string.count {
        suffixes.append(String(string[string.index(after: string.startIndex, offsetBy: i)...string.endIndex]))
    }
    return suffixes
}

func allSubstrings(string: String) -> [String] {
    var substrings: [String] = []
    for i in 0..<string.count {
        for j in i..<string.count {
            substrings.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]))
        }
    }
    return substrings
}
```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(string[string.startIndex..<string.index(after: string.startIndex, offsetBy: i + 1)]))
    }
    return prefixes
}

// Return array of all suffixes from shortest to longest of the input string
// allSuffixes(string: "abc") == ["c", "bc", "abc"]
func allSuffixes(string: String) -> [String] {
    var suffixes: [String] = []
    for i in 0..<string.count {
        suffixes.append(String(string[string.index(after: string.startIndex, offsetBy: i)...string.endIndex]))
    }
    return suffixes
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var substrings: [String] = []
    for i in 0..<string.count {
        for j in i..<string.count {
            substrings.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]))
        }
    }
    return substrings
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var substrings: [String] = []
    for i in 0..<string.count {
        for j in i..<string.count {
            substrings.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]))
        }
    }
    return substrings
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var substrings: [String] = []
    for i in 0..<string.count {
        for j in i..<string.count {
            substrings.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]))
        }
    }
    return substrings
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var substrings: [String] = []
    for i in 0..<string.count {
        for j in i..<string.count {
            substrings.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]))
        }
    }
    return substrings
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var substrings: [String] = []
    for i in 0..<string.count {
        for j in i..<string.count {
            substrings.append(String(string[string.index(after: string.startIndex, offsetBy: i
prefixes.append(String(string[string.startIndex..<string.index(after: string.startIndex, offsetBy: i + 1)])) // extraneous argument label 'after:' in call
suffixes.append(String(string[string.index(after: string.startIndex, offsetBy: i)...string.endIndex])) // extraneous argument label 'after:' in call
substrings.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)])) // extraneous argument label 'after:' in call
substrings.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)])) // extraneous argument label 'after:' in call

func allPrefixes(string: String) -> [String] {
    var prefixes = [String]()
    for i in 0..<string.count {
        prefixes.append(String(string[string.startIndex..<string.index(after: string.startIndex, offsetBy: i + 1)]))
    }
    return prefixes
}

func allSuffixes(string: String) -> [String] {
    var suffixes = [String]()
    for i in 0..<string.count {
        suffixes.append(String(string[string.index(after: string.startIndex, offsetBy: i)...string.endIndex]))
    }
    return suffixes
}

func allSubstrings(string: String) -> [String] {
    var substrings = [String]()
    for i in 0..<string.count {
        for j in i..<string.count {
            substrings.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]))
        }
    }
    return substrings
}

func allPalindromes(string: String) -> [String] {
    var palindromes = [String]()
    for i in 0..<string.count {
        for j in i..<string.count {
            let substring = String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)])
            if substring == String(substring.reversed()) {
                palindromes.append(substring)
            }
        }
    }
    return palindromes
}

func allPalindromes(string: String) -> [String] {
    var palindromes = [String]()
    for i in 0..<string.count {
        for j in i..<string.count {
            let substring = String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)])
            if substring == String(substring.reversed()) && substring.count > 1 {
                palindromes.append(substring)
            }
        }
    }
    return palindromes
}
```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(string[string.startIndex..<string.index(after: string.startIndex, offsetBy: i + 1)]))
    }
    return prefixes
}

// Return array of all suffixes from shortest to longest of the input string
// allSuffixes(string: "abc") == ["c", "bc", "abc"]
func allSuffixes(string: String) -> [String] {
    var suffixes = [String]()
    for i in 0..<string.count {
        suffixes.append(String(string[string.index(after: string.startIndex, offsetBy: i)...string.endIndex]))
    }
    return suffixes
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var substrings = [String]()
    for i in 0..<string.count {
        for j in i..<string.count {
            substrings.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]))
        }
    }
    return substrings
}

// Return array of all substrings from shortest to longest of the input string
// that are palindromes
// allPalindromes(string: "abc") == ["a", "b", "c"]
func allPalindromes(string: String) -> [String] {
    var palindromes = [String]()
    for i in 0..<string.count {
        for j in i..<string.count {
            let substring = String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)])
            if substring == String(substring.reversed()) {
                palindromes.append(substring)
            }
        }
    }
    return palindromes
}

// Return array of all substrings from shortest to longest of the input string
// that are palindromes and are longer than 1 character
// allPalindromes(string: "abc") == ["a", "b", "c"]
func allPalindromes(string: String) -> [String] {
    var palindromes = [String]()
    for i in 0..<string.count {
        for j in i..<string.count {
            let substring = String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)])
            if substring == String(substring.reversed()) && substring.count > 1 {
                palindromes.append(substring)
            }
        }
    }
    return palindromes
}

// Return array of all substrings from shortest to longest of the input string
// that are palindromes and are longer than 1 character
// allPalindromes(string: "abc") == ["a", "b", "c"]
func allPalindromes(string: String) -> [String] {
    var palindromes = [String]()
    for i in 0..<string.count {
        for j in i..<string.count {
            let substring = String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)])
            if substring == String(substring.reversed()) && substring.count > 1 {
                palindromes.append(substring)
            }
        }
    }
    return palindromes
}

// Return array of all substrings from shortest to longest of the input string
prefixes.append(String(string[string.startIndex..<string.index(after: string.startIndex, offsetBy: i + 1)])) // extraneous argument label 'after:' in call
suffixes.append(String(string[string.index(after: string.startIndex, offsetBy: i)...string.endIndex])) // extraneous argument label 'after:' in call
substrings.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)])) // extraneous argument label 'after:' in call
substrings.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)])) // extraneous argument label 'after:' in call
let substring = String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]) // extraneous argument label 'after:' in call
let substring = String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]) // extraneous argument label 'after:' in call
func allPalindromes(string: String) -> [String] { // invalid redeclaration of 'allPalindromes(string:)'
let substring = String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]) // extraneous argument label 'after:' in call
let substring = String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]) // extraneous argument label 'after:' in call

func allPrefixes(string: String) -> [String] {
    var result = [String]()
    for i in 0..<string.count {
        result.append(String(string[string.startIndex..<string.index(after: string.startIndex, offsetBy: i + 1)]))
    }
    return result
}

func allSuffixes(string: String) -> [String] {
    var result = [String]()
    for i in 0..<string.count {
        result.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.endIndex]))
    }
    return result
}

func allSubstrings(string: String) -> [String] {
    var result = [String]()
    for i in 0..<string.count {
        for j in i..<string.count {
            result.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]))
        }
    }
    return result
}

func allPalindromes(string: String) -> [String] {
    var result = [String]()
    for i in 0..<string.count {
        for j in i..<string.count {
            let substring = String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)])
            if substring == String(substring.reversed()) {
                result.append(substring)
            }
        }
    }
    return result
}

func longestPalindrome(string: String) -> String {
    var result = ""
    for i in 0..<string.count {
        for j in i..<string.count {
            let substring = String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)])
            if substring == String(substring.reversed()) && substring.count > result.count {
                result = substring
            }
        }
    }
    return result
}

func longestPalindromeSubstring(string: String) -> String {
    var result = ""
    for i in 0..<string.count {
        for j in i..<string.count {
            let substring = String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)])
            if substring == String(substring.reversed()) && substring.count > result.count {
                result = substring
            }
        }
    }
    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 result = [String]()
    for i in 0..<string.count {
        result.append(String(string[string.startIndex..<string.index(after: string.startIndex, offsetBy: i + 1)]))
    }
    return result
}

// Return array of all suffixes from shortest to longest of the input string
// allSuffixes(string: "abc") == ["c", "bc", "abc"]
func allSuffixes(string: String) -> [String] {
    var result = [String]()
    for i in 0..<string.count {
        result.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.endIndex]))
    }
    return result
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var result = [String]()
    for i in 0..<string.count {
        for j in i..<string.count {
            result.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]))
        }
    }
    return result
}

// Return array of all substrings from shortest to longest of the input string
// that are palindromes
// allPalindromes(string: "abc") == ["a", "b", "c"]
func allPalindromes(string: String) -> [String] {
    var result = [String]()
    for i in 0..<string.count {
        for j in i..<string.count {
            let substring = String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)])
            if substring == String(substring.reversed()) {
                result.append(substring)
            }
        }
    }
    return result
}

// Return the longest palindrome substring of the input string
// longestPalindrome(string: "abc") == "a"
func longestPalindrome(string: String) -> String {
    var result = ""
    for i in 0..<string.count {
        for j in i..<string.count {
            let substring = String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)])
            if substring == String(substring.reversed()) && substring.count > result.count {
                result = substring
            }
        }
    }
    return result
}

// Return the longest palindrome substring of the input string
// that is a substring of the input string
// longestPalindromeSubstring(string: "abc") == "a"
func longestPalindromeSubstring(string: String) -> String {
    var result = ""
    for i in 0..<string.count {
        for j in i..<string.count {
            let substring = String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)])
            if substring == String(substring.reversed()) && substring.count > result.count {
                result = substring
            }
        }
    }
    return result
}

// Return the longest palindrome substring of the input string
// that is a substring of the input string
// that is a substring of the input string
// that is a substring of the input string
// that is a substring of the input string
// that is a substring of the input string
// that is a substring of the input string
// that is a substring of the input string
// that is a substring of the input string
// that is
result.append(String(string[string.startIndex..<string.index(after: string.startIndex, offsetBy: i + 1)])) // extraneous argument label 'after:' in call
result.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.endIndex])) // extraneous argument label 'after:' in call
result.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)])) // extraneous argument label 'after:' in call
result.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)])) // extraneous argument label 'after:' in call
let substring = String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]) // extraneous argument label 'after:' in call
let substring = String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]) // extraneous argument label 'after:' in call
let substring = String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]) // extraneous argument label 'after:' in call
let substring = String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]) // extraneous argument label 'after:' in call
let substring = String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]) // extraneous argument label 'after:' in call
let substring = String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]) // extraneous argument label 'after:' in call

func allPrefixes(string: String) -> [String] {
    var result: [String] = []
    for i in 0..<string.count {
        result.append(String(string[string.startIndex..<string.index(after: string.startIndex, offsetBy: i + 1)]))
    }
    return result
}

func allSuffixes(string: String) -> [String] {
    var result: [String] = []
    for i in 0..<string.count {
        result.append(String(string[string.index(after: string.startIndex, offsetBy: i)...string.endIndex]))
    }
    return result
}

func allSubstrings(string: String) -> [String] {
    var result: [String] = []
    for i in 0..<string.count {
        for j in i..<string.count {
            result.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]))
        }
    }
    return result
}

func allPalindromes(string: String) -> [String] {
    var result: [String] = []
    for i in 0..<string.count {
        for j in i..<string.count {
            let substring = String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)])
            if substring == String(substring.reversed()) {
                result.append(substring)
            }
        }
    }
    return result
}

func longestPalindrome(string: String) -> String {
    var result = ""
    for i in 0..<string.count {
        for j in i..<string.count {
            let substring = String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)])
            if substring == String(substring.reversed()) && substring.count > result.count {
                result = substring
            }
        }
    }
    return result
}

func longestPalindromeSubstring(string: String) -> String {
    var result = ""
    for i in 0..<string.count {
        for j in i..<string.count {
            let substring = String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)])
            if substring == String(substring.reversed()) && substring.count > result.count {
                result = substring
            }
        }
    }
    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 result: [String] = []
    for i in 0..<string.count {
        result.append(String(string[string.startIndex..<string.index(after: string.startIndex, offsetBy: i + 1)]))
    }
    return result
}

// Return array of all suffixes from shortest to longest of the input string
// allSuffixes(string: "abc") == ["c", "bc", "abc"]
func allSuffixes(string: String) -> [String] {
    var result: [String] = []
    for i in 0..<string.count {
        result.append(String(string[string.index(after: string.startIndex, offsetBy: i)...string.endIndex]))
    }
    return result
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var result: [String] = []
    for i in 0..<string.count {
        for j in i..<string.count {
            result.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]))
        }
    }
    return result
}

// Return array of all substrings from shortest to longest of the input string
// that are palindromes
// allPalindromes(string: "abc") == ["a", "b", "c"]
func allPalindromes(string: String) -> [String] {
    var result: [String] = []
    for i in 0..<string.count {
        for j in i..<string.count {
            let substring = String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)])
            if substring == String(substring.reversed()) {
                result.append(substring)
            }
        }
    }
    return result
}

// Return the longest palindrome in the input string
// longestPalindrome(string: "abc") == "a"
func longestPalindrome(string: String) -> String {
    var result = ""
    for i in 0..<string.count {
        for j in i..<string.count {
            let substring = String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)])
            if substring == String(substring.reversed()) && substring.count > result.count {
                result = substring
            }
        }
    }
    return result
}

// Return the longest palindrome in the input string
// that is a substring of the input string
// longestPalindromeSubstring(string: "abc") == "a"
func longestPalindromeSubstring(string: String) -> String {
    var result = ""
    for i in 0..<string.count {
        for j in i..<string.count {
            let substring = String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)])
            if substring == String(substring.reversed()) && substring.count > result.count {
                result = substring
            }
        }
    }
    return result
}

// Return the longest palindrome in the input string
// that is a substring of the input string
// that is a prefix of the input string
// longestPalindromeSubstringPrefix(string: "abc") == "a"
func longestPalindromeSubstringPrefix(string: String) -> String {
    var result = ""
    for i in 0..<string.count {
        for j in i..<string.count {
            
result.append(String(string[string.startIndex..<string.index(after: string.startIndex, offsetBy: i + 1)])) // extraneous argument label 'after:' in call
result.append(String(string[string.index(after: string.startIndex, offsetBy: i)...string.endIndex])) // extraneous argument label 'after:' in call
result.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)])) // extraneous argument label 'after:' in call
result.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)])) // extraneous argument label 'after:' in call
let substring = String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]) // extraneous argument label 'after:' in call
let substring = String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]) // extraneous argument label 'after:' in call
let substring = String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]) // extraneous argument label 'after:' in call
let substring = String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]) // extraneous argument label 'after:' in call
let substring = String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]) // extraneous argument label 'after:' in call
let substring = String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]) // extraneous argument label 'after:' in call

func allPrefixes(string: String) -> [String] {
    var result: [String] = []
    for i in 0..<string.count {
        result.append(String(string[string.startIndex..<string.index(after: string.startIndex, offsetBy: i + 1)]))
    }
    return result
}

func allSuffixes(string: String) -> [String] {
    var result: [String] = []
    for i in 0..<string.count {
        result.append(String(string[string.index(after: string.startIndex, offsetBy: i)...string.endIndex]))
    }
    return result
}

func allSubstrings(string: String) -> [String] {
    var result: [String] = []
    for i in 0..<string.count {
        for j in i..<string.count {
            result.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]))
        }
    }
    return result
}

func allSubstringsWithoutDuplicates(string: String) -> [String] {
    var result: [String] = []
    for i in 0..<string.count {
        for j in i..<string.count {
            result.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]))
        }
    }
    return Array(Set(result))
}

func allSubstringsWithoutDuplicatesAndSubstringsOfOtherSubstrings(string: String) -> [String] {
    var result: [String] = []
    for i in 0..<string.count {
        for j in i..<string.count {
            result.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]))
        }
    }
    return Array(Set(result)).filter { $0.count == 1 || !result.contains($0.prefix(1)) || !result.contains($0.suffix(1)) }
}
```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 result: [String] = []
    for i in 0..<string.count {
        result.append(String(string[string.startIndex..<string.index(after: string.startIndex, offsetBy: i + 1)]))
    }
    return result
}

// Return array of all suffixes from shortest to longest of the input string
// allSuffixes(string: "abc") == ["c", "bc", "abc"]
func allSuffixes(string: String) -> [String] {
    var result: [String] = []
    for i in 0..<string.count {
        result.append(String(string[string.index(after: string.startIndex, offsetBy: i)...string.endIndex]))
    }
    return result
}

// Return array of all substrings from shortest to longest of the input string
// allSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstrings(string: String) -> [String] {
    var result: [String] = []
    for i in 0..<string.count {
        for j in i..<string.count {
            result.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]))
        }
    }
    return result
}

// Return array of all substrings from shortest to longest of the input string
// without duplicates
// allSubstringsWithoutDuplicates(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstringsWithoutDuplicates(string: String) -> [String] {
    var result: [String] = []
    for i in 0..<string.count {
        for j in i..<string.count {
            result.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]))
        }
    }
    return Array(Set(result))
}

// Return array of all substrings from shortest to longest of the input string
// without duplicates and without substrings that are substrings of other substrings
// allSubstringsWithoutDuplicatesAndSubstringsOfOtherSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstringsWithoutDuplicatesAndSubstringsOfOtherSubstrings(string: String) -> [String] {
    var result: [String] = []
    for i in 0..<string.count {
        for j in i..<string.count {
            result.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1)]))
        }
    }
    return Array(Set(result)).filter { $0.count == 1 || !result.contains($0.prefix(1)) || !result.contains($0.suffix(1)) }
}

// Return array of all substrings from shortest to longest of the input string
// without duplicates and without substrings that are substrings of other substrings
// and without substrings that are substrings of other substrings
// allSubstringsWithoutDuplicatesAndSubstringsOfOtherSubstringsAndSubstringsOfOtherSubstrings(string: "abc") == ["a", "ab", "abc", "b", "bc", "c"]
func allSubstringsWithoutDuplicatesAndSubstringsOfOtherSubstringsAndSubstringsOfOtherSubstrings(string: String) -> [String] {
    var result: [String] = []
    for i in 0..<string.count {
        for j in i..<string.count {
            result.append(String(string[string.index(after: string.startIndex, offsetBy: i)..<string.index(after: string.startIndex, offsetBy: j + 1

func stringSequence(n: Int) -> String {
    var result = ""
    for i in 0...n {
        result += "\(i) "
    }
    return result.trimmingCharacters(in: .whitespacesAndNewlines)
}
```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.trimmingCharacters(in: .whitespacesAndNewlines)
}

print(stringSequence(n: 0))
print(stringSequence(n: 5))
```

func stringSequence(n: Int) -> String {
    var result = ""
    for i in 0...n {
        result += "\(i) "
    }
    return result.trimmingCharacters(in: .whitespacesAndNewlines)
}
```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.trimmingCharacters(in: .whitespacesAndNewlines)
}
```

func stringSequence(n: Int) -> String {
    var result = ""
    for i in 0...n {
        result += "\(i) "
    }
    return result.trimmingCharacters(in: .whitespacesAndNewlines)
}
```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.trimmingCharacters(in: .whitespacesAndNewlines)
}

print(stringSequence(n: 0))
print(stringSequence(n: 5))
```

func stringSequence(n: Int) -> String {
    var result = ""
    for i in 0...n {
        result += "\(i) "
    }
    return String(result.dropLast())
}
```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 String(result.dropLast())
}
```

func stringSequence(n: Int) -> String {
    var result = ""
    for i in 0...n {
        result += "\(i) "
    }
    return result.trimmingCharacters(in: .whitespacesAndNewlines)
}
```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.trimmingCharacters(in: .whitespacesAndNewlines)
}

print(stringSequence(n: 0))
print(stringSequence(n: 5))
```

func stringSequence(n: Int) -> String {
    var result = ""
    for i in 0...n {
        result += "\(i) "
    }
    return result.trimmingCharacters(in: .whitespacesAndNewlines)
}
```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.trimmingCharacters(in: .whitespacesAndNewlines)
}

print(stringSequence(n: 0))
print(stringSequence(n: 5))
```

func stringSequence(n: Int) -> String {
    // 1. Create a sequence of numbers from 0 to n
    let sequence = 0...n
    // 2. Create an array of strings from the sequence
    let stringArray = sequence.map { String($0) }
    // 3. Join the array into a single string separated by spaces
    return stringArray.joined(separator: " ")
}
```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 {
    // 1. Create a sequence of numbers from 0 to n
    let sequence = 0...n
    // 2. Create an array of strings from the sequence
    let stringArray = sequence.map { String($0) }
    // 3. Join the array into a single string separated by spaces
    return stringArray.joined(separator: " ")
}
```

func stringSequence(n: Int) -> String {
    var result = ""
    for i in 0...n {
        result += "\(i) "
    }
    return result.trimmingCharacters(in: .whitespacesAndNewlines)
}
```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.trimmingCharacters(in: .whitespacesAndNewlines)
}

print(stringSequence(n: 0))
print(stringSequence(n: 5))
```

func stringSequence(n: Int) -> String {
    var result = ""
    for i in 0...n {
        result += "\(i) "
    }
    return result.trimmingCharacters(in: .whitespacesAndNewlines)
}
```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.trimmingCharacters(in: .whitespacesAndNewlines)
}
```

func stringSequence(n: Int) -> String {
    var result = ""
    for i in 0...n {
        result += "\(i) "
    }
    return result.trimmingCharacters(in: .whitespacesAndNewlines)
}
```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.trimmingCharacters(in: .whitespacesAndNewlines)
}

print(stringSequence(n: 0))
print(stringSequence(n: 5))
```

func countDistinctCharacters(string: String) -> Int {
    // Write your code here
}
```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 {
    // Write your code here
}
```
} // missing return in global function expected to return 'Int'

func countDistinctCharacters(string: String) -> Int {
    // write your code in Swift
    var set = Set<Character>()
    for char in string {
        set.insert(char)
    }
    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 {
    // write your code in Swift
    var set = Set<Character>()
    for char in string {
        set.insert(char)
    }
    return set.count
}

print(countDistinctCharacters(string: "xyzXYZ"))
print(countDistinctCharacters(string: "Jerry"))

// 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 {
    // write your code in Swift
    var set = Set<Character>()
    for char in string {
        set.insert(char)
    }
    return set.count
}

print(countDistinctCharacters(string: "xyzXYZ"))
print(countDistinctCharacters(string: "Jerry"))

// 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 {
    // write your code in Swift
    var set = Set<Character>()
    for char in string {
        set.insert(char)
    }
    return set.count
}

print(countDistinctCharacters(string: "xyzXYZ"))
print(countDistinctCharacters(string: "Jerry"))

// 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 {
    // write your code in Swift
    var set = Set<Character>()
    for char in string {
        set.insert(char)
    }
    return set.count
}

print(countDistinctCharacters(string: "xyzXYZ"))
print(countDistinctCharacters(string: "Jerry"))

// 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 {
    // write your code in Swift
    var set = Set<Character>()
    for char in string {
        set.insert(char)
    }
    return set.count
}

print(countDistinctCharacters(string: "xyzXYZ"))
print(countDistinctCharacters(string: "Jerry"))

// 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 {
    // write your code in Swift
    var set = Set<Character>()
    for char in string {
        set.insert(char)
    }
    return set.count
}

print(countDistinctCharacters(string: "xyzXYZ"))
print(countDistinctCharacters(string: "Jerry"))

// 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 {
    // write your code in Swift
    var set = Set<Character>()
    for char in string {
        set.insert(char)
    }
    return set.count
}

print(countDistinctCharacters(string: "xyzXYZ"))
print(countDistinctCharacters(string: "Jerry"))

// Given a string, find out how many distinct characters (regardless of case) does it consist of
// countDistinctCharacters(string: "xyz
 // XCTAssertTrue failed

func countDistinctCharacters(string: String) -> Int {
    // write your code in Swift
    var distinctCharacters = Set<Character>()
    for character in string {
        distinctCharacters.insert(character)
    }
    return distinctCharacters.count
}

func countAlphanumericCharacters(string: String) -> Int {
    // write your code in Swift
    var alphanumericCharacters = Set<Character>()
    for character in string {
        if CharacterSet.alphanumerics.contains(character) {
            alphanumericCharacters.insert(character)
        }
    }
    return alphanumericCharacters.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 {
    // write your code in Swift
    var distinctCharacters = Set<Character>()
    for character in string {
        distinctCharacters.insert(character)
    }
    return distinctCharacters.count
}

// Given a string, find out how many distinct case-insensitive alphabetic characters and numeric digits it consists of
// countAlphanumericCharacters(string: "abc123") == 6
// countAlphanumericCharacters(string: "abc123!@#$%^&*()") == 6
func countAlphanumericCharacters(string: String) -> Int {
    // write your code in Swift
    var alphanumericCharacters = Set<Character>()
    for character in string {
        if CharacterSet.alphanumerics.contains(character) {
            alphanumericCharacters.insert(character)
        }
    }
    return alphanumericCharacters.count
}

// Given a string, find out how many distinct case-insensitive alphabetic characters and numeric digits it consists of
// countAlphanumericCharacters(string: "abc123") == 6
// countAlphanumericCharacters(string: "abc123!@#$%^&*()") == 6
func countAlphanumericCharacters(string: String) -> Int {
    // write your code in Swift
    var alphanumericCharacters = Set<Character>()
    for character in string {
        if CharacterSet.alphanumerics.contains(character) {
            alphanumericCharacters.insert(character)
        }
    }
    return alphanumericCharacters.count
}

// Given a string, find out how many distinct case-insensitive alphabetic characters and numeric digits it consists of
// countAlphanumericCharacters(string: "abc123") == 6
// countAlphanumericCharacters(string: "abc123!@#$%^&*()") == 6
func countAlphanumericCharacters(string: String) -> Int {
    // write your code in Swift
    var alphanumericCharacters = Set<Character>()
    for character in string {
        if CharacterSet.alphanumerics.contains(character) {
            alphanumericCharacters.insert(character)
        }
    }
    return alphanumericCharacters.count
}

// Given a string, find out how many distinct case-insensitive alphabetic characters and numeric digits it consists of
// countAlphanumericCharacters(string: "abc123") == 6
// countAlphanumericCharacters(string: "abc123!@#$%^&*()") == 6
func countAlphanumericCharacters(string: String) -> Int {
    // write your code in Swift
    var alphanumericCharacters = Set<Character>()
    for character in string {
        if CharacterSet.alphanumerics.contains(character) {
            alphanumericCharacters.insert(character)
        }
    }
    return alphanumericCharacters.count
}

// Given a string, find out how many distinct case-insensitive alphabetic characters and numeric digits it consists of
// countAlphanumericCharacters(string: "abc123") == 6
// countAlphanumericCharacters(string: "abc123!@#$%^&*()") == 6
func countAlphanumericCharacters(string: String) -> Int {
    // write your code in Swift
    var alphanumericCharacters = Set<Character>()
    for character in string {
        if CharacterSet.alphanumerics.contains(character) {
            alphanumericCharacters.insert(character)
        }
    }
    return alphanumericCharacters.count
}

// Given a string, find out how many distinct case-insensitive alphabetic characters and numeric digits it consists of
// countAlphanumericCharacters(string: "abc123") == 6
// countAlphanumericCharacters(string: "abc123!@#$%^&*()") == 6
func countAlphanumericCharacters(string: String) -> Int {
    // write your code in Swift
    var alphanumericCharacters = Set<Character>()
    for character in string {
        if CharacterSet.alphanumerics.contains(character) {
            alphanumericCharacters.
if CharacterSet.alphanumerics.contains(character) { // cannot convert value of type 'Character' to expected argument type 'Unicode.Scalar'

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 {
    // write your code in Swift
    var charSet = Set<Character>()
    for char in string {
        charSet.insert(char)
    }
    return charSet.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 {
    // write your code in Swift
    var charSet = Set<Character>()
    for char in string {
        charSet.insert(char)
    }
    return charSet.count
}

// 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 {
    // write your code in Swift
    var charSet = Set<Character>()
    for char in string {
        charSet.insert(char)
    }
    return charSet.count
}

// 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 {
    // write your code in Swift
    var charSet = Set<Character>()
    for char in string {
        charSet.insert(char)
    }
    return charSet.count
}

// 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 {
    // write your code in Swift
    var charSet = Set<Character>()
    for char in string {
        charSet.insert(char)
    }
    return charSet.count
}

// 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 {
    // write your code in Swift
    var charSet = Set<Character>()
    for char in string {
        charSet.insert(char)
    }
    return charSet.count
}

// 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 {
    // write your code in Swift
    var charSet = Set<Character>()
    for char in string {
        charSet.insert(char)
    }
    return charSet.count
}

// 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 {
    // write your code in Swift
    var charSet = Set<Character>()
    for char in string {
        charSet.insert(char)
    }
    return charSet.count
}

// 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 {
    // write your code in Swift
    var charSet = Set<Character>()
    for char in string {
        charSet.insert(char)
    }
    return charSet.count
}

// 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 {
    // write your code in Swift
    var charSet = Set<Character>()
    for char in string {
        charSet.insert(char)
    }
    return charSet.count
}

// Given a string, find out how
 // XCTAssertTrue failed

func countDistinctCharacters(string: String) -> Int {
    return 0
}
```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 0
}
```
 // XCTAssertTrue failed

func countDistinctCharacters(string: String) -> Int {
    // write your code in Swift
    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 {
    // write your code in Swift
    var distinctCharacters: Set<Character> = []
    for character in string {
        distinctCharacters.insert(character)
    }
    return distinctCharacters.count
}

print(countDistinctCharacters(string: "xyzXYZ"))
print(countDistinctCharacters(string: "Jerry"))
```
 // XCTAssertTrue failed

func countDistinctCharacters(string: String) -> Int {
    // write your code in Swift
    var count = 0
    var chars = Set<Character>()
    for char in string {
        if !chars.contains(char) {
            chars.insert(char)
            count += 1
        }
    }
    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 {
    // write your code in Swift
    var count = 0
    var chars = Set<Character>()
    for char in string {
        if !chars.contains(char) {
            chars.insert(char)
            count += 1
        }
    }
    return count
}

// 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 {
    // write your code in Swift
    var count = 0
    var chars = Set<Character>()
    for char in string {
        if !chars.contains(char) {
            chars.insert(char)
            count += 1
        }
    }
    return count
}

// 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 {
    // write your code in Swift
    var count = 0
    var chars = Set<Character>()
    for char in string {
        if !chars.contains(char) {
            chars.insert(char)
            count += 1
        }
    }
    return count
}

// 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 {
    // write your code in Swift
    var count = 0
    var chars = Set<Character>()
    for char in string {
        if !chars.contains(char) {
            chars.insert(char)
            count += 1
        }
    }
    return count
}

// 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 {
    // write your code in Swift
    var count = 0
    var chars = Set<Character>()
    for char in string {
        if !chars.contains(char) {
            chars.insert(char)
            count += 1
        }
    }
    return count
}

// 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 {
    // write your code in Swift
    var count = 0
    var chars = Set<Character>()
    for char in string {
        if !chars.contains(char) {
            chars.insert(char)
            count += 1
        }
    }
    return count
}

// 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 {
    // write your code in Swift
    var count = 0
    var chars = Set<Character>()
    for char in string {
        if !chars.contains(char) {
            chars.insert(char)
            count += 1
        }
    }
    return count
}

// 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 {
    // write your code in Swift
 // XCTAssertTrue failed

func countDistinctCharacters(string: String) -> Int {
    // write your code in Swift
    var set = Set<Character>()
    for char in string {
        set.insert(char)
    }
    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 {
    // write your code in Swift
    var set = Set<Character>()
    for char in string {
        set.insert(char)
    }
    return set.count
}

print(countDistinctCharacters(string: "xyzXYZ"))
print(countDistinctCharacters(string: "Jerry"))

// 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 {
    // write your code in Swift
    var set = Set<Character>()
    for char in string {
        set.insert(char)
    }
    return set.count
}

print(countDistinctCharacters(string: "xyzXYZ"))
print(countDistinctCharacters(string: "Jerry"))

// 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 {
    // write your code in Swift
    var set = Set<Character>()
    for char in string {
        set.insert(char)
    }
    return set.count
}

print(countDistinctCharacters(string: "xyzXYZ"))
print(countDistinctCharacters(string: "Jerry"))

// 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 {
    // write your code in Swift
    var set = Set<Character>()
    for char in string {
        set.insert(char)
    }
    return set.count
}

print(countDistinctCharacters(string: "xyzXYZ"))
print(countDistinctCharacters(string: "Jerry"))

// 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 {
    // write your code in Swift
    var set = Set<Character>()
    for char in string {
        set.insert(char)
    }
    return set.count
}

print(countDistinctCharacters(string: "xyzXYZ"))
print(countDistinctCharacters(string: "Jerry"))

// 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 {
    // write your code in Swift
    var set = Set<Character>()
    for char in string {
        set.insert(char)
    }
    return set.count
}

print(countDistinctCharacters(string: "xyzXYZ"))
print(countDistinctCharacters(string: "Jerry"))

// 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 {
    // write your code in Swift
    var set = Set<Character>()
    for char in string {
        set.insert(char)
    }
    return set.count
}

print(countDistinctCharacters(string: "xyzXYZ"))
print(countDistinctCharacters(string: "Jerry"))

// Given a string, find out how many distinct characters (regardless of case) does it consist of
// countDistinctCharacters(string: "xyz
 // XCTAssertTrue failed

func countDistinctCharacters(string: String) -> Int {
    // write your code in Swift
    var set = Set<Character>()
    for char in string {
        set.insert(char)
    }
    return set.count
}

func countCharacters(string: String) -> [Character: Int] {
    // write your code in Swift
    var dict = [Character: Int]()
    for char in string {
        dict[char] = (dict[char] ?? 0) + 1
    }
    return dict
}
```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 {
    // write your code in Swift
    var set = Set<Character>()
    for char in string {
        set.insert(char)
    }
    return set.count
}

// Given a string, find out how many times each character appears in the string
// countCharacters(string: "xyzXYZ") == ["x": 1, "y": 1, "z": 2, "X": 1, "Y": 1, "Z": 2]
// countCharacters(string: "Jerry") == ["J": 1, "e": 1, "r": 2, "y": 1]
func countCharacters(string: String) -> [Character: Int] {
    // write your code in Swift
    var dict = [Character: Int]()
    for char in string {
        dict[char] = (dict[char] ?? 0) + 1
    }
    return dict
}

// Given a string, find out how many times each character appears in the string
// countCharacters(string: "xyzXYZ") == ["x": 1, "y": 1, "z": 2, "X": 1, "Y": 1, "Z": 2]
// countCharacters(string: "Jerry") == ["J": 1, "e": 1, "r": 2, "y": 1]
func countCharacters(string: String) -> [Character: Int] {
    // write your code in Swift
    var dict = [Character: Int]()
    for char in string {
        dict[char] = (dict[char] ?? 0) + 1
    }
    return dict
}

// Given a string, find out how many times each character appears in the string
// countCharacters(string: "xyzXYZ") == ["x": 1, "y": 1, "z": 2, "X": 1, "Y": 1, "Z": 2]
// countCharacters(string: "Jerry") == ["J": 1, "e": 1, "r": 2, "y": 1]
func countCharacters(string: String) -> [Character: Int] {
    // write your code in Swift
    var dict = [Character: Int]()
    for char in string {
        dict[char] = (dict[char] ?? 0) + 1
    }
    return dict
}

// Given a string, find out how many times each character appears in the string
// countCharacters(string: "xyzXYZ") == ["x": 1, "y": 1, "z": 2, "X": 1, "Y": 1, "Z": 2]
// countCharacters(string: "Jerry") == ["J": 1, "e": 1, "r": 2, "y": 1]
func countCharacters(string: String) -> [Character: Int] {
    // write your code in Swift
    var dict = [Character: Int]()
    for char in string {
        dict[char] = (dict[char] ?? 0) + 1
    }
    return dict
}

// Given a string, find out how many times each character appears in the string
// countCharacters(string: "xyzXYZ") == ["x": 1, "y": 1, "z": 2, "X": 1, "Y": 1, "Z": 2]
// countCharacters(string: "Jerry") == ["J": 1, "e": 1, "r": 2, "y": 1]
func countCharacters(string: String) -> [Character: Int] {
    // write your code in Swift
    var dict = [Character: Int]()
    for char in string {
        dict[char] = (dict[char] ?? 0) + 1
    }
    return dict
}

// Given a string, find out how many times each character appears in the string
// countCharacters(string: "xyzXYZ") == ["x": 1, "y": 1, "z": 2, "X": 1, "Y": 1, "Z": 2]
 // XCTAssertTrue failed

func parseMusic(musicString: String) -> [Int] {
    var result: [Int] = []
    let beats = musicString.split(separator: " ")
    for beat in beats {
        switch beat {
        case "o":
            result.append(4)
        case "o|":
            result.append(2)
        case ".|":
            result.append(1)
        default:
            break
        }
    }
    return result
}

func last2(str: String) -> Int {
    var count = 0
    let last2 = str.suffix(2)
    for i in 0..<str.count - 2 {
        let substring = str[str.index(str.startIndex, offsetBy: i)..<str.index(str.startIndex, offsetBy: i + 2)]
        if substring == last2 {
            count += 1
        }
    }
    return count
}

func stringX(str: String) -> String {
    var result = ""
    for i in 0..<str.count {
        let char = str[str.index(str.startIndex, offsetBy: i)]
        if char == "x" && i != 0 && i != str.count - 1 {
            continue
        }
        result.append(char)
    }
    return result
}

func altPairs(str: String) -> String {
    var result = ""
    for i in 0..<str.count {
        if i % 4 == 0 || i % 4 == 1 {
            result.append(str[str.index(str.startIndex, offsetBy: i)])
        }
    }
    return result
}

func sumNumbers(str: String) -> Int {
    var result = 0
    var number = ""
    for char in str {
        if CharacterSet.decimalDigits.contains(char) {
            number.append(char)
        } else {
            if !number.isEmpty {
                result += Int(number)!
                number = ""
            }
        }
    }
    if !number.isEmpty {
        result += Int(number)!
    }
    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] = []
    let beats = musicString.split(separator: " ")
    for beat in beats {
        switch beat {
        case "o":
            result.append(4)
        case "o|":
            result.append(2)
        case ".|":
            result.append(1)
        default:
            break
        }
    }
    return result
}

// 2.
// Given a string, return the number of times 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
// last2("xaxxaxaxx") == 1
// last2("axxxaaxx") == 2
func last2(str: String) -> Int {
    var count = 0
    let last2 = str.suffix(2)
    for i in 0..<str.count - 2 {
        let substring = str[str.index(str.startIndex, offsetBy: i)..<str.index(str.startIndex, offsetBy: i + 2)]
        if substring == last2 {
            count += 1
        }
    }
    return count
}

// 3.
// Given a string, return a version where all the "x" have been removed. Except an "x" at the very start or end should not be removed.
// stringX("xxHxix") == "xHix"
// stringX("abxxxcd") == "abcd"
// stringX("xabxxxcdx") == "xabcdx"
func stringX(str: String) -> String {
    var result = ""
    for i in 0..<str.count {
        let char = str[str.index(str.startIndex, offsetBy: i)]
        if char == "x" && i != 0 && i != str.count - 1 {
            continue
        }
        result.append(char)
    }
    return result
}

// 4.
// Given a string, return a string made of the chars at indexes 0,1, 4,5, 8,9 ... so "kittens" yields "kien".
// altPairs("kitten") == "kien"
// altPairs("Chocolate") == "Chole"
// altPairs("CodingHorror") == "Congrr"
func altPairs(str: String) -> String {
    var result = ""
    for i in 0..<str.count {
        if i % 4 == 0 || i % 4 == 1 {
            result.append(str[str.index(str.startIndex, offsetBy: i)])
        }
    }
    return result
}

// 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 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(str: String) -> Int {
    var result = 0
    var number = ""
    for char in str {
        if CharacterSet.decimalDigits.contains(char) {
            number.append(char)
        } else {
            if !number.isEmpty {
                result += Int(number)!
                number = ""
            }
        }
    }
    if !number.isEmpty {
        result += Int(number)!
    }
    return result
}

// 6.
// Given a string, return the length of the largest "block" in the string. A block is a run of adjacent chars that are
if CharacterSet.decimalDigits.contains(char) { // cannot convert value of type 'Character' to expected argument type 'Unicode.Scalar'

func parseMusic(musicString: String) -> [Int] {
    // TODO: Implement this function
    return []
}
```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] {
    // TODO: Implement this function
    return []
}
```
 // XCTAssertTrue failed

func parseMusic(musicString: String) -> [Int] {
    var result = [Int]()
    let notes = musicString.split(separator: " ")
    for note in notes {
        if note == "o" {
            result.append(4)
        } else if note == "o|" {
            result.append(2)
        } else if note == ".|" {
            result.append(1)
        }
    }
    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]()
    let notes = musicString.split(separator: " ")
    for note in notes {
        if note == "o" {
            result.append(4)
        } else if note == "o|" {
            result.append(2)
        } else if note == ".|" {
            result.append(1)
        }
    }
    return result
}

// 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]()
    let notes = musicString.split(separator: " ")
    for note in notes {
        if note == "o" {
            result.append(4)
        } else if note == "o|" {
            result.append(2)
        } else if note == ".|" {
            result.append(1)
        }
    }
    return result
}

// 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]()
    let notes = musicString.split(separator: " ")
    for note in notes {
        if note == "o" {
            result.append(4)
        } else if note == "o|" {
            result.append(2)
        } else if note == ".|" {
            result.append(1)
        }
    }
    return result
}

// 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]()
    let notes = musicString.split(separator: " ")
    for note in notes {
        if note == "o" {
            result.append(4)
        } else if note == "o|" {
            result.append(2)
        } else if note == ".|" {
            result.append(1)
        }
    }
    return result
}

// 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

func parseMusic(musicString: String) -> [Int] {
    var result = [Int]()
    let notes = musicString.split(separator: " ")
    for note in notes {
        if note == "o" {
            result.append(4)
        } else if note == "o|" {
            result.append(2)
        } else if note == ".|" {
            result.append(1)
        }
    }
    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]()
    let notes = musicString.split(separator: " ")
    for note in notes {
        if note == "o" {
            result.append(4)
        } else if note == "o|" {
            result.append(2)
        } else if note == ".|" {
            result.append(1)
        }
    }
    return result
}

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

func parseMusic(musicString: String) -> [Int] {
    var result: [Int] = []
    let beats = musicString.split(separator: " ")
    for beat in beats {
        if beat == "o" {
            result.append(4)
        } else if beat == "o|" {
            result.append(2)
        } else if beat == ".|" {
            result.append(1)
        }
    }
    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] = []
    let beats = musicString.split(separator: " ")
    for beat in beats {
        if beat == "o" {
            result.append(4)
        } else if beat == "o|" {
            result.append(2)
        } else if beat == ".|" {
            result.append(1)
        }
    }
    return result
}

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

func parseMusic(musicString: String) -> [Int] {
    var result: [Int] = []
    let beats = ["o": 4, "o|": 2, ".|": 1]
    let notes = musicString.split(separator: " ")
    for note in notes {
        result.append(beats[String(note)]!)
    }
    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] = []
    let beats = ["o": 4, "o|": 2, ".|": 1]
    let notes = musicString.split(separator: " ")
    for note in notes {
        result.append(beats[String(note)]!)
    }
    return result
}

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

func parseMusic(musicString: String) -> [Int] {
    var result = [Int]()
    var beats = 0
    for char in musicString {
        if char == "o" {
            beats = 4
        } else if char == "|" {
            result.append(beats)
            beats = 0
        } else if char == "." {
            beats = 1
        }
    }
    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 beats = 0
    for char in musicString {
        if char == "o" {
            beats = 4
        } else if char == "|" {
            result.append(beats)
            beats = 0
        } else if char == "." {
            beats = 1
        }
    }
    return result
}

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

func parseMusic(musicString: String) -> [Int] {
    let beats = musicString.split(separator: " ").map {
        switch $0 {
        case "o":
            return 4
        case "o|":
            return 2
        case ".|":
            return 1
        default:
            return 0
        }
    }
    return beats.filter { $0 != 0 }
}
```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 beats = musicString.split(separator: " ").map {
        switch $0 {
        case "o":
            return 4
        case "o|":
            return 2
        case ".|":
            return 1
        default:
            return 0
        }
    }
    return beats.filter { $0 != 0 }
}

// 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 beats = musicString.split(separator: " ").map {
        switch $0 {
        case "o":
            return 4
        case "o|":
            return 2
        case ".|":
            return 1
        default:
            return 0
        }
    }
    return beats.filter { $0 != 0 }
}

// 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 beats = musicString.split(separator: " ").map {
        switch $0 {
        case "o":
            return 4
        case "o|":
            return 2
        case ".|":
            return 1
        default:
            return 0
        }
    }
    return beats.filter { $0 != 0 }
}

// 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 beats = musicString.split(separator: " ").map {
        switch $0 {
        case "o":
            return 4
        case "o|":
            return 2
        case ".|":
            return 1
        default:
            return 0
        }
    }
    return beats.filter { $0 != 0 }
}

// 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, 

func parseMusic(musicString: String) -> [Int] {
    var result: [Int] = []
    let beats = musicString.split(separator: " ")
    for beat in beats {
        if beat == "o" {
            result.append(4)
        } else if beat == "o|" {
            result.append(2)
        } else if beat == ".|" {
            result.append(1)
        }
    }
    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] = []
    let beats = musicString.split(separator: " ")
    for beat in beats {
        if beat == "o" {
            result.append(4)
        } else if beat == "o|" {
            result.append(2)
        } else if beat == ".|" {
            result.append(1)
        }
    }
    return result
}

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

func parseMusic(musicString: String) -> [Int] {
    var beats = [Int]()
    let notes = musicString.split(separator: " ")
    for note in notes {
        if note == "o" {
            beats.append(4)
        } else if note == "o|" {
            beats.append(2)
        } else if note == ".|" {
            beats.append(1)
        }
    }
    return beats
}
```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 beats = [Int]()
    let notes = musicString.split(separator: " ")
    for note in notes {
        if note == "o" {
            beats.append(4)
        } else if note == "o|" {
            beats.append(2)
        } else if note == ".|" {
            beats.append(1)
        }
    }
    return beats
}

// Example usage:
let beats = parseMusic(musicString: "o o| .| o| o| .| .| .| .| o o")
print(beats)
// Output: [4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]

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

func howManyTimes(string: String, substring: String) -> Int {
    var count = 0
    var index = string.startIndex
    while index != string.endIndex {
        if let found = string.index(from: index, offsetBy: substring.count, limitedBy: string.endIndex) {
            let substringRange = index..<found
            if String(string[substringRange]) == substring {
                count += 1
                index = found
            } else {
                index = string.index(after: index)
            }
        } else {
            break
        }
    }
    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 = string.startIndex
    while index != string.endIndex {
        if let found = string.index(from: index, offsetBy: substring.count, limitedBy: string.endIndex) {
            let substringRange = index..<found
            if String(string[substringRange]) == substring {
                count += 1
                index = found
            } else {
                index = string.index(after: index)
            }
        } else {
            break
        }
    }
    return count
}

// Test cases
print(howManyTimes(string: "", substring: "a") == 0)
print(howManyTimes(string: "aaa", substring: "a") == 3)
print(howManyTimes(string: "aaaa", substring: "aa") == 3)
print(howManyTimes(string: "aaaa", substring: "aaa") == 2)
print(howManyTimes(string: "aaaa", substring: "aaaa") == 1)
print(howManyTimes(string: "aaaa", substring: "aaaaa") == 0)
print(howManyTimes(string: "aaaa", substring: "bbb") == 0)
print(howManyTimes(string: "aaaa", substring: "") == 0)
print(howManyTimes(string: "", substring: "") == 0)
```
if let found = string.index(from: index, offsetBy: substring.count, limitedBy: string.endIndex) { // no exact matches in call to instance method 'index'

func howManyTimes(string: String, substring: String) -> Int {
    var count = 0
    var index = string.startIndex
    while index != string.endIndex {
        if let foundIndex = string.index(from: index, offsetBy: substring.count, limitedBy: string.endIndex) {
            let substringRange = index..<foundIndex
            let substring = String(string[substringRange])
            if substring == substring {
                count += 1
                index = foundIndex
            } else {
                index = string.index(after: index)
            }
        } else {
            break
        }
    }
    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 = string.startIndex
    while index != string.endIndex {
        if let foundIndex = string.index(from: index, offsetBy: substring.count, limitedBy: string.endIndex) {
            let substringRange = index..<foundIndex
            let substring = String(string[substringRange])
            if substring == substring {
                count += 1
                index = foundIndex
            } else {
                index = string.index(after: index)
            }
        } else {
            break
        }
    }
    return count
}
```
if let foundIndex = string.index(from: index, offsetBy: substring.count, limitedBy: string.endIndex) { // no exact matches in call to instance method 'index'

func howManyTimes(string: String, substring: String) -> Int {
    var count = 0
    var startIndex = string.startIndex
    while startIndex < string.endIndex {
        if let foundIndex = string.index(from: startIndex, offsetBy: substring.count) {
            let substringRange = startIndex..<foundIndex
            let substring = String(string[substringRange])
            if substring == substring {
                count += 1
            }
            startIndex = foundIndex
        } else {
            break
        }
    }
    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 startIndex = string.startIndex
    while startIndex < string.endIndex {
        if let foundIndex = string.index(from: startIndex, offsetBy: substring.count) {
            let substringRange = startIndex..<foundIndex
            let substring = String(string[substringRange])
            if substring == substring {
                count += 1
            }
            startIndex = foundIndex
        } else {
            break
        }
    }
    return count
}

// 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 startIndex = string.startIndex
    while startIndex < string.endIndex {
        if let foundIndex = string.index(from: startIndex, offsetBy: substring.count) {
            let substringRange = startIndex..<foundIndex
            let substring = String(string[substringRange])
            if substring == substring {
                count += 1
            }
            startIndex = foundIndex
        } else {
            break
        }
    }
    return count
}

// 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 startIndex = string.startIndex
    while startIndex < string.endIndex {
        if let foundIndex = string.index(from: startIndex, offsetBy: substring.count) {
            let substringRange = startIndex..<foundIndex
            let substring = String(string[substringRange])
            if substring == substring {
                count += 1
            }
            startIndex = foundIndex
        } else {
            break
        }
    }
    return count
}

// 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 startIndex = string.startIndex
    while startIndex < string.endIndex {
        if let foundIndex = string.index(from: startIndex, offsetBy: substring.count) {
            let substringRange = startIndex..<foundIndex
            let substring = String(string[substringRange])
            if substring == substring {
                count += 1
            }
            startIndex = foundIndex
        } else {
            break
        }
    }
    return count
}

// 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 startIndex = string.startIndex
    while startIndex < string.endIndex {
        if let foundIndex = string.index(from: startIndex, offsetBy: substring.count) {
            let substringRange = startIndex..<foundIndex
            let substring = String(string[substringRange])
            if substring == substring {
                count += 1
if let foundIndex = string.index(from: startIndex, offsetBy: substring.count) { // no exact matches in call to instance method 'index'

func howManyTimes(string: String, substring: String) -> Int {
    var count = 0
    var startIndex = string.startIndex
    while let foundIndex = string.index(from: startIndex, offsetBy: substring.count, limitedBy: string.endIndex) {
        if string[startIndex..<foundIndex] == substring {
            count += 1
            startIndex = foundIndex
        } else {
            startIndex = string.index(after: startIndex)
        }
    }
    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 startIndex = string.startIndex
    while let foundIndex = string.index(from: startIndex, offsetBy: substring.count, limitedBy: string.endIndex) {
        if string[startIndex..<foundIndex] == substring {
            count += 1
            startIndex = foundIndex
        } else {
            startIndex = string.index(after: startIndex)
        }
    }
    return count
}
```
while let foundIndex = string.index(from: startIndex, offsetBy: substring.count, limitedBy: string.endIndex) { // no exact matches in call to instance method 'index'

func howManyTimes(string: String, substring: String) -> Int {
    var count = 0
    var startIndex = string.startIndex
    while let foundIndex = string.index(from: startIndex, offsetBy: 1, limitedBy: string.endIndex) {
        if string[startIndex..<foundIndex] == substring {
            count += 1
        }
        startIndex = foundIndex
    }
    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 startIndex = string.startIndex
    while let foundIndex = string.index(from: startIndex, offsetBy: 1, limitedBy: string.endIndex) {
        if string[startIndex..<foundIndex] == substring {
            count += 1
        }
        startIndex = foundIndex
    }
    return count
}

print(howManyTimes(string: "", substring: "a"))
print(howManyTimes(string: "aaa", substring: "a"))
print(howManyTimes(string: "aaaa", substring: "aa"))
```
while let foundIndex = string.index(from: startIndex, offsetBy: 1, limitedBy: string.endIndex) { // no exact matches in call to instance method 'index'

func howManyTimes(string: String, substring: String) -> Int {
    var count = 0
    var index = string.startIndex
    while index != string.endIndex {
        if let found = string.index(from: index, offsetBy: substring.count, limitedBy: string.endIndex) {
            let substringRange = index..<found
            if String(string[substringRange]) == substring {
                count += 1
                index = found
            } else {
                index = string.index(after: index)
            }
        } else {
            break
        }
    }
    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 = string.startIndex
    while index != string.endIndex {
        if let found = string.index(from: index, offsetBy: substring.count, limitedBy: string.endIndex) {
            let substringRange = index..<found
            if String(string[substringRange]) == substring {
                count += 1
                index = found
            } else {
                index = string.index(after: index)
            }
        } else {
            break
        }
    }
    return count
}

print(howManyTimes(string: "aaa", substring: "a"))
print(howManyTimes(string: "aaaa", substring: "aa"))
print(howManyTimes(string: "aaaa", substring: "aaa"))
print(howManyTimes(string: "aaaa", substring: "aaaa"))
print(howManyTimes(string: "aaaa", substring: "aaaaa"))
print(howManyTimes(string: "aaaa", substring: ""))
print(howManyTimes(string: "", substring: "a"))
print(howManyTimes(string: "", substring: ""))
```
if let found = string.index(from: index, offsetBy: substring.count, limitedBy: string.endIndex) { // no exact matches in call to instance method 'index'

func howManyTimes(string: String, substring: String) -> Int {
    var count = 0
    var index = string.startIndex
    while let range = string.range(of: substring, range: index..<string.endIndex) {
        count += 1
        index = range.upperBound
    }
    return count
}

func longestRepeatedSubstring(string: String) -> String {
    var max = ""
    for i in 0..<string.count {
        for j in i+1..<string.count {
            let substring = String(string[i..<j])
            let count = howManyTimes(string: string, substring: substring)
            if count > 1 && substring.count > max.count {
                max = substring
            }
        }
    }
    return max
}

func longestRepeatedSubstring2(string: String) -> String {
    var max = ""
    for i in 0..<string.count {
        for j in i+1..<string.count {
            let substring = String(string[i..<j])
            let count = howManyTimes(string: string, substring: substring)
            if count > 1 && substring.count > max.count {
                max = substring
            }
        }
    }
    return max
}

func longestRepeatedSubstring3(string: String) -> String {
    var max = ""
    for i in 0..<string.count {
        for j in i+1..<string.count {
            let substring = String(string[i..<j])
            let count = howManyTimes(string: string, substring: substring)
            if count > 1 && substring.count > max.count {
                max = substring
            }
        }
    }
    return max
}
```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 = string.startIndex
    while let range = string.range(of: substring, range: index..<string.endIndex) {
        count += 1
        index = range.upperBound
    }
    return count
}

// Find the longest substring that is repeated at least once.
// longestRepeatedSubstring(string: "") == ""
// longestRepeatedSubstring(string: "aaa") == "aa"
// longestRepeatedSubstring(string: "aaaa") == "aaa"
// longestRepeatedSubstring(string: "abcabc") == "abc"
// longestRepeatedSubstring(string: "abcabcabc") == "abcabc"
// longestRepeatedSubstring(string: "abcabcabcabc") == "abcabcabc"
func longestRepeatedSubstring(string: String) -> String {
    var max = ""
    for i in 0..<string.count {
        for j in i+1..<string.count {
            let substring = String(string[i..<j])
            let count = howManyTimes(string: string, substring: substring)
            if count > 1 && substring.count > max.count {
                max = substring
            }
        }
    }
    return max
}

// Find the longest substring that is repeated at least once, but only count non-overlapping cases.
// longestRepeatedSubstring(string: "") == ""
// longestRepeatedSubstring(string: "aaa") == "a"
// longestRepeatedSubstring(string: "aaaa") == "aa"
// longestRepeatedSubstring(string: "abcabc") == "abc"
// longestRepeatedSubstring(string: "abcabcabc") == "abc"
// longestRepeatedSubstring(string: "abcabcabcabc") == "abc"
func longestRepeatedSubstring2(string: String) -> String {
    var max = ""
    for i in 0..<string.count {
        for j in i+1..<string.count {
            let substring = String(string[i..<j])
            let count = howManyTimes(string: string, substring: substring)
            if count > 1 && substring.count > max.count {
                max = substring
            }
        }
    }
    return max
}

// Find the longest substring that is repeated at least once, but only count non-overlapping cases.
// longestRepeatedSubstring(string: "") == ""
// longestRepeatedSubstring(string: "aaa") == "a"
// longestRepeatedSubstring(string: "aaaa") == "aa"
// longestRepeatedSubstring(string: "abcabc") == "abc"
// longestRepeatedSubstring(string: "abcabcabc") == "abc"
// longestRepeatedSubstring(string: "abcabcabcabc") == "abc"
func longestRepeatedSubstring3(string: String) -> String {
    var max = ""
    for i in 0..<string.count {
        for j in i+1..<string.count {
            let substring = String(string[i..<j])
            let count = howManyTimes(string: string, substring: substring)
            if count > 1 && substring.count > max.count {
                max = substring
            }
        }
    }
    return max
}

// Find the longest substring that is repeated at least once, but only count non-overlapping cases.
// longestRepeatedSubstring(string: "") == ""
// longestRepeatedSubstring(string: "aaa") == "a"
// longestRepeatedSubstring(string: "aaaa") == "aa"
// longestRepeatedSubstring(string: "abcabc") == "abc"
// longestRepeatedSubstring(string: "abcabcabc") == "abc"
// longestRepeatedSubstring(string: "abcabcabcabc") == "abc"
func longestRepeatedSubstring4(string: String) -> String {
    var max = ""
    for i in 0..<string.count {
        for j in i
let substring = String(string[i..<j]) // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.
let substring = String(string[i..<j]) // 'subscript(_:)' is unavailable: cannot subscript String with an integer range, use a String.Index range instead.
let substring = String(string[i..<j]) // '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 = string.startIndex
    while let found = string.index(from: index, offsetBy: substring.count, limitedBy: string.endIndex) {
        if String(string[index..<found]) == substring {
            count += 1
        }
        index = found
    }
    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 = string.startIndex
    while let found = string.index(from: index, offsetBy: substring.count, limitedBy: string.endIndex) {
        if String(string[index..<found]) == substring {
            count += 1
        }
        index = found
    }
    return count
}

print(howManyTimes(string: "", substring: "a"))
print(howManyTimes(string: "aaa", substring: "a"))
print(howManyTimes(string: "aaaa", substring: "aa"))
```
while let found = string.index(from: index, offsetBy: substring.count, limitedBy: string.endIndex) { // no exact matches in call to instance method 'index'

func howManyTimes(string: String, substring: String) -> Int {
    // your code here
}
```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 {
    // your code here
}
```
} // missing return in global function expected to return 'Int'

func howManyTimes(string: String, substring: String) -> Int {
    var count = 0
    var startIndex = string.startIndex
    while startIndex < string.endIndex {
        let foundIndex = string.index(from: startIndex, offsetBy: 1)
        if foundIndex != nil {
            count += 1
            startIndex = foundIndex!
        } else {
            break
        }
    }
    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 startIndex = string.startIndex
    while startIndex < string.endIndex {
        let foundIndex = string.index(from: startIndex, offsetBy: 1)
        if foundIndex != nil {
            count += 1
            startIndex = foundIndex!
        } else {
            break
        }
    }
    return count
}

print(howManyTimes(string: "aaa", substring: "a"))
print(howManyTimes(string: "aaaa", substring: "aa"))
print(howManyTimes(string: "aaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaaaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaaaaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaaaaaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaaaaaaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaaaaaaaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaaaaaaaaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaaaaaaaaaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaaaaaaaaaaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaaaaaaaaaaaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaaaaaaaaaaaaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaaaaaaaaaaaaaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaaaaaaaaaaaaaaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaaaaaaaaaaaaaaaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaaaaaaaaaaaaaaaaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaaaaaaaaaaaaaaaaaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", substring: "aa"))
print(howManyTimes(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
let foundIndex = string.index(from: startIndex, offsetBy: 1) // no exact matches in call to instance method 'index'

func sortNumbers(numbers: String) -> String {
    let numbersArray = numbers.split(separator: " ")
    let sortedNumbersArray = numbersArray.sorted {
        let firstNumber = getNumberFromString($0)
        let secondNumber = getNumberFromString($1)
        return firstNumber < secondNumber
    }
    return sortedNumbersArray.joined(separator: " ")
}

func getNumberFromString(_ string: String) -> Int {
    switch string {
    case "zero": return 0
    case "one": return 1
    case "two": return 2
    case "three": return 3
    case "four": return 4
    case "five": return 5
    case "six": return 6
    case "seven": return 7
    case "eight": return 8
    case "nine": return 9
    default: return 0
    }
}
```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 numbersArray = numbers.split(separator: " ")
    let sortedNumbersArray = numbersArray.sorted {
        let firstNumber = getNumberFromString($0)
        let secondNumber = getNumberFromString($1)
        return firstNumber < secondNumber
    }
    return sortedNumbersArray.joined(separator: " ")
}

func getNumberFromString(_ string: String) -> Int {
    switch string {
    case "zero": return 0
    case "one": return 1
    case "two": return 2
    case "three": return 3
    case "four": return 4
    case "five": return 5
    case "six": return 6
    case "seven": return 7
    case "eight": return 8
    case "nine": return 9
    default: return 0
    }
}

print(sortNumbers(numbers: "three one five"))
print(sortNumbers(numbers: "six five four three two one zero"))
```
let firstNumber = getNumberFromString($0) // cannot convert value of type 'String.SubSequence' (aka 'Substring') to expected argument type 'String'

func sortNumbers(numbers: String) -> String {
    let numbersArray = numbers.split(separator: " ")
    let sortedNumbersArray = numbersArray.sorted {
        let number1 = getNumberFromString($0)
        let number2 = getNumberFromString($1)
        return number1 < number2
    }
    return sortedNumbersArray.joined(separator: " ")
}

func getNumberFromString(_ string: String) -> Int {
    switch string {
    case "zero":
        return 0
    case "one":
        return 1
    case "two":
        return 2
    case "three":
        return 3
    case "four":
        return 4
    case "five":
        return 5
    case "six":
        return 6
    case "seven":
        return 7
    case "eight":
        return 8
    case "nine":
        return 9
    default:
        return 0
    }
}
```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 numbersArray = numbers.split(separator: " ")
    let sortedNumbersArray = numbersArray.sorted {
        let number1 = getNumberFromString($0)
        let number2 = getNumberFromString($1)
        return number1 < number2
    }
    return sortedNumbersArray.joined(separator: " ")
}

func getNumberFromString(_ string: String) -> Int {
    switch string {
    case "zero":
        return 0
    case "one":
        return 1
    case "two":
        return 2
    case "three":
        return 3
    case "four":
        return 4
    case "five":
        return 5
    case "six":
        return 6
    case "seven":
        return 7
    case "eight":
        return 8
    case "nine":
        return 9
    default:
        return 0
    }
}

print(sortNumbers(numbers: "three one five"))
```
let number1 = getNumberFromString($0) // cannot convert value of type 'String.SubSequence' (aka 'Substring') to expected argument type 'String'

func sortNumbers(numbers: String) -> String {
    let numberWords = ["zero": 0, "one": 1, "two": 2, "three": 3, "four": 4, "five": 5, "six": 6, "seven": 7, "eight": 8, "nine": 9]
    let numberWordsReversed = [0: "zero", 1: "one", 2: "two", 3: "three", 4: "four", 5: "five", 6: "six", 7: "seven", 8: "eight", 9: "nine"]
    var numbersArray = numbers.components(separatedBy: " ")
    var numbersIntArray = [Int]()
    for number in numbersArray {
        numbersIntArray.append(numberWords[number]!)
    }
    numbersIntArray.sort()
    var sortedNumbersArray = [String]()
    for number in numbersIntArray {
        sortedNumbersArray.append(numberWordsReversed[number]!)
    }
    return sortedNumbersArray.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 numberWords = ["zero": 0, "one": 1, "two": 2, "three": 3, "four": 4, "five": 5, "six": 6, "seven": 7, "eight": 8, "nine": 9]
    let numberWordsReversed = [0: "zero", 1: "one", 2: "two", 3: "three", 4: "four", 5: "five", 6: "six", 7: "seven", 8: "eight", 9: "nine"]
    var numbersArray = numbers.components(separatedBy: " ")
    var numbersIntArray = [Int]()
    for number in numbersArray {
        numbersIntArray.append(numberWords[number]!)
    }
    numbersIntArray.sort()
    var sortedNumbersArray = [String]()
    for number in numbersIntArray {
        sortedNumbersArray.append(numberWordsReversed[number]!)
    }
    return sortedNumbersArray.joined(separator: " ")
}

print(sortNumbers(numbers: "three one five"))
print(sortNumbers(numbers: "five one two three four"))
print(sortNumbers(numbers: "zero zero zero one one one two two two three three three four four four five five five six six six seven seven seven eight eight eight nine nine nine"))
print(sortNumbers(numbers: "zero one two three four five six seven eight nine"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "zero one two three four five six seven eight nine"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "zero one two three four five six seven eight nine"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "zero one two three four five six seven eight nine"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "zero one two three four five six seven eight nine"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "zero one two three four five six seven eight nine"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "zero one two three four five six seven eight nine"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "zero one two three four five six seven eight nine"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "zero one two three four five six seven eight nine"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "zero one two three four five six seven eight nine"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "zero one two three four five six seven eight nine"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "zero one two three four five six seven eight nine"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "zero one two three four five six seven eight nine"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "zero one two three four five six seven eight nine"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "zero one two three four five six seven eight nine"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "zero one two three four five six seven eight
var numbersArray = numbers.components(separatedBy: " ") // variable 'numbersArray' was never mutated; consider changing to 'let' constant
 // Fatal error: Unexpectedly found nil while unwrapping an Optional value

func sortNumbers(numbers: String) -> String {
    let numbersArray = numbers.split(separator: " ")
    let sortedNumbersArray = numbersArray.sorted { (first, second) -> Bool in
        return first < second
    }
    return sortedNumbersArray.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 numbersArray = numbers.split(separator: " ")
    let sortedNumbersArray = numbersArray.sorted { (first, second) -> Bool in
        return first < second
    }
    return sortedNumbersArray.joined(separator: " ")
}

print(sortNumbers(numbers: "three one five"))
```
 // XCTAssertTrue failed

func sortNumbers(numbers: String) -> String {
    let numbersArray = numbers.components(separatedBy: " ")
    let sortedNumbers = numbersArray.sorted {
        let number1 = numberStringToInt($0)
        let number2 = numberStringToInt($1)
        return number1 < number2
    }
    return sortedNumbers.joined(separator: " ")
}

func numberStringToInt(_ numberString: String) -> Int {
    switch numberString {
    case "zero": return 0
    case "one": return 1
    case "two": return 2
    case "three": return 3
    case "four": return 4
    case "five": return 5
    case "six": return 6
    case "seven": return 7
    case "eight": return 8
    case "nine": return 9
    default: return 0
    }
}
```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 numbersArray = numbers.components(separatedBy: " ")
    let sortedNumbers = numbersArray.sorted {
        let number1 = numberStringToInt($0)
        let number2 = numberStringToInt($1)
        return number1 < number2
    }
    return sortedNumbers.joined(separator: " ")
}

func numberStringToInt(_ numberString: String) -> Int {
    switch numberString {
    case "zero": return 0
    case "one": return 1
    case "two": return 2
    case "three": return 3
    case "four": return 4
    case "five": return 5
    case "six": return 6
    case "seven": return 7
    case "eight": return 8
    case "nine": return 9
    default: return 0
    }
}

print(sortNumbers(numbers: "three one five"))
print(sortNumbers(numbers: "five one three"))
print(sortNumbers(numbers: "four three two one"))
print(sortNumbers(numbers: "zero zero zero"))
print(sortNumbers(numbers: "one two three four five six seven eight nine"))
print(sortNumbers(numbers: "nine eight seven six five four three two one"))
print(sortNumbers(numbers: "zero one two three four five six seven eight nine"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "zero one two three four five six seven eight nine"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "zero one two three four five six seven eight nine"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "zero one two three four five six seven eight nine"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "zero one two three four five six seven eight nine"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "zero one two three four five six seven eight nine"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "zero one two three four five six seven eight nine"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "zero one two three four five six seven eight nine"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "zero one two three four five six seven eight nine"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "zero one two three four five six seven eight nine"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "zero one two three four five six seven eight nine"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "zero one two three four five six seven eight nine"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "zero one two three four five six seven eight nine"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "zero one two three four five six seven eight nine"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "zero one two three four five six seven eight nine"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "zero one two three four five six seven eight nine"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers

func sortNumbers(numbers: String) -> String {
    let numberMap = ["zero": 0, "one": 1, "two": 2, "three": 3, "four": 4, "five": 5, "six": 6, "seven": 7, "eight": 8, "nine": 9]
    let numbersArray = numbers.components(separatedBy: " ")
    let sortedNumbers = numbersArray.sorted { numberMap[$0]! < numberMap[$1]! }
    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 numberMap = ["zero": 0, "one": 1, "two": 2, "three": 3, "four": 4, "five": 5, "six": 6, "seven": 7, "eight": 8, "nine": 9]
    let numbersArray = numbers.components(separatedBy: " ")
    let sortedNumbers = numbersArray.sorted { numberMap[$0]! < numberMap[$1]! }
    return sortedNumbers.joined(separator: " ")
}

print(sortNumbers(numbers: "three one five"))
print(sortNumbers(numbers: "five six two"))
print(sortNumbers(numbers: "one two three four five six seven eight nine zero"))
print(sortNumbers(numbers: ""))
print(sortNumbers(numbers: "one one one one one one one one one one one one one one"))
print(sortNumbers(numbers: "zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero

func sortNumbers(numbers: String) -> String {
    let numbersArray = numbers.split(separator: " ")
    var sortedNumbersArray = [String]()
    var sortedNumbers = ""
    for number in numbersArray {
        switch number {
        case "zero":
            sortedNumbersArray.append("0")
        case "one":
            sortedNumbersArray.append("1")
        case "two":
            sortedNumbersArray.append("2")
        case "three":
            sortedNumbersArray.append("3")
        case "four":
            sortedNumbersArray.append("4")
        case "five":
            sortedNumbersArray.append("5")
        case "six":
            sortedNumbersArray.append("6")
        case "seven":
            sortedNumbersArray.append("7")
        case "eight":
            sortedNumbersArray.append("8")
        case "nine":
            sortedNumbersArray.append("9")
        default:
            print("Invalid number")
        }
    }
    sortedNumbersArray.sort()
    for number in sortedNumbersArray {
        switch number {
        case "0":
            sortedNumbers += "zero "
        case "1":
            sortedNumbers += "one "
        case "2":
            sortedNumbers += "two "
        case "3":
            sortedNumbers += "three "
        case "4":
            sortedNumbers += "four "
        case "5":
            sortedNumbers += "five "
        case "6":
            sortedNumbers += "six "
        case "7":
            sortedNumbers += "seven "
        case "8":
            sortedNumbers += "eight "
        case "9":
            sortedNumbers += "nine "
        default:
            print("Invalid number")
        }
    }
    return String(sortedNumbers.dropLast())
}
```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 numbersArray = numbers.split(separator: " ")
    var sortedNumbersArray = [String]()
    var sortedNumbers = ""
    for number in numbersArray {
        switch number {
        case "zero":
            sortedNumbersArray.append("0")
        case "one":
            sortedNumbersArray.append("1")
        case "two":
            sortedNumbersArray.append("2")
        case "three":
            sortedNumbersArray.append("3")
        case "four":
            sortedNumbersArray.append("4")
        case "five":
            sortedNumbersArray.append("5")
        case "six":
            sortedNumbersArray.append("6")
        case "seven":
            sortedNumbersArray.append("7")
        case "eight":
            sortedNumbersArray.append("8")
        case "nine":
            sortedNumbersArray.append("9")
        default:
            print("Invalid number")
        }
    }
    sortedNumbersArray.sort()
    for number in sortedNumbersArray {
        switch number {
        case "0":
            sortedNumbers += "zero "
        case "1":
            sortedNumbers += "one "
        case "2":
            sortedNumbers += "two "
        case "3":
            sortedNumbers += "three "
        case "4":
            sortedNumbers += "four "
        case "5":
            sortedNumbers += "five "
        case "6":
            sortedNumbers += "six "
        case "7":
            sortedNumbers += "seven "
        case "8":
            sortedNumbers += "eight "
        case "9":
            sortedNumbers += "nine "
        default:
            print("Invalid number")
        }
    }
    return String(sortedNumbers.dropLast())
}

print(sortNumbers(numbers: "three one five"))
print(sortNumbers(numbers: "five four three two one"))
print(sortNumbers(numbers: "eight seven six five four three two one"))
print(sortNumbers(numbers: "nine eight seven six five four three two one"))
print(sortNumbers(numbers: "zero one two three four five six seven eight nine"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))
print(sortNumbers(numbers: "nine eight seven six five four three two one zero"))

func sortNumbers(numbers: String) -> String {
    let numbersArray = numbers.split(separator: " ")
    let sortedNumbersArray = numbersArray.sorted {
        switch $0 {
        case "zero": return $1 != "zero"
        case "one": return $1 != "zero" && $1 != "one"
        case "two": return $1 != "zero" && $1 != "one" && $1 != "two"
        case "three": return $1 != "zero" && $1 != "one" && $1 != "two" && $1 != "three"
        case "four": return $1 != "zero" && $1 != "one" && $1 != "two" && $1 != "three" && $1 != "four"
        case "five": return $1 != "zero" && $1 != "one" && $1 != "two" && $1 != "three" && $1 != "four" && $1 != "five"
        case "six": return $1 != "zero" && $1 != "one" && $1 != "two" && $1 != "three" && $1 != "four" && $1 != "five" && $1 != "six"
        case "seven": return $1 != "zero" && $1 != "one" && $1 != "two" && $1 != "three" && $1 != "four" && $1 != "five" && $1 != "six" && $1 != "seven"
        case "eight": return $1 != "zero" && $1 != "one" && $1 != "two" && $1 != "three" && $1 != "four" && $1 != "five" && $1 != "six" && $1 != "seven" && $1 != "eight"
        case "nine": return $1 != "zero" && $1 != "one" && $1 != "two" && $1 != "three" && $1 != "four" && $1 != "five" && $1 != "six" && $1 != "seven" && $1 != "eight" && $1 != "nine"
        default: return false
        }
    }
    return sortedNumbersArray.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 numbersArray = numbers.split(separator: " ")
    let sortedNumbersArray = numbersArray.sorted {
        switch $0 {
        case "zero": return $1 != "zero"
        case "one": return $1 != "zero" && $1 != "one"
        case "two": return $1 != "zero" && $1 != "one" && $1 != "two"
        case "three": return $1 != "zero" && $1 != "one" && $1 != "two" && $1 != "three"
        case "four": return $1 != "zero" && $1 != "one" && $1 != "two" && $1 != "three" && $1 != "four"
        case "five": return $1 != "zero" && $1 != "one" && $1 != "two" && $1 != "three" && $1 != "four" && $1 != "five"
        case "six": return $1 != "zero" && $1 != "one" && $1 != "two" && $1 != "three" && $1 != "four" && $1 != "five" && $1 != "six"
        case "seven": return $1 != "zero" && $1 != "one" && $1 != "two" && $1 != "three" && $1 != "four" && $1 != "five" && $1 != "six" && $1 != "seven"
        case "eight": return $1 != "zero" && $1 != "one" && $1 != "two" && $1 != "three" && $1 != "four" && $1 != "five" && $1 != "six" && $1 != "seven" && $1 != "eight"
        case "nine": return $1 != "zero" && $1 != "one" && $1 != "two" && $1 != "three" && $1 != "four" && $1 != "five" && $1 != "six" && $1 != "seven" && $1 != "eight" && $1 != "nine"
        default: return false
        }
    }
    return sortedNumbersArray.joined(separator: " ")
}
```

func sortNumbers(numbers: String) -> String {
    let numberWords = ["zero": 0, "one": 1, "two": 2, "three": 3, "four": 4, "five": 5, "six": 6, "seven": 7, "eight": 8, "nine": 9]
    let numbers = numbers.split(separator: " ").map { numberWords[$0] ?? 0 }
    let sortedNumbers = numbers.sorted()
    let sortedWords = sortedNumbers.map { numberWords.first(where: { $0.value == $0 })!.key }
    return sortedWords.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 numberWords = ["zero": 0, "one": 1, "two": 2, "three": 3, "four": 4, "five": 5, "six": 6, "seven": 7, "eight": 8, "nine": 9]
    let numbers = numbers.split(separator: " ").map { numberWords[$0] ?? 0 }
    let sortedNumbers = numbers.sorted()
    let sortedWords = sortedNumbers.map { numberWords.first(where: { $0.value == $0 })!.key }
    return sortedWords.joined(separator: " ")
}

print(sortNumbers(numbers: "three one five"))
```
let numbers = numbers.split(separator: " ").map { numberWords[$0] ?? 0 } // cannot convert value of type 'String.SubSequence' (aka 'Substring') to expected argument type 'String'
let sortedWords = sortedNumbers.map { numberWords.first(where: { $0.value == $0 })!.key } // binary operator '==' cannot be applied to operands of type 'Int' and 'Dictionary<String, Int>.Element' (aka '(key: String, value: Int)')

func sortNumbers(numbers: String) -> String {
    let numbersArray = numbers.split(separator: " ")
    let sortedNumbersArray = numbersArray.sorted {
        switch ($0, $1) {
        case ("zero", "one"): return true
        case ("zero", "two"): return true
        case ("zero", "three"): return true
        case ("zero", "four"): return true
        case ("zero", "five"): return true
        case ("zero", "six"): return true
        case ("zero", "seven"): return true
        case ("zero", "eight"): return true
        case ("zero", "nine"): return true
        case ("one", "two"): return true
        case ("one", "three"): return true
        case ("one", "four"): return true
        case ("one", "five"): return true
        case ("one", "six"): return true
        case ("one", "seven"): return true
        case ("one", "eight"): return true
        case ("one", "nine"): return true
        case ("two", "three"): return true
        case ("two", "four"): return true
        case ("two", "five"): return true
        case ("two", "six"): return true
        case ("two", "seven"): return true
        case ("two", "eight"): return true
        case ("two", "nine"): return true
        case ("three", "four"): return true
        case ("three", "five"): return true
        case ("three", "six"): return true
        case ("three", "seven"): return true
        case ("three", "eight"): return true
        case ("three", "nine"): return true
        case ("four", "five"): return true
        case ("four", "six"): return true
        case ("four", "seven"): return true
        case ("four", "eight"): return true
        case ("four", "nine"): return true
        case ("five", "six"): return true
        case ("five", "seven"): return true
        case ("five", "eight"): return true
        case ("five", "nine"): return true
        case ("six", "seven"): return true
        case ("six", "eight"): return true
        case ("six", "nine"): return true
        case ("seven", "eight"): return true
        case ("seven", "nine"): return true
        case ("eight", "nine"): return true
        default: return false
        }
    }
    return sortedNumbersArray.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 numbersArray = numbers.split(separator: " ")
    let sortedNumbersArray = numbersArray.sorted {
        switch ($0, $1) {
        case ("zero", "one"): return true
        case ("zero", "two"): return true
        case ("zero", "three"): return true
        case ("zero", "four"): return true
        case ("zero", "five"): return true
        case ("zero", "six"): return true
        case ("zero", "seven"): return true
        case ("zero", "eight"): return true
        case ("zero", "nine"): return true
        case ("one", "two"): return true
        case ("one", "three"): return true
        case ("one", "four"): return true
        case ("one", "five"): return true
        case ("one", "six"): return true
        case ("one", "seven"): return true
        case ("one", "eight"): return true
        case ("one", "nine"): return true
        case ("two", "three"): return true
        case ("two", "four"): return true
        case ("two", "five"): return true
        case ("two", "six"): return true
        case ("two", "seven"): return true
        case ("two", "eight"): return true
        case ("two", "nine"): return true
        case ("three", "four"): return true
        case ("three", "five"): return true
        case ("three", "six"): return true
        case ("three", "seven"): return true
        case ("three", "eight"): return true
        case ("three", "nine"): return true
        case ("four", "five"): return true
        case ("four", "six"): return true
        case ("four", "seven"): return true
        case ("four", "eight"): return true
        case ("four", "nine"): return true
        case ("five", "six"): return true
        case ("five", "seven"): return true
        case ("five", "eight"): return true
        case ("five", "nine"): return true
        case ("six", "seven"): return true
        case ("six", "eight"): return true
        case ("six", "nine"): return true
        case ("seven", "eight"): return true
        case ("seven", "nine"): return true
        case ("eight", "nine"): return true
        default: return false
        }
    }
    return sortedNumbersArray.joined(separator: " ")
}
```

func findClosestElements(numbers: [Double]) -> (Double, Double) {
    // ...
}
```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) {
    // ...
}
```
} // missing return in global function expected to return '(Double, Double)'

func findClosestElements(numbers: [Double]) -> (Double, Double) {
    var minDistance = Double.max
    var closestElements: (Double, Double) = (0.0, 0.0)

    for i in 0..<numbers.count {
        for j in i+1..<numbers.count {
            let distance = abs(numbers[i] - numbers[j])
            if distance < minDistance {
                minDistance = distance
                closestElements = (numbers[i], numbers[j])
            }
        }
    }

    return closestElements
}
```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 minDistance = Double.max
    var closestElements: (Double, Double) = (0.0, 0.0)

    for i in 0..<numbers.count {
        for j in i+1..<numbers.count {
            let distance = abs(numbers[i] - numbers[j])
            if distance < minDistance {
                minDistance = distance
                closestElements = (numbers[i], numbers[j])
            }
        }
    }

    return closestElements
}

// Example usage
print(findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.2])) // Output: (2.0, 2.2)
print(findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.0])) // Output: (2.0, 2.0)

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
var minDistance = Double.max // type 'Double' has no member 'max'

func findClosestElements(numbers: [Double]) -> (Double, Double) {
    var minDistance = Double.max
    var closestElements: (Double, Double) = (0.0, 0.0)
    for i in 0..<numbers.count {
        for j in i+1..<numbers.count {
            let distance = abs(numbers[i] - numbers[j])
            if distance < minDistance {
                minDistance = distance
                closestElements = (numbers[i], numbers[j])
            }
        }
    }
    return closestElements
}
```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 minDistance = Double.max
    var closestElements: (Double, Double) = (0.0, 0.0)
    for i in 0..<numbers.count {
        for j in i+1..<numbers.count {
            let distance = abs(numbers[i] - numbers[j])
            if distance < minDistance {
                minDistance = distance
                closestElements = (numbers[i], numbers[j])
            }
        }
    }
    return closestElements
}

print(findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.2]))
print(findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.0]))
```
var minDistance = Double.max // type 'Double' has no member 'max'

func findClosestElements(numbers: [Double]) -> (Double, Double) {
    // ...
}
```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) {
    // ...
}
```
} // missing return in global function expected to return '(Double, Double)'

func findClosestElements(numbers: [Double]) -> (Double, Double) {
    // ...
}
```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) {
    // ...
}
```
} // missing return in global function expected to return '(Double, Double)'

func findClosestElements(numbers: [Double]) -> (Double, Double) {
    var minDistance = Double.infinity
    var closestElements: (Double, Double) = (0.0, 0.0)

    for i in 0..<numbers.count {
        for j in i + 1..<numbers.count {
            let distance = abs(numbers[i] - numbers[j])
            if distance < minDistance {
                minDistance = distance
                closestElements = (numbers[i], numbers[j])
            }
        }
    }

    return closestElements
}
```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 minDistance = Double.infinity
    var closestElements: (Double, Double) = (0.0, 0.0)

    for i in 0..<numbers.count {
        for j in i + 1..<numbers.count {
            let distance = abs(numbers[i] - numbers[j])
            if distance < minDistance {
                minDistance = distance
                closestElements = (numbers[i], numbers[j])
            }
        }
    }

    return closestElements
}

// Example usage:
let numbers = [1.0, 2.0, 3.0, 4.0, 5.0, 2.2]
let closestElements = findClosestElements(numbers: numbers)
print(closestElements) // Output: (2.0, 2.2)
```
 // XCTAssertTrue failed

func findClosestElements(numbers: [Double]) -> (Double, Double) {
    var minDifference = Double.infinity
    var minDifferencePair: (Double, Double) = (0.0, 0.0)

    for i in 0..<numbers.count {
        for j in i+1..<numbers.count {
            let difference = abs(numbers[i] - numbers[j])
            if difference < minDifference {
                minDifference = difference
                minDifferencePair = (numbers[i], numbers[j])
            }
        }
    }

    return minDifferencePair
}
```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 minDifference = Double.infinity
    var minDifferencePair: (Double, Double) = (0.0, 0.0)

    for i in 0..<numbers.count {
        for j in i+1..<numbers.count {
            let difference = abs(numbers[i] - numbers[j])
            if difference < minDifference {
                minDifference = difference
                minDifferencePair = (numbers[i], numbers[j])
            }
        }
    }

    return minDifferencePair
}

// Example usage
print(findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.2])) // Output: (2.0, 2.2)
print(findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.0])) // Output: (2.0, 2.0)
```
 // XCTAssertTrue failed

func findClosestElements(numbers: [Double]) -> (Double, Double) {
    var minDistance = Double.max
    var minDistanceElements = (Double(0), Double(0))
    for i in 0..<numbers.count {
        for j in i+1..<numbers.count {
            let distance = abs(numbers[i] - numbers[j])
            if distance < minDistance {
                minDistance = distance
                minDistanceElements = (min(numbers[i], numbers[j]), max(numbers[i], numbers[j]))
            }
        }
    }
    return minDistanceElements
}
```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 minDistance = Double.max
    var minDistanceElements = (Double(0), Double(0))
    for i in 0..<numbers.count {
        for j in i+1..<numbers.count {
            let distance = abs(numbers[i] - numbers[j])
            if distance < minDistance {
                minDistance = distance
                minDistanceElements = (min(numbers[i], numbers[j]), max(numbers[i], numbers[j]))
            }
        }
    }
    return minDistanceElements
}

// Test cases
print(findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.2])) // (2.0, 2.2)
print(findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.0])) // (2.0, 2.0)
print(findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 1.5])) // (1.0, 1.5)
print(findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 1.99])) // (1.99, 2.0)
```
var minDistance = Double.max // type 'Double' has no member 'max'

func findClosestElements(numbers: [Double]) -> (Double, Double) {
    var minDifference = Double.max
    var closestElements = (Double(0), Double(0))
    for i in 0..<numbers.count {
        for j in i+1..<numbers.count {
            let difference = abs(numbers[i] - numbers[j])
            if difference < minDifference {
                minDifference = difference
                closestElements = (min(numbers[i], numbers[j]), max(numbers[i], numbers[j]))
            }
        }
    }
    return closestElements
}
```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 minDifference = Double.max
    var closestElements = (Double(0), Double(0))
    for i in 0..<numbers.count {
        for j in i+1..<numbers.count {
            let difference = abs(numbers[i] - numbers[j])
            if difference < minDifference {
                minDifference = difference
                closestElements = (min(numbers[i], numbers[j]), max(numbers[i], numbers[j]))
            }
        }
    }
    return closestElements
}

// Test cases
print(findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.2])) // (2.0, 2.2)
print(findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.0])) // (2.0, 2.0)
print(findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.1])) // (2.0, 2.1)
print(findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.3])) // (2.0, 2.3)
print(findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.4])) // (2.0, 2.4)
print(findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.5])) // (2.0, 2.5)
print(findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.6])) // (2.0, 2.6)
print(findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.7])) // (2.0, 2.7)
print(findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.8])) // (2.0, 2.8)
print(findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 2.9])) // (2.0, 2.9)
print(findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 3.0])) // (2.0, 3.0)
print(findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 3.1])) // (2.0, 3.1)
print(findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 3.2])) // (2.0, 3.2)
print(findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 3.3])) // (2.0, 3.3)
print(findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 3.4])) // (2.0, 3.4)
print(findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 3.5])) // (2.0, 3.5)
print(findClosestElements(numbers: [1.0, 2.0, 3.0, 4.0, 5.0, 3.6])) // (2.0, 3.6)
print
var minDifference = Double.max // type 'Double' has no member 'max'

func findClosestElements(numbers: [Double]) -> (Double, Double) {
    var minDifference = Double.infinity
    var minDifferencePair: (Double, Double) = (0.0, 0.0)

    for i in 0..<numbers.count {
        for j in i + 1..<numbers.count {
            let difference = abs(numbers[i] - numbers[j])
            if difference < minDifference {
                minDifference = difference
                minDifferencePair = (numbers[i], numbers[j])
            }
        }
    }

    return minDifferencePair
}
```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 minDifference = Double.infinity
    var minDifferencePair: (Double, Double) = (0.0, 0.0)

    for i in 0..<numbers.count {
        for j in i + 1..<numbers.count {
            let difference = abs(numbers[i] - numbers[j])
            if difference < minDifference {
                minDifference = difference
                minDifferencePair = (numbers[i], numbers[j])
            }
        }
    }

    return minDifferencePair
}

// Example usage
let numbers = [1.0, 2.0, 3.0, 4.0, 5.0, 2.2]
let closestElements = findClosestElements(numbers: numbers)
print(closestElements) // Output: (2.0, 2.2)
```
 // XCTAssertTrue failed

func rescaleToUnit(numbers: [Double]) -> [Double] {
    let min = numbers.min()!
    let max = numbers.max()!
    return numbers.map { (number: Double) -> Double in
        return (number - min) / (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 { (number: Double) -> Double in
        return (number - min) / (max - min)
    }
}
```

func rescaleToUnit(numbers: [Double]) -> [Double] {
    let min = numbers.min()!
    let max = numbers.max()!
    return numbers.map { $0.map(min, max, 0.0, 1.0) }
}
```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.map(min, max, 0.0, 1.0) }
}

// 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.map(min, max, 0.0, 1.0) }
}

// 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.map(min, max, 0.0, 1.0) }
}

// 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.map(min, max, 0.0, 1.0) }
}

// 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.map(min, max, 0.0, 1.0) }
}

// 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.map(min, max, 0.0, 1.0) }
}

// 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()!
return numbers.map { $0.map(min, max, 0.0, 1.0) } // value of type 'Double' has no member 'map'

func rescaleToUnit(numbers: [Double]) -> [Double] {
    let min = numbers.min() ?? 0.0
    let max = numbers.max() ?? 0.0
    return numbers.map { (number) -> Double in
        return (number - min) / (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() ?? 0.0
    let max = numbers.max() ?? 0.0
    return numbers.map { (number) -> Double in
        return (number - min) / (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() ?? 0.0
    let max = numbers.max() ?? 0.0
    return numbers.map { (number) -> Double in
        return (number - min) / (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() ?? 0.0
    let max = numbers.max() ?? 0.0
    return numbers.map { (number) -> Double in
        return (number - min) / (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() ?? 0.0
    let max = numbers.max() ?? 0.0
    return numbers.map { (number) -> Double in
        return (number - min) / (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() ?? 0.0
    let max = numbers.max() ?? 0.0
    return numbers.map { (number) -> Double in
        return (number - min) / (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() ?? 0.0
    let max = numbers.max() ?? 0.0
    return numbers.map { (number) -> Double in
        return (number - min) / (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 

func rescaleToUnit(numbers: [Double]) -> [Double] {
    let min = numbers.min()!
    let max = numbers.max()!
    return numbers.map { (number: Double) -> Double in
        return (number - min) / (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 { (number: Double) -> Double in
        return (number - min) / (max - min)
    }
}
```

func rescaleToUnit(numbers: [Double]) -> [Double] {
    let min = numbers.min()!
    let max = numbers.max()!
    return numbers.map { (number) -> Double in
        return (number - min) / (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 { (number) -> Double in
        return (number - min) / (max - min)
    }
}
```

func rescaleToUnit(numbers: [Double]) -> [Double] {
    let min = numbers.min()!
    let max = numbers.max()!
    return numbers.map { (number) -> Double in
        return (number - min) / (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 { (number) -> Double in
        return (number - min) / (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 { (number) -> Double in
        return (number - min) / (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 { (number) -> Double in
        return (number - min) / (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 { (number) -> Double in
        return (number - min) / (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 { (number) -> Double in
        return (number - min) / (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 { (number) -> Double in
        return (number - min) / (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:

func rescaleToUnit(numbers: [Double]) -> [Double] {
    let min = numbers.min()!
    let max = numbers.max()!
    return numbers.map { (number) -> Double in
        return (number - min) / (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 { (number) -> Double in
        return (number - min) / (max - min)
    }
}
```

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 / range - 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() ?? 0.0
    let max = numbers.max() ?? 0.0
    let range = max - min
    return numbers.map { $0 / range - min / range }
}

// 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 / range - min / range }
}

// 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 / range - min / range }
}

// 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 / range - min / range }
}

// 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 / range - min / range }
}

// 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 / range - min / range }
}

// 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]) ==

func rescaleToUnit(numbers: [Double]) -> [Double] {
    let min = numbers.min()!
    let max = numbers.max()!
    return numbers.map { (number) -> Double in
        return (number - min) / (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 { (number) -> Double in
        return (number - min) / (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 { (number) -> Double in
        return (number - min) / (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 { (number) -> Double in
        return (number - min) / (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 { (number) -> Double in
        return (number - min) / (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 { (number) -> Double in
        return (number - min) / (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 { (number) -> Double in
        return (number - min) / (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:

func rescaleToUnit(numbers: [Double]) -> [Double] {
    let min = numbers.min()!
    let max = numbers.max()!
    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()!
    let max = numbers.max()!
    let range = max - min
    return numbers.map { $0 - min }.map { $0 / range }
}

// 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 { $0 - min }.map { $0 / range }
}

// 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 { $0 - min }.map { $0 / range }
}

// 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 { $0 - min }.map { $0 / range }
}

// 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 { $0 - min }.map { $0 / range }
}

// 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 { $0 - min }.map { $0 / range }
}

// 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

func filterIntegers(values: [AnyHashable]) -> [Int] {
    return values.filter { $0 is Int }.map { $0 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 { $0 is Int }.map { $0 as! Int }
}
```

func filterIntegers(values: [AnyHashable]) -> [Int] {
    return values.filter { $0 is Int }.compactMap { $0 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 { $0 is Int }.compactMap { $0 as? Int }
}
```

func filterIntegers(values: [AnyHashable]) -> [Int] {
    return values.filter { $0 is Int }.map { $0 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 { $0 is Int }.map { $0 as! Int }
}
```

func filterIntegers(values: [AnyHashable]) -> [Int] {
    return values.filter { $0 is Int }.map { $0 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 { $0 is Int }.map { $0 as! Int }
}
```

func filterIntegers(values: [AnyHashable]) -> [Int] {
    return values.filter { $0 is Int }.map { $0 as! Int }
}

func filterStrings(values: [AnyHashable]) -> [String] {
    return values.filter { $0 is String }.map { $0 as! String }
}

func filterDictionaries(values: [AnyHashable]) -> [[AnyHashable : AnyHashable]] {
    return values.filter { $0 is [AnyHashable : AnyHashable] }.map { $0 as! [AnyHashable : AnyHashable] }
}

func filterLists(values: [AnyHashable]) -> [[AnyHashable]] {
    return values.filter { $0 is [AnyHashable] }.map { $0 as! [AnyHashable] }
}

func filterTuples(values: [AnyHashable]) -> [(AnyHashable, AnyHashable)] {
    return values.filter { $0 is (AnyHashable, AnyHashable) }.map { $0 as! (AnyHashable, AnyHashable) }
}

func filterSets(values: [AnyHashable]) -> [Set<AnyHashable>] {
    return values.filter { $0 is Set<AnyHashable> }.map { $0 as! Set<AnyHashable> }
}

func filterClosures(values: [AnyHashable]) -> [AnyHashable] {
    return values.filter { $0 is @convention(block) (AnyHashable) -> AnyHashable }
}
```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 { $0 is Int }.map { $0 as! Int }
}

// Filter given array of any swiftthon values only for strings
// filterStrings(values: ["a", 3.14, 5]) == ["a"]
// filterStrings(values: [1, 2, 3, "abc", [:] as [AnyHashable : AnyHashable], [] as [AnyHashable]]) == ["abc"]
func filterStrings(values: [AnyHashable]) -> [String] {
    return values.filter { $0 is String }.map { $0 as! String }
}

// Filter given array of any swiftthon values only for dictionaries
// filterDictionaries(values: ["a", 3.14, 5]) == []
// filterDictionaries(values: [1, 2, 3, "abc", [:] as [AnyHashable : AnyHashable], [] as [AnyHashable]]) == [[:] as [AnyHashable : AnyHashable]]
func filterDictionaries(values: [AnyHashable]) -> [[AnyHashable : AnyHashable]] {
    return values.filter { $0 is [AnyHashable : AnyHashable] }.map { $0 as! [AnyHashable : AnyHashable] }
}

// Filter given array of any swiftthon values only for lists
// filterLists(values: ["a", 3.14, 5]) == []
// filterLists(values: [1, 2, 3, "abc", [:] as [AnyHashable : AnyHashable], [] as [AnyHashable]]) == [[] as [AnyHashable]]
func filterLists(values: [AnyHashable]) -> [[AnyHashable]] {
    return values.filter { $0 is [AnyHashable] }.map { $0 as! [AnyHashable] }
}

// Filter given array of any swiftthon values only for tuples
// filterTuples(values: ["a", 3.14, 5]) == []
// filterTuples(values: [1, 2, 3, "abc", (1, 2) as (Int, Int), (1, "a") as (Int, String), ("a", 1) as (String, Int)]) == [(1, 2) as (Int, Int), (1, "a") as (Int, String), ("a", 1) as (String, Int)]
func filterTuples(values: [AnyHashable]) -> [(AnyHashable, AnyHashable)] {
    return values.filter { $0 is (AnyHashable, AnyHashable) }.map { $0 as! (AnyHashable, AnyHashable) }
}

// Filter given array of any swiftthon values only for sets
// filterSets(values: ["a", 3.14, 5]) == []
// filterSets(values: [1, 2, 3, "abc", Set([1, 2]), Set(["a", "b"])]) == [Set([1, 2]), Set(["a", "b"])]
func filterSets(values: [AnyHashable]) -> [Set<AnyHashable>] {
    return values.filter { $0 is Set<AnyHashable> }.map { $0 as! Set<AnyHashable> }
}

// Filter given array of any swiftthon values only for closures
// filterClosures(values: ["a", 3.14, 5]) == []
// filterClosures(values: [1, 2, 3, "abc", { (a: Int) -> Int in return a }, { (a: String) -> String in return a }]) == [{ (a: Int) -> Int in return a }, { (a: String) -> String in return a }]
func filterClosures(values: [AnyHashable]) -> [AnyHashable] {
    return values.filter { $0 is @convention(block) (AnyHashable) -> AnyHashable }
}

// Filter given array of any swiftthon values only for closures that take no arguments
// filterNoArgClosures(values: ["a", 3.14, 

func filterIntegers(values: [AnyHashable]) -> [Int] {
    return values.filter { $0 is Int }.compactMap { $0 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 { $0 is Int }.compactMap { $0 as? Int }
}
```

func filterIntegers(values: [AnyHashable]) -> [Int] {
    return values.filter { $0 is Int }.compactMap { $0 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 { $0 is Int }.compactMap { $0 as? Int }
}
```

func filterIntegers(values: [AnyHashable]) -> [Int] {
    return values.filter { $0 is Int }.compactMap { $0 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 { $0 is Int }.compactMap { $0 as? Int }
}
```

func filterIntegers(values: [AnyHashable]) -> [Int] {
    return values.filter { $0 is Int }.compactMap { $0 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 { $0 is Int }.compactMap { $0 as? Int }
}
```

func filterIntegers(values: [AnyHashable]) -> [Int] {
    return values.filter { $0 is Int }.map { $0 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 { $0 is Int }.map { $0 as! Int }
}
```

func strlen(string: String) -> Int {
    // Your code here
}
```swift
// Return length of given string
// strlen(string: "") == 0
// strlen(string: "abc") == 3
func strlen(string: String) -> Int {
    // Your code here
}
```
} // missing return in global function expected to return 'Int'

func strlen(string: String) -> Int {
    return string.count
}

func isEmpty(string: String) -> Bool {
    return string.isEmpty
}

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

func isPalindrome(string: String) -> Bool {
    var left = 0
    var right = string.count - 1
    while left < right {
        if string[string.index(string.startIndex, offsetBy: left)] != string[string.index(string.startIndex, offsetBy: right)] {
            return false
        }
        left += 1
        right -= 1
    }
    return true
}
```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
// isEmpty(string: "") == true
// isEmpty(string: "abc") == false
func isEmpty(string: String) -> Bool {
    return string.isEmpty
}

// Return true if given string is palindrome
// isPalindrome(string: "") == true
// isPalindrome(string: "a") == true
// isPalindrome(string: "aa") == true
// isPalindrome(string: "aba") == true
// isPalindrome(string: "abc") == false
func isPalindrome(string: String) -> Bool {
    return string == String(string.reversed())
}

// Return true if given string is palindrome
// isPalindrome(string: "") == true
// isPalindrome(string: "a") == true
// isPalindrome(string: "aa") == true
// isPalindrome(string: "aba") == true
// isPalindrome(string: "abc") == false
func isPalindrome(string: String) -> Bool {
    var left = 0
    var right = string.count - 1
    while left < right {
        if string[string.index(string.startIndex, offsetBy: left)] != string[string.index(string.startIndex, offsetBy: right)] {
            return false
        }
        left += 1
        right -= 1
    }
    return true
}

// Return true if given string is palindrome
// isPalindrome(string: "") == true
// isPalindrome(string: "a") == true
// isPalindrome(string: "aa") == true
// isPalindrome(string: "aba") == true
// isPalindrome(string: "abc") == false
func isPalindrome(string: String) -> Bool {
    var left = 0
    var right = string.count - 1
    while left < right {
        if string[string.index(string.startIndex, offsetBy: left)] != string[string.index(string.startIndex, offsetBy: right)] {
            return false
        }
        left += 1
        right -= 1
    }
    return true
}

// Return true if given string is palindrome
// isPalindrome(string: "") == true
// isPalindrome(string: "a") == true
// isPalindrome(string: "aa") == true
// isPalindrome(string: "aba") == true
// isPalindrome(string: "abc") == false
func isPalindrome(string: String) -> Bool {
    var left = 0
    var right = string.count - 1
    while left < right {
        if string[string.index(string.startIndex, offsetBy: left)] != string[string.index(string.startIndex, offsetBy: right)] {
            return false
        }
        left += 1
        right -= 1
    }
    return true
}

// Return true if given string is palindrome
// isPalindrome(string: "") == true
// isPalindrome(string: "a") == true
// isPalindrome(string: "aa") == true
// isPalindrome(string: "aba") == true
// isPalindrome(string: "abc") == false
func isPalindrome(string: String) -> Bool {
    var left = 0
    var right = string.count - 1
    while left < right {
        if string[string.index(string.startIndex, offsetBy: left)] != string[string.index(string.startIndex, offsetBy: right)] {
            return false
        }
        left += 1
        right -= 1
    }
    return true
}

// Return true if given string is palindrome
// isPalindrome(string: "") == true
// isPalindrome(string: "a") == true
// isPalindrome(string: "aa") == true
// isPalindrome(string: "aba") == true
//
func isPalindrome(string: String) -> Bool { // invalid redeclaration of 'isPalindrome(string:)'

func strlen(string: String) -> Int {
    // TODO: implement
}
```swift
// Return length of given string
// strlen(string: "") == 0
// strlen(string: "abc") == 3
func strlen(string: String) -> Int {
    // TODO: implement
}
```
} // missing return in global function expected to return 'Int'

func strlen(string: String) -> Int {
    return string.count
}

func isEmpty(string: String) -> Bool {
    return string.isEmpty
}

func isBlank(string: String) -> Bool {
    return string.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
}

func startsWith(string: String, prefix: String) -> Bool {
    return string.hasPrefix(prefix)
}

func endsWith(string: String, suffix: String) -> Bool {
    return string.hasSuffix(suffix)
}

func contains(string: String, substring: String) -> Bool {
    return string.contains(substring)
}

func isAlpha(string: String) -> Bool {
    return string.rangeOfCharacter(from: CharacterSet.letters) != nil
}

func isAlphanumeric(string: String) -> Bool {
    return string.rangeOfCharacter(from: CharacterSet.alphanumerics) != nil
}

func isDigit(string: String) -> Bool {
    return string.rangeOfCharacter(from: CharacterSet.decimalDigits) != nil
}

func isLowercase(string: String) -> Bool {
    return string.rangeOfCharacter(from: CharacterSet.lowercaseLetters) != nil
}

func isUppercase(string: String) -> Bool {
    return string.rangeOfCharacter(from: CharacterSet.uppercaseLetters) != nil
}

func isWhitespace(string: String) -> Bool {
    return string.rangeOfCharacter(from: CharacterSet.whitespaces) != nil
}
```swift
// Return length of given string
// strlen(string: "") == 0
// strlen(string: "abc") == 3
func strlen(string: String) -> Int {
    return string.count
}

// Return true if string is empty
// isEmpty(string: "") == true
// isEmpty(string: "abc") == false
func isEmpty(string: String) -> Bool {
    return string.isEmpty
}

// Return true if string contains only whitespace characters
// isBlank(string: "") == true
// isBlank(string: " ") == true
// isBlank(string: "a b") == false
func isBlank(string: String) -> Bool {
    return string.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
}

// Return true if string starts with prefix
// startsWith(string: "abc", prefix: "a") == true
// startsWith(string: "abc", prefix: "b") == false
func startsWith(string: String, prefix: String) -> Bool {
    return string.hasPrefix(prefix)
}

// Return true if string ends with suffix
// endsWith(string: "abc", suffix: "c") == true
// endsWith(string: "abc", suffix: "b") == false
func endsWith(string: String, suffix: String) -> Bool {
    return string.hasSuffix(suffix)
}

// Return true if string contains substring
// contains(string: "abc", substring: "bc") == true
// contains(string: "abc", substring: "bcd") == false
func contains(string: String, substring: String) -> Bool {
    return string.contains(substring)
}

// Return true if string contains only alphabetic characters
// isAlpha(string: "abc") == true
// isAlpha(string: "abc1") == false
func isAlpha(string: String) -> Bool {
    return string.rangeOfCharacter(from: CharacterSet.letters) != nil
}

// Return true if string contains only alphanumeric characters
// isAlphanumeric(string: "abc1") == true
// isAlphanumeric(string: "abc$") == false
func isAlphanumeric(string: String) -> Bool {
    return string.rangeOfCharacter(from: CharacterSet.alphanumerics) != nil
}

// Return true if string contains only digits
// isDigit(string: "123") == true
// isDigit(string: "123a") == false
func isDigit(string: String) -> Bool {
    return string.rangeOfCharacter(from: CharacterSet.decimalDigits) != nil
}

// Return true if string contains only lowercase characters
// isLowercase(string: "abc") == true
// isLowercase(string: "Abc") == false
func isLowercase(string: String) -> Bool {
    return string.rangeOfCharacter(from: CharacterSet.lowercaseLetters) != nil
}

// Return true if string contains only uppercase characters
// isUppercase(string: "ABC") == true
// isUppercase(string: "ABc") == false
func isUppercase(string: String) -> Bool {
    return string.rangeOfCharacter(from: CharacterSet.uppercaseLetters) != nil
}

// Return true if string contains only whitespace characters
// isWhitespace(string: " ") == true
// isWhitespace(string: "a ") == false
func isWhitespace(string: String) -> Bool {
    return string.rangeOfCharacter(from: CharacterSet.whitespaces) != nil
}

// Return true if string is a valid email address
// isEmail(string: "[email protected]") == true
// isEmail(string: "abc@example") == false
func isEmail(string: String) -> Bool {
    let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}"
    let emailTest = NSPredicate(format: "SELF MATCHES %@", emailRegEx)
    return emailTest.evaluate(with:

func strlen(string: String) -> Int {
    // Your code here
}
```swift
// Return length of given string
// strlen(string: "") == 0
// strlen(string: "abc") == 3
func strlen(string: String) -> Int {
    // Your code here
}
```
} // missing return in global function expected to return 'Int'

func strlen(string: String) -> Int {
    return string.count
}

func isEmpty(string: String) -> Bool {
    return string.isEmpty
}

func isBlank(string: String) -> Bool {
    return string.isEmpty || string.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
}

func startsWith(string: String, prefix: String) -> Bool {
    return string.hasPrefix(prefix)
}

func endsWith(string: String, suffix: String) -> Bool {
    return string.hasSuffix(suffix)
}

func contains(string: String, substring: String) -> Bool {
    return string.contains(substring)
}

func isAlpha(string: String) -> Bool {
    return string.range(of: "[^a-zA-Z]", options: .regularExpression) == nil
}

func isAlphanumeric(string: String) -> Bool {
    return string.range(of: "[^a-zA-Z0-9]", options: .regularExpression) == nil
}

func isNumeric(string: String) -> Bool {
    return string.range(of: "[^0-9]", options: .regularExpression) == nil
}

func isWhitespace(string: String) -> Bool {
    return string.range(of: "[^\t\n\r ]", options: .regularExpression) == nil
}

func isEmail(string: String) -> Bool {
    let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}"
    let emailTest = NSPredicate(format: "SELF MATCHES %@", emailRegEx)
    return emailTest.evaluate(with: string)
}
```swift
// Return length of given string
// strlen(string: "") == 0
// strlen(string: "abc") == 3
func strlen(string: String) -> Int {
    return string.count
}

// Return true if string is empty, false otherwise
// isEmpty(string: "") == true
// isEmpty(string: "abc") == false
func isEmpty(string: String) -> Bool {
    return string.isEmpty
}

// Return true if string contains only whitespace characters, false otherwise
// isBlank(string: "") == true
// isBlank(string: " ") == true
// isBlank(string: "a b") == false
func isBlank(string: String) -> Bool {
    return string.isEmpty || string.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
}

// Return true if string starts with prefix, false otherwise
// startsWith(string: "abc", prefix: "a") == true
// startsWith(string: "abc", prefix: "b") == false
func startsWith(string: String, prefix: String) -> Bool {
    return string.hasPrefix(prefix)
}

// Return true if string ends with suffix, false otherwise
// endsWith(string: "abc", suffix: "c") == true
// endsWith(string: "abc", suffix: "b") == false
func endsWith(string: String, suffix: String) -> Bool {
    return string.hasSuffix(suffix)
}

// Return true if string contains substring, false otherwise
// contains(string: "abc", substring: "b") == true
// contains(string: "abc", substring: "d") == false
func contains(string: String, substring: String) -> Bool {
    return string.contains(substring)
}

// Return true if string contains only alphabetic characters, false otherwise
// isAlpha(string: "abc") == true
// isAlpha(string: "abc1") == false
func isAlpha(string: String) -> Bool {
    return string.range(of: "[^a-zA-Z]", options: .regularExpression) == nil
}

// Return true if string contains only alphanumeric characters, false otherwise
// isAlphanumeric(string: "abc1") == true
// isAlphanumeric(string: "abc$") == false
func isAlphanumeric(string: String) -> Bool {
    return string.range(of: "[^a-zA-Z0-9]", options: .regularExpression) == nil
}

// Return true if string contains only numeric characters, false otherwise
// isNumeric(string: "123") == true
// isNumeric(string: "123a") == false
func isNumeric(string: String) -> Bool {
    return string.range(of: "[^0-9]", options: .regularExpression) == nil
}

// Return true if string contains only whitespace characters, false otherwise
// isWhitespace(string: " ") == true
// isWhitespace(string: "a ") == false
func isWhitespace(string: String) -> Bool {
    return string.range(of: "[^\t\n\r ]", options: .regularExpression) == nil
}

// Return true if string is a valid email address, false otherwise
// isEmail(string: "[email protected]") == true
// isEmail(string: "a@b") == false
func isEmail(string: String) -> Bool {
    let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}"
    let emailTest = NSPredicate(format: "SELF MATCHES %@", emailRegEx)
    return emailTest.evaluate(with: string)
}

// Return true if string is a valid URL, false otherwise
// isURL(string: "http://www.example.com") == true
// isURL(string: "http://www.example") == false
func isURL(string: String) -> Bool {
    let urlRegEx = "(https?:\\/\\/(?:www\\.|(?!www))[a-zA-Z0-9][a-

func strlen(string: String) -> Int {
    return string.count
}

func isEmpty(string: String) -> Bool {
    return string.isEmpty
}

func startsWith(string: String, prefix: String) -> Bool {
    return string.hasPrefix(prefix)
}

func endsWith(string: String, suffix: String) -> Bool {
    return string.hasSuffix(suffix)
}

func contains(string: String, substring: String) -> Bool {
    return string.contains(substring)
}

func isDigits(string: String) -> Bool {
    return string.rangeOfCharacter(from: CharacterSet.decimalDigits.inverted) == nil
}

func isLetters(string: String) -> Bool {
    return string.rangeOfCharacter(from: CharacterSet.letters.inverted) == nil
}

func isLettersAndDigits(string: String) -> Bool {
    return string.rangeOfCharacter(from: CharacterSet.letters.union(CharacterSet.decimalDigits).inverted) == nil
}

func isLettersDigitsAndSpaces(string: String) -> Bool {
    return string.rangeOfCharacter(from: CharacterSet.letters.union(CharacterSet.decimalDigits).union(CharacterSet.whitespacesAndNewlines).inverted) == nil
}

func isLettersDigitsSpacesAndPunctuation(string: String) -> Bool {
    return string.rangeOfCharacter(from: CharacterSet.letters.union(CharacterSet.decimalDigits).union(CharacterSet.whitespacesAndNewlines).union(CharacterSet.punctuationCharacters).inverted) == nil
}
```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
// isEmpty(string: "") == true
// isEmpty(string: "abc") == false
func isEmpty(string: String) -> Bool {
    return string.isEmpty
}

// Return true if given string starts with given prefix
// startsWith(string: "abc", prefix: "ab") == true
// startsWith(string: "abc", prefix: "bc") == false
func startsWith(string: String, prefix: String) -> Bool {
    return string.hasPrefix(prefix)
}

// Return true if given string ends with given suffix
// endsWith(string: "abc", suffix: "bc") == true
// endsWith(string: "abc", suffix: "ab") == false
func endsWith(string: String, suffix: String) -> Bool {
    return string.hasSuffix(suffix)
}

// Return true if given string contains given substring
// contains(string: "abc", substring: "bc") == true
// contains(string: "abc", substring: "ab") == true
// contains(string: "abc", substring: "ac") == false
func contains(string: String, substring: String) -> Bool {
    return string.contains(substring)
}

// Return true if given string contains only digits
// isDigits(string: "123") == true
// isDigits(string: "12a") == false
func isDigits(string: String) -> Bool {
    return string.rangeOfCharacter(from: CharacterSet.decimalDigits.inverted) == nil
}

// Return true if given string contains only letters
// isLetters(string: "abc") == true
// isLetters(string: "12a") == false
func isLetters(string: String) -> Bool {
    return string.rangeOfCharacter(from: CharacterSet.letters.inverted) == nil
}

// Return true if given string contains only letters and digits
// isLettersAndDigits(string: "12a") == true
// isLettersAndDigits(string: "12a!") == false
func isLettersAndDigits(string: String) -> Bool {
    return string.rangeOfCharacter(from: CharacterSet.letters.union(CharacterSet.decimalDigits).inverted) == nil
}

// Return true if given string contains only letters, digits and spaces
// isLettersDigitsAndSpaces(string: "12a") == true
// isLettersDigitsAndSpaces(string: "12a!") == false
func isLettersDigitsAndSpaces(string: String) -> Bool {
    return string.rangeOfCharacter(from: CharacterSet.letters.union(CharacterSet.decimalDigits).union(CharacterSet.whitespacesAndNewlines).inverted) == nil
}

// Return true if given string contains only letters, digits, spaces and punctuation
// isLettersDigitsSpacesAndPunctuation(string: "12a!") == true
// isLettersDigitsSpacesAndPunctuation(string: "12a!@#$%^&*()") == true
// isLettersDigitsSpacesAndPunctuation(string: "12a!@#$%^&*()[]") == false
func isLettersDigitsSpacesAndPunctuation(string: String) -> Bool {
    return string.rangeOfCharacter(from: CharacterSet.letters.union(CharacterSet.decimalDigits).union(CharacterSet.whitespacesAndNewlines).union(CharacterSet.punctuationCharacters).inverted) == nil
}

// Return true if given string contains only letters, digits, spaces, punctuation and symbols
// isLettersDigitsSpacesPunctuationAndSymbols(string: "12a!@#$%^&*()[]") == true
// isLettersDigitsSpacesPunctuationAndSymbols(string: "12a!@#$%^&*()[]<>?") == true
// isLettersDigitsSpacesPunctuationAndSymbols(string: "12a!@#$%^&*()[]<>?{}") == false

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 isEmpty(string: String) -> Bool {
    return string.isEmpty
}

func contains(string: String, substring: String) -> Bool {
    return string.contains(substring)
}

func startsWith(string: String, substring: String) -> Bool {
    return string.hasPrefix(substring)
}

func endsWith(string: String, substring: String) -> Bool {
    return string.hasSuffix(substring)
}

func substring(string: String, start: Int, end: Int) -> String {
    let startIndex = string.index(string.startIndex, offsetBy: start)
    let endIndex = string.index(string.startIndex, offsetBy: end)
    return String(string[startIndex..<endIndex])
}

func substring(string: String, start: Int, length: Int) -> String {
    let startIndex = string.index(string.startIndex, offsetBy: start)
    let endIndex = string.index(string.startIndex, offsetBy: start + length)
    return String(string[startIndex..<endIndex])
}

func substring(string: String, start: Int) -> String {
    let startIndex = string.index(string.startIndex, offsetBy: start)
    return String(string[startIndex...])
}

func substring(string: String, end: Int) -> String {
    let endIndex = string.index(string.startIndex, offsetBy: end)
    return String(string[..<endIndex])
}
```swift
// Return length of given string
// strlen(string: "") == 0
// strlen(string: "abc") == 3
func strlen(string: String) -> Int {
    return string.count
}

// Return true if string is empty
// isEmpty(string: "") == true
// isEmpty(string: "abc") == false
func isEmpty(string: String) -> Bool {
    return string.isEmpty
}

// Return true if string contains given substring
// contains(string: "abc", substring: "b") == true
// contains(string: "abc", substring: "d") == false
func contains(string: String, substring: String) -> Bool {
    return string.contains(substring)
}

// Return true if string starts with given substring
// startsWith(string: "abc", substring: "a") == true
// startsWith(string: "abc", substring: "d") == false
func startsWith(string: String, substring: String) -> Bool {
    return string.hasPrefix(substring)
}

// Return true if string ends with given substring
// endsWith(string: "abc", substring: "c") == true
// endsWith(string: "abc", substring: "d") == false
func endsWith(string: String, substring: String) -> Bool {
    return string.hasSuffix(substring)
}

// Return substring from given string
// substring(string: "abc", start: 0, end: 2) == "ab"
// substring(string: "abc", start: 1, end: 3) == "bc"
func substring(string: String, start: Int, end: Int) -> String {
    let startIndex = string.index(string.startIndex, offsetBy: start)
    let endIndex = string.index(string.startIndex, offsetBy: end)
    return String(string[startIndex..<endIndex])
}

// Return substring from given string
// substring(string: "abc", start: 0, length: 2) == "ab"
// substring(string: "abc", start: 1, length: 2) == "bc"
func substring(string: String, start: Int, length: Int) -> String {
    let startIndex = string.index(string.startIndex, offsetBy: start)
    let endIndex = string.index(string.startIndex, offsetBy: start + length)
    return String(string[startIndex..<endIndex])
}

// Return substring from given string
// substring(string: "abc", start: 0) == "abc"
// substring(string: "abc", start: 1) == "bc"
func substring(string: String, start: Int) -> String {
    let startIndex = string.index(string.startIndex, offsetBy: start)
    return String(string[startIndex...])
}

// Return substring from given string
// substring(string: "abc", end: 2) == "ab"
// substring(string: "abc", end: 3) == "abc"
func substring(string: String, end: Int) -> String {
    let endIndex = string.index(string.startIndex, offsetBy: end)
    return String(string[..<endIndex])
}

// Return substring from given string
// substring(string: "abc", start: 0, end: 2) == "ab"
// substring(string: "abc", start: 1, end: 3) == "bc"
func substring(string: String, start: Int, end: Int) -> String {
    let startIndex = string.index(string.startIndex, offsetBy: start)
    let endIndex = string.index(string.startIndex, offsetBy: end)
    return String(string[startIndex..<endIndex])
}

// Return substring from given string
// substring(string: "abc", start: 0, length: 2) == "ab"
// substring(string: "abc", start: 1, length: 2) == "bc"
func substring(string: String, start: Int, length: Int) -> String {
    let startIndex = string.index(string.startIndex, offsetBy: start)
    let endIndex = string.index

func strlen(string: String) -> Int {
    return string.count
}

func isEmpty(string: String) -> Bool {
    return string.isEmpty
}

func startsWith(string: String, prefix: String) -> Bool {
    return string.hasPrefix(prefix)
}

func endsWith(string: String, suffix: String) -> Bool {
    return string.hasSuffix(suffix)
}

func contains(string: String, substring: String) -> Bool {
    return string.contains(substring)
}

func contains(string: String, character: Character) -> Bool {
    return string.contains(character)
}

func contains(string: String, characters: String) -> Bool {
    return string.contains(characters)
}

func contains(string: String, characters: Character) -> Bool {
    return string.contains(characters)
}
```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
// isEmpty(string: "") == true
// isEmpty(string: "abc") == false
func isEmpty(string: String) -> Bool {
    return string.isEmpty
}

// Return true if given string starts with given prefix
// startsWith(string: "abc", prefix: "a") == true
// startsWith(string: "abc", prefix: "ab") == true
// startsWith(string: "abc", prefix: "abc") == true
// startsWith(string: "abc", prefix: "b") == false
// startsWith(string: "abc", prefix: "bc") == false
// startsWith(string: "abc", prefix: "c") == false
func startsWith(string: String, prefix: String) -> Bool {
    return string.hasPrefix(prefix)
}

// Return true if given string ends with given suffix
// endsWith(string: "abc", suffix: "c") == true
// endsWith(string: "abc", suffix: "bc") == true
// endsWith(string: "abc", suffix: "abc") == true
// endsWith(string: "abc", suffix: "a") == false
// endsWith(string: "abc", suffix: "ab") == false
// endsWith(string: "abc", suffix: "b") == false
func endsWith(string: String, suffix: String) -> Bool {
    return string.hasSuffix(suffix)
}

// Return true if given string contains given substring
// contains(string: "abc", substring: "a") == true
// contains(string: "abc", substring: "ab") == true
// contains(string: "abc", substring: "abc") == true
// contains(string: "abc", substring: "b") == true
// contains(string: "abc", substring: "bc") == true
// contains(string: "abc", substring: "c") == true
// contains(string: "abc", substring: "d") == false
func contains(string: String, substring: String) -> Bool {
    return string.contains(substring)
}

// Return true if given string contains given character
// contains(string: "abc", character: "a") == true
// contains(string: "abc", character: "b") == true
// contains(string: "abc", character: "c") == true
// contains(string: "abc", character: "d") == false
func contains(string: String, character: Character) -> Bool {
    return string.contains(character)
}

// Return true if given string contains given characters
// contains(string: "abc", characters: "a") == true
// contains(string: "abc", characters: "ab") == true
// contains(string: "abc", characters: "abc") == true
// contains(string: "abc", characters: "b") == true
// contains(string: "abc", characters: "bc") == true
// contains(string: "abc", characters: "c") == true
// contains(string: "abc", characters: "d") == false
func contains(string: String, characters: String) -> Bool {
    return string.contains(characters)
}

// Return true if given string contains given characters
// contains(string: "abc", characters: "a") == true
// contains(string: "abc", characters: "ab") == true
// contains(string: "abc", characters: "abc") == true
// contains(string: "abc", characters: "b") == true
// contains(string: "abc", characters: "bc") == true
// contains(string: "abc", characters: "c") == true
// contains(string: "abc", characters: "d") == false
func contains(string: String, characters: Character) -> Bool {
    return string.contains(characters)
}

// Return true if given string contains given characters
// contains(string: "abc", characters: "a") == true
// contains(string

func largestDivisor(n: Int) -> Int {
    for i in (1..<n).reversed() {
        if n % i == 0 {
            return i
        }
    }
    return 1
}

func smallestMultiple(n: Int) -> Int {
    var result = 1
    for i in 1...n {
        result = lcm(a: result, b: i)
    }
    return result
}

func greatestCommonDivisor(a: Int, b: Int) -> Int {
    var a = a
    var b = b
    while b != 0 {
        let temp = b
        b = a % b
        a = temp
    }
    return a
}

func leastCommonMultiple(a: Int, b: Int) -> Int {
    return (a * b) / greatestCommonDivisor(a: a, b: b)
}

func sumOfEvenNumbers(n: Int) -> Int {
    var result = 0
    for i in 1...n {
        if i % 2 == 0 {
            result += i
        }
    }
    return result
}

func sumOfOddNumbers(n: Int) -> Int {
    var result = 0
    for i in 1...n {
        if i % 2 != 0 {
            result += i
        }
    }
    return result
}

func sumOfNumbers(n: Int) -> Int {
    var result = 0
    for i in 1...n {
        result += i
    }
    return result
}

func sumOfSquares(n: Int) -> Int {
    var result = 0
    for i in 1...n {
        result += i * i
    }
    return result
}

func sumOfCubes(n: Int) -> Int {
    var result = 0
    for i in 1...n {
        result += i * i * i
    }
    return result
}

func sumOfPowersOf2(n: Int) -> Int {
    var result = 0
    for i in 1...n {
        result += Int(pow(2, Double(i)))
    }
    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
}

// For a given number n, find the smallest number that is evenly divisible by all numbers from 1 to n
// smallestMultiple(n: 10) == 2520
func smallestMultiple(n: Int) -> Int {
    var result = 1
    for i in 1...n {
        result = lcm(a: result, b: i)
    }
    return result
}

// For a given pair of numbers a and b, find the largest number that divides both of them
// greatestCommonDivisor(a: 15, b: 10) == 5
func greatestCommonDivisor(a: Int, b: Int) -> Int {
    var a = a
    var b = b
    while b != 0 {
        let temp = b
        b = a % b
        a = temp
    }
    return a
}

// For a given pair of numbers a and b, find the smallest number that is evenly divisible by both of them
// leastCommonMultiple(a: 15, b: 10) == 30
func leastCommonMultiple(a: Int, b: Int) -> Int {
    return (a * b) / greatestCommonDivisor(a: a, b: b)
}

// For a given number n, find the sum of all the even numbers from 1 to n
// sumOfEvenNumbers(n: 10) == 30
func sumOfEvenNumbers(n: Int) -> Int {
    var result = 0
    for i in 1...n {
        if i % 2 == 0 {
            result += i
        }
    }
    return result
}

// For a given number n, find the sum of all the odd numbers from 1 to n
// sumOfOddNumbers(n: 10) == 25
func sumOfOddNumbers(n: Int) -> Int {
    var result = 0
    for i in 1...n {
        if i % 2 != 0 {
            result += i
        }
    }
    return result
}

// For a given number n, find the sum of all the numbers from 1 to n
// sumOfNumbers(n: 10) == 55
func sumOfNumbers(n: Int) -> Int {
    var result = 0
    for i in 1...n {
        result += i
    }
    return result
}

// For a given number n, find the sum of all the squares from 1 to n
// sumOfSquares(n: 10) == 385
func sumOfSquares(n: Int) -> Int {
    var result = 0
    for i in 1...n {
        result += i * i
    }
    return result
}

// For a given number n, find the sum of all the cubes from 1 to n
// sumOfCubes(n: 10) == 3025
func sumOfCubes(n: Int) -> Int {
    var result = 0
    for i in 1...n {
        result += i * i * i
    }
    return result
}

// For a given number n, find the sum of all the powers of 2 from 1 to n
// sumOfPowersOf2(n: 10) == 1023
func sumOfPowersOf2(n: Int) -> Int {
    var result = 0
    for i in 1...n {
        result += Int(pow(2, Double(i)))
    }
    return result
}

// For a given number n, find the sum of all the powers of 3 from 1 to n
// sumOfPowersOf3(n: 10) == 1162261467
func sumOfPowersOf3(n: Int) -> Int {
    var result = 0
    for i in 1...n {
        result += Int(pow(3, Double(i)))
    }
    
result = lcm(a: result, b: i) // cannot find 'lcm' in scope

func largestDivisor(n: Int) -> Int {
    for i in (2...n).reversed() {
        if n % i == 0 {
            return i
        }
    }
    return 1
}

func smallestMultiple(n: Int) -> Int {
    for i in (n+1...) {
        if i % n == 0 {
            return i
        }
    }
    return n
}

func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if !vowels.contains(char) {
            result.append(char)
        }
    }
    return result
}

func convertDigitsToLetters(input: String) -> String {
    var result = ""
    for char in input {
        if let index = digits.firstIndex(of: char) {
            result.append(letters[index])
        }
    }
    return result
}

func replaceVowels(input: String) -> String {
    var result = ""
    for char in input {
        if vowels.contains(char) {
            result.append("x")
        } else {
            result.append(char)
        }
    }
    return result
}

func replaceVowelsExceptFirstAndLast(input: String) -> String {
    var result = ""
    for (index, char) in input.enumerated() {
        if vowels.contains(char) && index != 0 && index != input.count - 1 {
            result.append("x")
        } else {
            result.append(char)
        }
    }
    return result
}

func replaceVowelsExceptFirstAndLastAndSecond(input: String) -> String {
    var result = ""
    for (index, char) in input.enumerated() {
        if vowels.contains(char) && index != 0 && index != input.count - 1 && index != 1 && index != input.count - 2 {
            result.append("x")
        } else {
            result.append(char)
        }
    }
    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 (2...n).reversed() {
        if n % i == 0 {
            return i
        }
    }
    return 1
}

// For a given number n, find the smallest number that divides n evenly, greater than n
// smallestMultiple(n: 15) == 30
func smallestMultiple(n: Int) -> Int {
    for i in (n+1...) {
        if i % n == 0 {
            return i
        }
    }
    return n
}

// Given a string, return the string, but with vowels removed.
// removeVowels("apple") == "ppl"
func removeVowels(input: String) -> String {
    var result = ""
    for char in input {
        if !vowels.contains(char) {
            result.append(char)
        }
    }
    return result
}

// Given a string of digits, return the string with each digit replaced by the
// corresponding letter.
// To give an example, the input "4103" should return "gold".
func convertDigitsToLetters(input: String) -> String {
    var result = ""
    for char in input {
        if let index = digits.firstIndex(of: char) {
            result.append(letters[index])
        }
    }
    return result
}

// Given a string, return the string, but with vowels replaced by "x".
// replaceVowels("apple") == "xxpxx"
func replaceVowels(input: String) -> String {
    var result = ""
    for char in input {
        if vowels.contains(char) {
            result.append("x")
        } else {
            result.append(char)
        }
    }
    return result
}

// Given a string, return the string, but with vowels replaced by "x", except for
// the first and last letter.
// replaceVowelsExceptFirstAndLast("apple") == "axpxx"
func replaceVowelsExceptFirstAndLast(input: String) -> String {
    var result = ""
    for (index, char) in input.enumerated() {
        if vowels.contains(char) && index != 0 && index != input.count - 1 {
            result.append("x")
        } else {
            result.append(char)
        }
    }
    return result
}

// Given a string, return the string, but with vowels replaced by "x", except for
// the first and last letter, and the second and second-to-last letter.
// replaceVowelsExceptFirstAndLastAndSecond("apple") == "axpxx"
func replaceVowelsExceptFirstAndLastAndSecond(input: String) -> String {
    var result = ""
    for (index, char) in input.enumerated() {
        if vowels.contains(char) && index != 0 && index != input.count - 1 && index != 1 && index != input.count - 2 {
            result.append("x")
        } else {
            result.append(char)
        }
    }
    return result
}

// Given a string, return the string, but with vowels replaced by "x", except for
// the first and last letter, and the second and second-to-last letter, and the
// third and third-to-last letter.
// replaceVowelsExceptFirstAndLastAndSecondAndThird("apple") == "axpxx"
func replaceVowelsExceptFirstAndLastAndSecondAndThird(input: String) -> String {
    var result = ""
    for (index, char) in input.enumerated() {
        if vowels.contains(char) && index != 0 && index != input.count - 1 && index != 1 && index != input.count - 2 && index != 2 && index != input.count - 3 {
            result.append("x")
        } else {
            result.append(char)
        }
    
for i in (n+1...) { // cannot convert value of type 'PartialRangeFrom<Int>' to expected argument type 'Int'
for i in (n+1...) { // for-in loop requires 'Int' to conform to 'Sequence'
if !vowels.contains(char) { // cannot find 'vowels' in scope
if let index = digits.firstIndex(of: char) { // cannot find 'digits' in scope
result.append(letters[index]) // cannot find 'letters' in scope
if vowels.contains(char) { // cannot find 'vowels' in scope
if vowels.contains(char) && index != 0 && index != input.count - 1 { // cannot find 'vowels' in scope
if vowels.contains(char) && index != 0 && index != input.count - 1 && index != 1 && index != input.count - 2 { // cannot find 'vowels' in scope

func largestDivisor(n: Int) -> Int {
    var result = 1
    for i in 1...n {
        if n % i == 0 {
            result = i
        }
    }
    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 {
    var result = 1
    for i in 1...n {
        if n % i == 0 {
            result = i
        }
    }
    return result
}

print(largestDivisor(n: 15))
```
 // XCTAssertTrue failed

func largestDivisor(n: Int) -> Int {
    var divisor = n - 1
    while divisor > 0 {
        if n % divisor == 0 {
            return divisor
        }
        divisor -= 1
    }
    return 1
}
```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 {
    var divisor = n - 1
    while divisor > 0 {
        if n % divisor == 0 {
            return divisor
        }
        divisor -= 1
    }
    return 1
}

print(largestDivisor(n: 15))
print(largestDivisor(n: 16))
print(largestDivisor(n: 17))
print(largestDivisor(n: 18))
print(largestDivisor(n: 19))
print(largestDivisor(n: 20))
print(largestDivisor(n: 21))
print(largestDivisor(n: 22))
print(largestDivisor(n: 23))
print(largestDivisor(n: 24))
print(largestDivisor(n: 25))
print(largestDivisor(n: 26))
print(largestDivisor(n: 27))
print(largestDivisor(n: 28))
print(largestDivisor(n: 29))
print(largestDivisor(n: 30))
print(largestDivisor(n: 31))
print(largestDivisor(n: 32))
print(largestDivisor(n: 33))
print(largestDivisor(n: 34))
print(largestDivisor(n: 35))
print(largestDivisor(n: 36))
print(largestDivisor(n: 37))
print(largestDivisor(n: 38))
print(largestDivisor(n: 39))
print(largestDivisor(n: 40))
print(largestDivisor(n: 41))
print(largestDivisor(n: 42))
print(largestDivisor(n: 43))
print(largestDivisor(n: 44))
print(largestDivisor(n: 45))
print(largestDivisor(n: 46))
print(largestDivisor(n: 47))
print(largestDivisor(n: 48))
print(largestDivisor(n: 49))
print(largestDivisor(n: 50))
print(largestDivisor(n: 51))
print(largestDivisor(n: 52))
print(largestDivisor(n: 53))
print(largestDivisor(n: 54))
print(largestDivisor(n: 55))
print(largestDivisor(n: 56))
print(largestDivisor(n: 57))
print(largestDivisor(n: 58))
print(largestDivisor(n: 59))
print(largestDivisor(n: 60))
print(largestDivisor(n: 61))
print(largestDivisor(n: 62))
print(largestDivisor(n: 63))
print(largestDivisor(n: 64))
print(largestDivisor(n: 65))
print(largestDivisor(n: 66))
print(largestDivisor(n: 67))
print(largestDivisor(n: 68))
print(largestDivisor(n: 69))
print(largestDivisor(n: 70))
print(largestDivisor(n: 71))
print(largestDivisor(n: 72))
print(largestDivisor(n: 73))
print(largestDivisor(n: 74))
print(largestDivisor(n: 75))
print(largestDivisor(n: 76))
print(largestDivisor(n: 77))
print(largestDivisor(n: 78))
print(largestDivisor(n: 79))
print(largestDivisor(n: 80))
print(largestDivisor(n: 81))
print(largestDivisor(n: 82))
print(largestDivisor(n: 83))
print(largestDivisor(n: 84))
print(largestDivisor(n: 85))
print(largestDivisor(n: 86))
print(largestDivisor(n: 87))
print(largestDivisor(n: 88))
print(largestDivisor(n: 

func largestDivisor(n: Int) -> Int {
    var largestDivisor = 1
    for i in 2...n {
        if n % i == 0 {
            largestDivisor = i
        }
    }
    return largestDivisor
}

func smallestMultiply(n: Int) -> Int {
    var smallestMultiply = 1
    for i in 1...n {
        if smallestMultiply % i != 0 {
            smallestMultiply *= i
        }
    }
    return smallestMultiply
}

func greatestCommonDivisor(array: [Int]) -> Int {
    var greatestCommonDivisor = 1
    for i in 2...array.min()! {
        if array.allSatisfy({ $0 % i == 0 }) {
            greatestCommonDivisor = i
        }
    }
    return greatestCommonDivisor
}

func leastCommonMultiple(array: [Int]) -> Int {
    var leastCommonMultiple = 1
    for i in 1...array.max()! {
        if array.allSatisfy({ $0 % i == 0 }) {
            leastCommonMultiple *= i
        }
    }
    return leastCommonMultiple
}

func sumArray(array: [Int]) -> Int {
    var sum = 0
    for i in array {
        sum += i
    }
    return sum
}

func productArray(array: [Int]) -> Int {
    var product = 1
    for i in array {
        product *= i
    }
    return product
}

func meanArray(array: [Int]) -> Int {
    var mean = 0
    for i in array {
        mean += i
    }
    return mean / array.count
}

func medianArray(array: [Int]) -> Int {
    var median = 0
    for i in array {
        median += i
    }
    return median / array.count
}

func modeArray(array: [Int]) -> Int {
    var mode = 0
    for i in array {
        if array.filter({ $0 == i }).count > mode {
            mode = i
        }
    }
    return mode
}

func rangeArray(array: [Int]) -> Int {
    var range = 0
    for i in array {
        if i > range {
            range = i
        }
    }
    return range - array.min()!
}
```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 {
    var largestDivisor = 1
    for i in 2...n {
        if n % i == 0 {
            largestDivisor = i
        }
    }
    return largestDivisor
}

// For a given number n, find the smallest number that is evenly divisible by all numbers in the range 1 to n
// smallestMultiply(n: 5) == 60
func smallestMultiply(n: Int) -> Int {
    var smallestMultiply = 1
    for i in 1...n {
        if smallestMultiply % i != 0 {
            smallestMultiply *= i
        }
    }
    return smallestMultiply
}

// Given an array of numbers, find the greatest common divisor among the array elements.
// greatestCommonDivisor(array: [2, 4, 6]) == 2
func greatestCommonDivisor(array: [Int]) -> Int {
    var greatestCommonDivisor = 1
    for i in 2...array.min()! {
        if array.allSatisfy({ $0 % i == 0 }) {
            greatestCommonDivisor = i
        }
    }
    return greatestCommonDivisor
}

// Given an array of numbers, find the least common multiple of all numbers in the array.
// leastCommonMultiple(array: [2, 4, 6]) == 12
func leastCommonMultiple(array: [Int]) -> Int {
    var leastCommonMultiple = 1
    for i in 1...array.max()! {
        if array.allSatisfy({ $0 % i == 0 }) {
            leastCommonMultiple *= i
        }
    }
    return leastCommonMultiple
}

// Given an array of numbers, find the sum of all the numbers in the array.
// sumArray(array: [1, 2, 3]) == 6
func sumArray(array: [Int]) -> Int {
    var sum = 0
    for i in array {
        sum += i
    }
    return sum
}

// Given an array of numbers, find the product of all the numbers in the array.
// productArray(array: [1, 2, 3]) == 6
func productArray(array: [Int]) -> Int {
    var product = 1
    for i in array {
        product *= i
    }
    return product
}

// Given an array of numbers, find the mean of all the numbers in the array.
// meanArray(array: [1, 2, 3]) == 2
func meanArray(array: [Int]) -> Int {
    var mean = 0
    for i in array {
        mean += i
    }
    return mean / array.count
}

// Given an array of numbers, find the median of all the numbers in the array.
// medianArray(array: [1, 2, 3]) == 2
func medianArray(array: [Int]) -> Int {
    var median = 0
    for i in array {
        median += i
    }
    return median / array.count
}

// Given an array of numbers, find the mode of all the numbers in the array.
// modeArray(array: [1, 2, 3]) == 1
func modeArray(array: [Int]) -> Int {
    var mode = 0
    for i in array {
        if array.filter({ $0 == i }).count > mode {
            mode = i
        }
    }
    return mode
}

// Given an array of numbers, find the range of all the numbers in the array.
// rangeArray(array: [1, 2, 3]) == 2
func rangeArray(array: [Int]) -> Int {
    var range = 0
    for i in array {
        if i > range {
            range = i
        }
    }
    return range - array.min()!
}

// Given an array of numbers, find the variance of all the numbers in the array.
// varianceArray(array: [1, 2, 3]) == 2
func varianceArray(array: [Int]) -> Int {
    var variance = 0
    for i in array {
        variance += pow(i - meanArray(array: array
 // XCTAssertTrue failed

func largestDivisor(n: Int) -> Int {
    for i in (1...n).reversed() {
        if n % i == 0 {
            return i
        }
    }
    return 1
}
```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
}

print(largestDivisor(n: 15))
```
 // XCTAssertTrue failed

func largestDivisor(n: Int) -> Int {
    var largest = 0
    for i in 1...n {
        if n % i == 0 {
            largest = i
        }
    }
    return largest
}
```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 {
    var largest = 0
    for i in 1...n {
        if n % i == 0 {
            largest = i
        }
    }
    return largest
}

print(largestDivisor(n: 15))
print(largestDivisor(n: 16))
print(largestDivisor(n: 17))
print(largestDivisor(n: 18))
print(largestDivisor(n: 19))
print(largestDivisor(n: 20))
print(largestDivisor(n: 21))
print(largestDivisor(n: 22))
print(largestDivisor(n: 23))
print(largestDivisor(n: 24))
print(largestDivisor(n: 25))
print(largestDivisor(n: 26))
print(largestDivisor(n: 27))
print(largestDivisor(n: 28))
print(largestDivisor(n: 29))
print(largestDivisor(n: 30))
print(largestDivisor(n: 31))
print(largestDivisor(n: 32))
print(largestDivisor(n: 33))
print(largestDivisor(n: 34))
print(largestDivisor(n: 35))
print(largestDivisor(n: 36))
print(largestDivisor(n: 37))
print(largestDivisor(n: 38))
print(largestDivisor(n: 39))
print(largestDivisor(n: 40))
print(largestDivisor(n: 41))
print(largestDivisor(n: 42))
print(largestDivisor(n: 43))
print(largestDivisor(n: 44))
print(largestDivisor(n: 45))
print(largestDivisor(n: 46))
print(largestDivisor(n: 47))
print(largestDivisor(n: 48))
print(largestDivisor(n: 49))
print(largestDivisor(n: 50))
print(largestDivisor(n: 51))
print(largestDivisor(n: 52))
print(largestDivisor(n: 53))
print(largestDivisor(n: 54))
print(largestDivisor(n: 55))
print(largestDivisor(n: 56))
print(largestDivisor(n: 57))
print(largestDivisor(n: 58))
print(largestDivisor(n: 59))
print(largestDivisor(n: 60))
print(largestDivisor(n: 61))
print(largestDivisor(n: 62))
print(largestDivisor(n: 63))
print(largestDivisor(n: 64))
print(largestDivisor(n: 65))
print(largestDivisor(n: 66))
print(largestDivisor(n: 67))
print(largestDivisor(n: 68))
print(largestDivisor(n: 69))
print(largestDivisor(n: 70))
print(largestDivisor(n: 71))
print(largestDivisor(n: 72))
print(largestDivisor(n: 73))
print(largestDivisor(n: 74))
print(largestDivisor(n: 75))
print(largestDivisor(n: 76))
print(largestDivisor(n: 77))
print(largestDivisor(n: 78))
print(largestDivisor(n: 79))
print(largestDivisor(n: 80))
print(largestDivisor(n: 81))
print(largestDivisor(n: 82))
print(largestDivisor(n: 83))
print(largestDivisor(n: 84))
print(largestDivisor(n: 85))
print(largestDivisor(n: 86))
print(largestDivisor(n: 87))
print(largestDivisor(n: 88))
print(largestDivisor(n: 89))
print
 // XCTAssertTrue failed

func largestDivisor(n: Int) -> Int {
    var i = n - 1
    while i > 0 {
        if n % i == 0 {
            return i
        }
        i -= 1
    }
    return 1
}
```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 {
    var i = n - 1
    while i > 0 {
        if n % i == 0 {
            return i
        }
        i -= 1
    }
    return 1
}

print(largestDivisor(n: 15))
print(largestDivisor(n: 16))
print(largestDivisor(n: 17))
print(largestDivisor(n: 18))
print(largestDivisor(n: 19))
print(largestDivisor(n: 20))
print(largestDivisor(n: 21))
print(largestDivisor(n: 22))
print(largestDivisor(n: 23))
print(largestDivisor(n: 24))
print(largestDivisor(n: 25))
print(largestDivisor(n: 26))
print(largestDivisor(n: 27))
print(largestDivisor(n: 28))
print(largestDivisor(n: 29))
print(largestDivisor(n: 30))
print(largestDivisor(n: 31))
print(largestDivisor(n: 32))
print(largestDivisor(n: 33))
print(largestDivisor(n: 34))
print(largestDivisor(n: 35))
print(largestDivisor(n: 36))
print(largestDivisor(n: 37))
print(largestDivisor(n: 38))
print(largestDivisor(n: 39))
print(largestDivisor(n: 40))
print(largestDivisor(n: 41))
print(largestDivisor(n: 42))
print(largestDivisor(n: 43))
print(largestDivisor(n: 44))
print(largestDivisor(n: 45))
print(largestDivisor(n: 46))
print(largestDivisor(n: 47))
print(largestDivisor(n: 48))
print(largestDivisor(n: 49))
print(largestDivisor(n: 50))
print(largestDivisor(n: 51))
print(largestDivisor(n: 52))
print(largestDivisor(n: 53))
print(largestDivisor(n: 54))
print(largestDivisor(n: 55))
print(largestDivisor(n: 56))
print(largestDivisor(n: 57))
print(largestDivisor(n: 58))
print(largestDivisor(n: 59))
print(largestDivisor(n: 60))
print(largestDivisor(n: 61))
print(largestDivisor(n: 62))
print(largestDivisor(n: 63))
print(largestDivisor(n: 64))
print(largestDivisor(n: 65))
print(largestDivisor(n: 66))
print(largestDivisor(n: 67))
print(largestDivisor(n: 68))
print(largestDivisor(n: 69))
print(largestDivisor(n: 70))
print(largestDivisor(n: 71))
print(largestDivisor(n: 72))
print(largestDivisor(n: 73))
print(largestDivisor(n: 74))
print(largestDivisor(n: 75))
print(largestDivisor(n: 76))
print(largestDivisor(n: 77))
print(largestDivisor(n: 78))
print(largestDivisor(n: 79))
print(largestDivisor(n: 80))
print(largestDivisor(n: 81))
print(largestDivisor(n: 82))
print(largestDivisor(n: 83))
print(largestDivisor(n: 84))
print(largestDivisor(n: 85))
print(largestDivisor(n: 86))
print(largestDivisor(n: 87))
print(largestDivisor(n: 88))
print(largestDivisor(n: 8

func largestDivisor(n: Int) -> Int {
    for i in (1..<n).reversed() {
        if n % i == 0 {
            return i
        }
    }
    return 1
}

func smallestMultiple(n: Int) -> Int {
    var result = 1
    for i in 1...n {
        result = lcm(a: result, b: i)
    }
    return result
}

func gcd(a: Int, b: Int) -> Int {
    var a = a
    var b = b
    while b != 0 {
        let temp = b
        b = a % b
        a = temp
    }
    return a
}

func lcm(a: Int, b: Int) -> Int {
    return a * b / gcd(a: a, b: b)
}
```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
}

// For a given number n, find the smallest number that is evenly divisible by all numbers from 1 to n
// smallestMultiple(n: 10) == 2520
func smallestMultiple(n: Int) -> Int {
    var result = 1
    for i in 1...n {
        result = lcm(a: result, b: i)
    }
    return result
}

// For a given pair of numbers a and b, find the largest number that divides both of them
// gcd(a: 15, b: 20) == 5
func gcd(a: Int, b: Int) -> Int {
    var a = a
    var b = b
    while b != 0 {
        let temp = b
        b = a % b
        a = temp
    }
    return a
}

// For a given pair of numbers a and b, find the smallest number that is evenly divisible by both of them
// lcm(a: 15, b: 20) == 60
func lcm(a: Int, b: Int) -> Int {
    return a * b / gcd(a: a, b: b)
}

// For a given pair of numbers a and b, find the smallest number that is evenly divisible by both of them
// lcm(a: 15, b: 20) == 60
func lcm(a: Int, b: Int) -> Int {
    return a * b / gcd(a: a, b: b)
}

// For a given pair of numbers a and b, find the smallest number that is evenly divisible by both of them
// lcm(a: 15, b: 20) == 60
func lcm(a: Int, b: Int) -> Int {
    return a * b / gcd(a: a, b: b)
}

// For a given pair of numbers a and b, find the smallest number that is evenly divisible by both of them
// lcm(a: 15, b: 20) == 60
func lcm(a: Int, b: Int) -> Int {
    return a * b / gcd(a: a, b: b)
}

// For a given pair of numbers a and b, find the smallest number that is evenly divisible by both of them
// lcm(a: 15, b: 20) == 60
func lcm(a: Int, b: Int) -> Int {
    return a * b / gcd(a: a, b: b)
}

// For a given pair of numbers a and b, find the smallest number that is evenly divisible by both of them
// lcm(a: 15, b: 20) == 60
func lcm(a: Int, b: Int) -> Int {
    return a * b / gcd(a: a, b: b)
}

// For a given pair of numbers a and b, find the smallest number that is evenly divisible by both of them
// lcm(a: 15, b: 20) == 60
func lcm(a: Int, b: Int) -> Int {
    return a * b / gcd(a: a, b: b)
}

// For a given pair of numbers a and b, find the smallest number that is evenly divisible by both of them
// lcm(a: 15, b: 20) == 60
func lcm(a: Int, b: Int) -> Int {
    return a * b / gcd(a: a, b: b)
}

// For a given pair of numbers a and b, find the smallest number that is evenly divisible by both of them
// lcm(a: 15, b: 20) == 60
func lcm(a: Int, b: Int) -> Int {
    return a * b / gcd(a: a, b: b)
}

// For a given pair of numbers a and b, find the smallest number that is evenly divisible by both of them
//

func largestDivisor(n: Int) -> Int {
    var largest = 1
    for i in 2...n {
        if n % i == 0 {
            largest = i
        }
    }
    return largest
}
```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 {
    var largest = 1
    for i in 2...n {
        if n % i == 0 {
            largest = i
        }
    }
    return largest
}

print(largestDivisor(n: 15))
print(largestDivisor(n: 16))
print(largestDivisor(n: 17))
print(largestDivisor(n: 18))
print(largestDivisor(n: 19))
print(largestDivisor(n: 20))
print(largestDivisor(n: 21))
print(largestDivisor(n: 22))
print(largestDivisor(n: 23))
print(largestDivisor(n: 24))
print(largestDivisor(n: 25))
print(largestDivisor(n: 26))
print(largestDivisor(n: 27))
print(largestDivisor(n: 28))
print(largestDivisor(n: 29))
print(largestDivisor(n: 30))
print(largestDivisor(n: 31))
print(largestDivisor(n: 32))
print(largestDivisor(n: 33))
print(largestDivisor(n: 34))
print(largestDivisor(n: 35))
print(largestDivisor(n: 36))
print(largestDivisor(n: 37))
print(largestDivisor(n: 38))
print(largestDivisor(n: 39))
print(largestDivisor(n: 40))
print(largestDivisor(n: 41))
print(largestDivisor(n: 42))
print(largestDivisor(n: 43))
print(largestDivisor(n: 44))
print(largestDivisor(n: 45))
print(largestDivisor(n: 46))
print(largestDivisor(n: 47))
print(largestDivisor(n: 48))
print(largestDivisor(n: 49))
print(largestDivisor(n: 50))
print(largestDivisor(n: 51))
print(largestDivisor(n: 52))
print(largestDivisor(n: 53))
print(largestDivisor(n: 54))
print(largestDivisor(n: 55))
print(largestDivisor(n: 56))
print(largestDivisor(n: 57))
print(largestDivisor(n: 58))
print(largestDivisor(n: 59))
print(largestDivisor(n: 60))
print(largestDivisor(n: 61))
print(largestDivisor(n: 62))
print(largestDivisor(n: 63))
print(largestDivisor(n: 64))
print(largestDivisor(n: 65))
print(largestDivisor(n: 66))
print(largestDivisor(n: 67))
print(largestDivisor(n: 68))
print(largestDivisor(n: 69))
print(largestDivisor(n: 70))
print(largestDivisor(n: 71))
print(largestDivisor(n: 72))
print(largestDivisor(n: 73))
print(largestDivisor(n: 74))
print(largestDivisor(n: 75))
print(largestDivisor(n: 76))
print(largestDivisor(n: 77))
print(largestDivisor(n: 78))
print(largestDivisor(n: 79))
print(largestDivisor(n: 80))
print(largestDivisor(n: 81))
print(largestDivisor(n: 82))
print(largestDivisor(n: 83))
print(largestDivisor(n: 84))
print(largestDivisor(n: 85))
print(largestDivisor(n: 86))
print(largestDivisor(n: 87))
print(largestDivisor(n: 88))
print(largestDivisor(n: 89))
print
 // XCTAssertTrue failed

func factorize(n: Int) -> [Int] {
    var factors = [Int]()
    var number = n
    var divisor = 2
    while number > 1 {
        if number % divisor == 0 {
            factors.append(divisor)
            number /= divisor
        } else {
            divisor += 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 number = n
    var divisor = 2
    while number > 1 {
        if number % divisor == 0 {
            factors.append(divisor)
            number /= divisor
        } else {
            divisor += 1
        }
    }
    return factors
}
```

func factorize(n: Int) -> [Int] {
    var factors: [Int] = []
    var number = n
    var divisor = 2
    while number > 1 {
        if number % divisor == 0 {
            factors.append(divisor)
            number /= divisor
        } else {
            divisor += 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 number = n
    var divisor = 2
    while number > 1 {
        if number % divisor == 0 {
            factors.append(divisor)
            number /= divisor
        } else {
            divisor += 1
        }
    }
    return factors
}

print(factorize(n: 8))
print(factorize(n: 25))
print(factorize(n: 70))
```

func factorize(n: Int) -> [Int] {
    var factors = [Int]()
    var number = n
    var divisor = 2

    while number > 1 {
        if number % divisor == 0 {
            factors.append(divisor)
            number /= divisor
        } else {
            divisor += 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 number = n
    var divisor = 2

    while number > 1 {
        if number % divisor == 0 {
            factors.append(divisor)
            number /= divisor
        } else {
            divisor += 1
        }
    }

    return factors
}

print(factorize(n: 8))
print(factorize(n: 25))
print(factorize(n: 70))
```

func factorize(n: Int) -> [Int] {
    var factors = [Int]()
    var number = n
    var divisor = 2

    while number > 1 {
        if number % divisor == 0 {
            number /= divisor
            factors.append(divisor)
        } else {
            divisor += 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 number = n
    var divisor = 2

    while number > 1 {
        if number % divisor == 0 {
            number /= divisor
            factors.append(divisor)
        } else {
            divisor += 1
        }
    }

    return factors
}
```

func factorize(n: Int) -> [Int] {
    var factors = [Int]()
    var number = n
    var divisor = 2
    while number > 1 {
        if number % divisor == 0 {
            number /= divisor
            factors.append(divisor)
        } else {
            divisor += 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 number = n
    var divisor = 2
    while number > 1 {
        if number % divisor == 0 {
            number /= divisor
            factors.append(divisor)
        } else {
            divisor += 1
        }
    }
    return factors
}
```

func factorize(n: Int) -> [Int] {
    var factors: [Int] = []
    var number = n
    var divisor = 2

    while number > 1 {
        if number % divisor == 0 {
            factors.append(divisor)
            number /= divisor
        } else {
            divisor += 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 number = n
    var divisor = 2

    while number > 1 {
        if number % divisor == 0 {
            factors.append(divisor)
            number /= divisor
        } else {
            divisor += 1
        }
    }

    return factors
}

print(factorize(n: 8))
print(factorize(n: 25))
print(factorize(n: 70))
```

func factorize(n: Int) -> [Int] {
    var factors = [Int]()
    var number = n
    var divisor = 2
    while number > 1 {
        if number % divisor == 0 {
            number /= divisor
            factors.append(divisor)
        } else {
            divisor += 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 number = n
    var divisor = 2
    while number > 1 {
        if number % divisor == 0 {
            number /= divisor
            factors.append(divisor)
        } else {
            divisor += 1
        }
    }
    return factors
}
```

func factorize(n: Int) -> [Int] {
    var factors = [Int]()
    var number = n
    var divisor = 2
    while number > 1 {
        if number % divisor == 0 {
            factors.append(divisor)
            number /= divisor
        } else {
            divisor += 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 number = n
    var divisor = 2
    while number > 1 {
        if number % divisor == 0 {
            factors.append(divisor)
            number /= divisor
        } else {
            divisor += 1
        }
    }
    return factors
}
```

func factorize(n: Int) -> [Int] {
    var factors = [Int]()
    var number = n
    var divisor = 2
    while number > 1 {
        if number % divisor == 0 {
            factors.append(divisor)
            number /= divisor
        } else {
            divisor += 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 number = n
    var divisor = 2
    while number > 1 {
        if number % divisor == 0 {
            factors.append(divisor)
            number /= divisor
        } else {
            divisor += 1
        }
    }
    return factors
}

print(factorize(n: 8))
print(factorize(n: 25))
print(factorize(n: 70))
```

func factorize(n: Int) -> [Int] {
    var factors = [Int]()
    var number = n
    var divisor = 2
    while number > 1 {
        if number % divisor == 0 {
            factors.append(divisor)
            number /= divisor
        } else {
            divisor += 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 number = n
    var divisor = 2
    while number > 1 {
        if number % divisor == 0 {
            factors.append(divisor)
            number /= divisor
        } else {
            divisor += 1
        }
    }
    return factors
}

print(factorize(n: 8))
print(factorize(n: 25))
print(factorize(n: 70))
```

func removeDuplicates(numbers: [Int]) -> [Int] {
    var result = numbers
    for i in 0..<result.count {
        for j in i+1..<result.count {
            if result[i] == result[j] {
                result.remove(at: j)
            }
        }
    }
    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 = numbers
    for i in 0..<result.count {
        for j in i+1..<result.count {
            if result[i] == result[j] {
                result.remove(at: j)
            }
        }
    }
    return result
}

print(removeDuplicates(numbers: [1, 2, 3, 2, 4]))
```
 // Fatal error: Index out of range

func removeDuplicates(numbers: [Int]) -> [Int] {
    var result = numbers
    for i in 0..<result.count {
        for j in i+1..<result.count {
            if result[i] == result[j] {
                result.remove(at: j)
            }
        }
    }
    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 = numbers
    for i in 0..<result.count {
        for j in i+1..<result.count {
            if result[i] == result[j] {
                result.remove(at: j)
            }
        }
    }
    return result
}

print(removeDuplicates(numbers: [1, 2, 3, 2, 4]))
```
 // Fatal error: Index out of range

func removeDuplicates(numbers: [Int]) -> [Int] {
    // ...
}
```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] {
    // ...
}
```
} // missing return in global function expected to return '[Int]'

func removeDuplicates(numbers: [Int]) -> [Int] {
    var result = numbers
    var seen = Set<Int>()
    for (index, number) in result.enumerated() {
        if seen.contains(number) {
            result.remove(at: index)
        } else {
            seen.insert(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 = numbers
    var seen = Set<Int>()
    for (index, number) in result.enumerated() {
        if seen.contains(number) {
            result.remove(at: index)
        } else {
            seen.insert(number)
        }
    }
    return result
}

// 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 = numbers
    var seen = Set<Int>()
    for (index, number) in result.enumerated() {
        if seen.contains(number) {
            result.remove(at: index)
        } else {
            seen.insert(number)
        }
    }
    return result
}

// 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 = numbers
    var seen = Set<Int>()
    for (index, number) in result.enumerated() {
        if seen.contains(number) {
            result.remove(at: index)
        } else {
            seen.insert(number)
        }
    }
    return result
}

// 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 = numbers
    var seen = Set<Int>()
    for (index, number) in result.enumerated() {
        if seen.contains(number) {
            result.remove(at: index)
        } else {
            seen.insert(number)
        }
    }
    return result
}

// 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 = numbers
    var seen = Set<Int>()
    for (index, number) in result.enumerated() {
        if seen.contains(number) {
            result.remove(at: index)
        } else {
            seen.insert(number)
        }
    }
    return result
}

// 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 = numbers
    var seen = Set<Int>()
    for (index, number) in result.enumerated() {
        if seen.contains(number) {
            result.remove(at: index)
        } else {
            seen.insert(number)
        }
    }
    return result
}

// 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 = numbers
    var seen = Set<Int>()
    for (index, number) in result.enumerated() {
        if seen.contains(number) {
            result.remove(at: index)
        } else {
            seen.insert(number)
        }
    }
 // XCTAssertTrue failed

func removeDuplicates(numbers: [Int]) -> [Int] {
    var result = numbers
    var set = Set<Int>()
    for (index, number) in result.enumerated() {
        if set.contains(number) {
            result.remove(at: index)
        } else {
            set.insert(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 = numbers
    var set = Set<Int>()
    for (index, number) in result.enumerated() {
        if set.contains(number) {
            result.remove(at: index)
        } else {
            set.insert(number)
        }
    }
    return result
}

print(removeDuplicates(numbers: [1, 2, 3, 2, 4]))
```
 // XCTAssertTrue failed

func removeDuplicates(numbers: [Int]) -> [Int] {
    var result: [Int] = []
    var seen: Set<Int> = []
    for number in numbers {
        if seen.contains(number) {
            continue
        }
        result.append(number)
        seen.insert(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: Set<Int> = []
    for number in numbers {
        if seen.contains(number) {
            continue
        }
        result.append(number)
        seen.insert(number)
    }
    return result
}
```
 // XCTAssertTrue failed

func removeDuplicates(numbers: [Int]) -> [Int] {
    var result: [Int] = []
    var seen: Set<Int> = []
    for number in numbers {
        if seen.contains(number) {
            continue
        }
        seen.insert(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] = []
    var seen: Set<Int> = []
    for number in numbers {
        if seen.contains(number) {
            continue
        }
        seen.insert(number)
        result.append(number)
    }
    return result
}
```
 // XCTAssertTrue failed

func removeDuplicates(numbers: [Int]) -> [Int] {
    var result = numbers
    for i in 0..<result.count {
        for j in i+1..<result.count {
            if result[i] == result[j] {
                result.remove(at: j)
            }
        }
    }
    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 = numbers
    for i in 0..<result.count {
        for j in i+1..<result.count {
            if result[i] == result[j] {
                result.remove(at: j)
            }
        }
    }
    return result
}

print(removeDuplicates(numbers: [1, 2, 3, 2, 4]))
```
 // Fatal error: Index out of range

func removeDuplicates(numbers: [Int]) -> [Int] {
    var result = numbers
    var duplicates = Set<Int>()

    for (index, number) in result.enumerated() {
        if duplicates.contains(number) {
            result.remove(at: index)
        } else {
            duplicates.insert(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 = numbers
    var duplicates = Set<Int>()

    for (index, number) in result.enumerated() {
        if duplicates.contains(number) {
            result.remove(at: index)
        } else {
            duplicates.insert(number)
        }
    }

    return result
}
```
 // XCTAssertTrue failed

func removeDuplicates(numbers: [Int]) -> [Int] {
    var result = numbers
    var uniqueNumbers = Set<Int>()
    for (index, number) in result.enumerated() {
        if uniqueNumbers.contains(number) {
            result.remove(at: index)
        } else {
            uniqueNumbers.insert(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 = numbers
    var uniqueNumbers = Set<Int>()
    for (index, number) in result.enumerated() {
        if uniqueNumbers.contains(number) {
            result.remove(at: index)
        } else {
            uniqueNumbers.insert(number)
        }
    }
    return result
}
```
 // XCTAssertTrue failed

func flipCase(string: String) -> String {
    // ...
}
```swift
// For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
// flipCase(string: "Hello") == "hELLO"
func flipCase(string: String) -> String {
    // ...
}
```
} // missing return in global function expected to return 'String'

func flipCase(string: String) -> String {
    // ...
}
```swift
// For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
// flipCase(string: "Hello") == "hELLO"
func flipCase(string: String) -> String {
    // ...
}
```
} // missing return in global function expected to return 'String'

func flipCase(string: String) -> String {
    var result = ""
    for char in string {
        if char.isLowercase {
            result.append(char.uppercaseString)
        } else {
            result.append(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 {
    var result = ""
    for char in string {
        if char.isLowercase {
            result.append(char.uppercaseString)
        } else {
            result.append(char.lowercaseString)
        }
    }
    return result
}

print(flipCase(string: "Hello"))
```
result.append(char.uppercaseString) // value of type 'Character' has no member 'uppercaseString'
result.append(char.lowercaseString) // value of type 'Character' has no member 'lowercaseString'

func flipCase(string: String) -> String {
    var result = ""
    for char in string {
        if char.isUppercase {
            result += char.lowercased()
        } else {
            result += char.uppercased()
        }
    }
    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.isUppercase {
            result += char.lowercased()
        } else {
            result += char.uppercased()
        }
    }
    return result
}

print(flipCase(string: "Hello")) // hELLO
print(flipCase(string: "hELLO")) // Hello
print(flipCase(string: "Hello, World!")) // hELLO, wORLD!
print(flipCase(string: "")) // ""
```

func flipCase(string: String) -> String {
    var result = ""
    for char in string {
        if char.isUppercase {
            result += char.lowercased()
        } else {
            result += char.uppercased()
        }
    }
    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.isUppercase {
            result += char.lowercased()
        } else {
            result += char.uppercased()
        }
    }
    return result
}

print(flipCase(string: "Hello"))
```

func flipCase(string: String) -> String {
    var result = ""
    for char in string {
        if char.isUppercase {
            result += char.lowercased()
        } else {
            result += char.uppercased()
        }
    }
    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.isUppercase {
            result += char.lowercased()
        } else {
            result += char.uppercased()
        }
    }
    return result
}

print(flipCase(string: "Hello")) // hELLO
```

func flipCase(string: String) -> String {
    return ""
}
```swift
// For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
// flipCase(string: "Hello") == "hELLO"
func flipCase(string: String) -> String {
    return ""
}
```
 // XCTAssertTrue failed

func flipCase(string: String) -> String {
    var result = ""
    for char in string {
        if char.isUppercase {
            result += char.lowercased()
        } else {
            result += char.uppercased()
        }
    }
    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.isUppercase {
            result += char.lowercased()
        } else {
            result += char.uppercased()
        }
    }
    return result
}

print(flipCase(string: "Hello"))
```

func flipCase(string: String) -> String {
    return ""
}

func countVowels(string: String) -> Int {
    return 0
}

func countConsonants(string: String) -> Int {
    return 0
}

func countWords(string: String) -> Int {
    return 0
}

func countSentences(string: String) -> Int {
    return 0
}

func countUniqueWords(string: String) -> Int {
    return 0
}

func mostCommonWord(string: String) -> String {
    return ""
}

func mostCommonLetter(string: String) -> String {
    return ""
}

func mostCommonVowel(string: String) -> String {
    return ""
}

func mostCommonConsonant(string: String) -> String {
    return ""
}

func mostCommonSentence(string: String) -> String {
    return ""
}
```swift
// For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
// flipCase(string: "Hello") == "hELLO"
func flipCase(string: String) -> String {
    return ""
}

// For a given string, return the number of vowels.
// countVowels(string: "Hello") == 2
func countVowels(string: String) -> Int {
    return 0
}

// For a given string, return the number of consonants.
// countConsonants(string: "Hello") == 3
func countConsonants(string: String) -> Int {
    return 0
}

// For a given string, return the number of words.
// countWords(string: "Hello world") == 2
func countWords(string: String) -> Int {
    return 0
}

// For a given string, return the number of sentences.
// countSentences(string: "Hello world. How are you?") == 2
func countSentences(string: String) -> Int {
    return 0
}

// For a given string, return the number of unique words.
// countUniqueWords(string: "Hello world. Hello world") == 2
func countUniqueWords(string: String) -> Int {
    return 0
}

// For a given string, return the most common word.
// mostCommonWord(string: "Hello world. Hello world") == "hello"
func mostCommonWord(string: String) -> String {
    return ""
}

// For a given string, return the most common letter.
// mostCommonLetter(string: "Hello world") == "l"
func mostCommonLetter(string: String) -> String {
    return ""
}

// For a given string, return the most common vowel.
// mostCommonVowel(string: "Hello world") == "o"
func mostCommonVowel(string: String) -> String {
    return ""
}

// For a given string, return the most common consonant.
// mostCommonConsonant(string: "Hello world") == "l"
func mostCommonConsonant(string: String) -> String {
    return ""
}

// For a given string, return the most common sentence.
// mostCommonSentence(string: "Hello world. Hello world") == "Hello world."
func mostCommonSentence(string: String) -> String {
    return ""
}

// For a given string, return the most common word.
// mostCommonWord(string: "Hello world. Hello world") == "hello"
func mostCommonWord(string: String) -> String {
    return ""
}

// For a given string, return the most common letter.
// mostCommonLetter(string: "Hello world") == "l"
func mostCommonLetter(string: String) -> String {
    return ""
}

// For a given string, return the most common vowel.
// mostCommonVowel(string: "Hello world") == "o"
func mostCommonVowel(string: String) -> String {
    return ""
}

// For a given string, return the most common consonant.
// mostCommonConsonant(string: "Hello world") == "l"
func mostCommonConsonant(string: String) -> String {
    return ""
}

// For a given string, return the most common sentence.
// mostCommonSentence(string: "Hello world. Hello world") == "Hello world."
func mostCommonSentence(string: String) -> String {
    return ""
}

// For a given string, return the most common word.
// mostCommonWord(string: "Hello world. Hello world") == "hello"
func mostCommonWord(string: String) -> String {
    return ""
}

// For a given string, return the most common letter.
// mostCommonLetter(string: "Hello world") == "l"
func mostCommonLetter(string: String) -> String {
    return ""
}

// For a given string, return the most common vowel.
// mostCommonVowel(string: "Hello world") == "o"
func mostCommonVowel(string: String) -> String {
    return ""
}

// For a given string, return the most common consonant.
// mostCommonConsonant(string: "Hello world") == "l"
 // XCTAssertTrue failed

func flipCase(string: String) -> String {
    var result = ""
    for char in string {
        if char.isUppercase {
            result += char.lowercased()
        } else {
            result += char.uppercased()
        }
    }
    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.isUppercase {
            result += char.lowercased()
        } else {
            result += char.uppercased()
        }
    }
    return result
}

print(flipCase(string: "Hello"))
```

func concatenate(strings: [String]) -> String {
    return strings.reduce("", combine: +)
}

func concatenate(strings: [String], separator: String) -> String {
    return strings.reduce("") { (result, next) -> String in
        return result + (result == "" ? "" : separator) + next
    }
}
```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.reduce("", combine: +)
}

// Concatenate array of strings into a single string,
// separated by a given separator
// concatenate(strings: [] as [String], separator: ", ") == ""
// concatenate(strings: ["a", "b", "c"], separator: ", ") == "a, b, c"
func concatenate(strings: [String], separator: String) -> String {
    return strings.reduce("") { (result, next) -> String in
        return result + (result == "" ? "" : separator) + next
    }
}
```
return strings.reduce("", combine: +) // extraneous argument label 'combine:' in call

func concatenate(strings: [String]) -> String {
    var result = ""
    for string in strings {
        result += string
    }
    return result
}
```swift
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    var result = ""
    for string in strings {
        result += string
    }
    return result
}
```

func concatenate(strings: [String]) -> String {
    return strings.reduce("", +)
}

func concatenate(strings: [String], delimiter: String) -> String {
    return strings.reduce("", { $0 + delimiter + $1 })
}
```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.reduce("", +)
}

// Concatenate array of strings into a single string, separated by a delimiter
// concatenate(strings: [] as [String], delimiter: ", ") == ""
// concatenate(strings: ["a", "b", "c"], delimiter: ", ") == "a, b, c"
func concatenate(strings: [String], delimiter: String) -> String {
    return strings.reduce("", { $0 + delimiter + $1 })
}
```

func concatenate(strings: [String]) -> String {
    var result = ""
    for string in strings {
        result += string
    }
    return result
}
```swift
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    var result = ""
    for string in strings {
        result += string
    }
    return result
}
```

func concatenate(strings: [String]) -> String {
    var result = ""
    for string in strings {
        result += string
    }
    return result
}
```swift
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    var result = ""
    for string in strings {
        result += string
    }
    return result
}
```

func concatenate(strings: [String]) -> String {
    return strings.reduce("", { $0 + $1 })
}
```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.reduce("", { $0 + $1 })
}
```

func concatenate(strings: [String]) -> String {
    var result = ""
    for string in strings {
        result += string
    }
    return result
}
```swift
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    var result = ""
    for string in strings {
        result += string
    }
    return result
}
```

func concatenate(strings: [String]) -> String {
    var result = ""
    for string in strings {
        result += string
    }
    return result
}

func concatenate(strings: [String], separator: String) -> String {
    var result = ""
    for string in strings {
        result += string
        if string != strings.last {
            result += separator
        }
    }
    return result
}

func concatenate(strings: [String], separator: String, prefix: String, suffix: String) -> String {
    var result = prefix
    for string in strings {
        result += string
        if string != strings.last {
            result += separator
        }
    }
    result += suffix
    return result
}

func concatenate(strings: [String], separator: String, prefix: String, suffix: String, maxCount: Int) -> String {
    var result = prefix
    for (index, string) in strings.enumerated() {
        result += string
        if index < strings.count - 1 {
            result += separator
        }
        if index == maxCount - 1 {
            result += ",...(\(strings.count - maxCount) more)"
            break
        }
    }
    result += suffix
    return result
}
```swift
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    var result = ""
    for string in strings {
        result += string
    }
    return result
}

// Concatenate array of strings into a single string, separated by a separator
// concatenate(strings: [] as [String], separator: ",") == ""
// concatenate(strings: ["a", "b", "c"], separator: ",") == "a,b,c"
func concatenate(strings: [String], separator: String) -> String {
    var result = ""
    for string in strings {
        result += string
        if string != strings.last {
            result += separator
        }
    }
    return result
}

// Concatenate array of strings into a single string, separated by a separator, with a prefix and suffix
// concatenate(strings: [] as [String], separator: ",", prefix: "[", suffix: "]") == "[]"
// concatenate(strings: ["a", "b", "c"], separator: ",", prefix: "[", suffix: "]") == "[a,b,c]"
func concatenate(strings: [String], separator: String, prefix: String, suffix: String) -> String {
    var result = prefix
    for string in strings {
        result += string
        if string != strings.last {
            result += separator
        }
    }
    result += suffix
    return result
}

// Concatenate array of strings into a single string, separated by a separator, with a prefix and suffix, and with a maximum number of strings
// concatenate(strings: [] as [String], separator: ",", prefix: "[", suffix: "]", maxCount: 3) == "[]"
// concatenate(strings: ["a", "b", "c"], separator: ",", prefix: "[", suffix: "]", maxCount: 3) == "[a,b,c]"
// concatenate(strings: ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"], separator: ",", prefix: "[", suffix: "]", maxCount: 3) == "[a,b,c,...(7 more)]"
func concatenate(strings: [String], separator: String, prefix: String, suffix: String, maxCount: Int) -> String {
    var result = prefix
    for (index, string) in strings.enumerated() {
        result += string
        if index < strings.count - 1 {
            result += separator
        }
        if index == maxCount - 1 {
            result += ",...(\(strings.count - maxCount) more)"
            break
        }
    }
    result += suffix
    return result
}

// Concatenate array of strings into a single string, separated by a separator, with a prefix and suffix, and with a maximum number of strings, and with a maximum number of characters
// concatenate(strings: [] as [String], separator: ",", prefix: "[", suffix: "]", maxCount: 3, maxCharacters: 10) == "[]"
// concatenate(strings: ["a", "b", "c"], separator: ",", prefix: "[", suffix: "]", maxCount: 3, maxCharacters: 10) == "[a,b,c]"
// concatenate(strings: ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"], separator: ",", prefix: "[", suffix: "]", maxCount: 3, maxCharacters: 10) == "[a,b,c,...(7 more)]"
// concatenate(strings: ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"], separator: ",", prefix: "["

func concatenate(strings: [String]) -> String {
    var result = ""
    for string in strings {
        result += string
    }
    return result
}
```swift
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    var result = ""
    for string in strings {
        result += string
    }
    return result
}
```

func concatenate(strings: [String]) -> String {
    var result = ""
    for string in strings {
        result += string
    }
    return result
}
```swift
// Concatenate array of strings into a single string
// concatenate(strings: [] as [String]) == ""
// concatenate(strings: ["a", "b", "c"]) == "abc"
func concatenate(strings: [String]) -> String {
    var result = ""
    for string in strings {
        result += string
    }
    return result
}
```

func filterByPrefix(strings: [String], prefix: String) -> [String] {
    // TODO: Implement
    return []
}
```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] {
    // TODO: Implement
    return []
}
```
 // XCTAssertTrue failed

func filterByPrefix(strings: [String], prefix: String) -> [String] {
    // TODO: Implement
    return []
}
```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] {
    // TODO: Implement
    return []
}
```
 // XCTAssertTrue failed

func filterByPrefix(strings: [String], prefix: String) -> [String] {
    // TODO: Implement this function
}
```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] {
    // TODO: Implement this function
}
```
} // missing return in global function expected to return '[String]'

func filterByPrefix(strings: [String], prefix: String) -> [String] {
    // TODO: Implement this function
    return []
}
```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] {
    // TODO: Implement this function
    return []
}
```
 // XCTAssertTrue failed

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) }
}
```

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) }
}
```

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) }
}
```

func filterByPrefix(strings: [String], prefix: String) -> [String] {
    return strings.filter { $0.hasPrefix(prefix) }
}

func filterBySuffix(strings: [String], suffix: String) -> [String] {
    return strings.filter { $0.hasSuffix(suffix) }
}

func filterBySubstring(strings: [String], substring: String) -> [String] {
    return strings.filter { $0.contains(substring) }
}
```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) }
}

// Filter an input array of strings only for ones that end with a given suffix.
// filterBySuffix(strings: [] as [String], suffix: "a") == [] as [String]
// filterBySuffix(strings: ["abc", "bcd", "cde", "array"], suffix: "a") == ["cde", "array"]
func filterBySuffix(strings: [String], suffix: String) -> [String] {
    return strings.filter { $0.hasSuffix(suffix) }
}

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

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

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

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

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

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

// Filter an input array of strings only for ones that contain a given substring.
// filterBySubstring(strings: [] as [String], substring: "a") == [] as [String]
// filterBySubstring(strings: ["abc", "bcd", "cde"

func filterByPrefix(strings: [String], prefix: String) -> [String] {
    var result: [String] = []
    for string in strings {
        if string.hasPrefix(prefix) {
            result.append(string)
        }
    }
    return result
}
```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] {
    var result: [String] = []
    for string in strings {
        if string.hasPrefix(prefix) {
            result.append(string)
        }
    }
    return result
}
```

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) }
}
```

func getPositive(l: [Int]) -> [Int] {
    // write your code here
}
```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] {
    // write your code here
}
```
} // missing return in global function expected to return '[Int]'

func getPositive(l: [Int]) -> [Int] {
    return l.filter { $0 > 0 }
}

func getNegative(l: [Int]) -> [Int] {
    return l.filter { $0 < 0 }
}

func getEven(l: [Int]) -> [Int] {
    return l.filter { $0 % 2 == 0 }
}

func getOdd(l: [Int]) -> [Int] {
    return l.filter { $0 % 2 != 0 }
}

func getPrime(l: [Int]) -> [Int] {
    return l.filter { isPrime($0) }
}

func getNonPrime(l: [Int]) -> [Int] {
    return l.filter { !isPrime($0) }
}

func getDivisibleBy3(l: [Int]) -> [Int] {
    return l.filter { $0 % 3 == 0 }
}

func getNonDivisibleBy3(l: [Int]) -> [Int] {
    return l.filter { $0 % 3 != 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 }
}

// Return only negative numbers in the array.
// getNegative(l: [-1, 2, -4, 5, 6]) == [-1, -4]
// getNegative(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == [-5, -3, -10]
func getNegative(l: [Int]) -> [Int] {
    return l.filter { $0 < 0 }
}

// Return only even numbers in the array.
// getEven(l: [-1, 2, -4, 5, 6]) == [2, -4, 6]
// getEven(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == [2, 0, -10]
func getEven(l: [Int]) -> [Int] {
    return l.filter { $0 % 2 == 0 }
}

// Return only odd numbers in the array.
// getOdd(l: [-1, 2, -4, 5, 6]) == [-1, 5]
// getOdd(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == [5, 3, -5, -3, 3, 9, 123, 1]
func getOdd(l: [Int]) -> [Int] {
    return l.filter { $0 % 2 != 0 }
}

// Return only prime numbers in the array.
// getPrime(l: [-1, 2, -4, 5, 6]) == [2, 5]
// getPrime(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == [5, 3, 2, 3]
func getPrime(l: [Int]) -> [Int] {
    return l.filter { isPrime($0) }
}

// Return only non-prime numbers in the array.
// getNonPrime(l: [-1, 2, -4, 5, 6]) == [-1, -4, 6]
// getNonPrime(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == [-5, 9, 0, 123, 1, -10]
func getNonPrime(l: [Int]) -> [Int] {
    return l.filter { !isPrime($0) }
}

// Return only numbers divisible by 3 in the array.
// getDivisibleBy3(l: [-1, 2, -4, 5, 6]) == [6]
// getDivisibleBy3(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == [3, -3, 3, 9, 0, 123]
func getDivisibleBy3(l: [Int]) -> [Int] {
    return l.filter { $0 % 3 == 0 }
}

// Return only numbers not divisible by 3 in the array.
// getNonDivisibleBy3(l: [-1, 2, -4, 5, 6]) == [-1, 2, -4, 5]
// getNonDivisibleBy3(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == [5, -5, 2, -3, 9, 1, -10]
func getNonDivisibleBy3(l: [Int]) -> [Int] {
    return l.filter { $0 % 3 != 0 }
}

// Return only numbers divisible by 5 in the array
return l.filter { isPrime($0) } // cannot find 'isPrime' in scope
return l.filter { !isPrime($0) } // cannot find 'isPrime' in scope

func getPositive(l: [Int]) -> [Int] {
    return []
}
```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 []
}
```
 // XCTAssertTrue failed

func getPositive(l: [Int]) -> [Int] {
    // Write your code here
}
```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] {
    // Write your code here
}
```
} // missing return in global function expected to return '[Int]'

func getPositive(l: [Int]) -> [Int] {
    return []
}
```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 []
}
```
 // XCTAssertTrue failed

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 }
}

print(getPositive(l: [-1, 2, -4, 5, 6]))
print(getPositive(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]))
```

func getPositive(l: [Int]) -> [Int] {
    return []
}
```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 []
}
```
 // XCTAssertTrue failed

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 []
}
```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 []
}
```
 // XCTAssertTrue failed

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 isPrime(n: Int) -> Bool {
    // your code here
}
```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 {
    // your code here
}
```
} // missing return in global function expected to return 'Bool'

func isPrime(n: Int) -> Bool {
    // write your code here
}
```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 {
    // write your code here
}
```
} // missing return in global function expected to return 'Bool'

func isPrime(n: Int) -> Bool {
    // your code here
}
```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 {
    // your code here
}
```
} // missing return in global function expected to return 'Bool'

func isPrime(n: Int) -> Bool {
    // your code here
}
```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 {
    // your code here
}
```
} // missing return in global function expected to return 'Bool'

func isPrime(n: Int) -> Bool {
    // write your code in Swift
    var isPrime = true
    for i in 2...n/2 {
        if n % i == 0 {
            isPrime = false
            break
        }
    }
    return isPrime
}
```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 {
    // write your code in Swift
    var isPrime = true
    for i in 2...n/2 {
        if n % i == 0 {
            isPrime = false
            break
        }
    }
    return isPrime
}

print(isPrime(n: 6))
print(isPrime(n: 101))
print(isPrime(n: 11))
print(isPrime(n: 13441))
print(isPrime(n: 61))
print(isPrime(n: 4))
print(isPrime(n: 1))
```
 // Fatal error: Range requires lowerBound <= upperBound

func isPrime(n: Int) -> Bool {
    // your code here
}
```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 {
    // your code here
}
```
} // missing return in global function expected to return 'Bool'

func isPrime(n: Int) -> Bool {
    return false
}
```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 {
    return false
}
```
 // XCTAssertTrue failed

func isPrime(n: Int) -> Bool {
    // write your code in Swift
    var isPrime = true
    for i in 2...n-1 {
        if n % i == 0 {
            isPrime = false
            break
        }
    }
    return isPrime
}
```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 {
    // write your code in Swift
    var isPrime = true
    for i in 2...n-1 {
        if n % i == 0 {
            isPrime = false
            break
        }
    }
    return isPrime
}

print(isPrime(n: 6))
print(isPrime(n: 101))
print(isPrime(n: 11))
print(isPrime(n: 13441))
print(isPrime(n: 61))
print(isPrime(n: 4))
print(isPrime(n: 1))

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // Fatal error: Range requires lowerBound <= upperBound

func isPrime(n: Int) -> Bool {
    if n <= 1 {
        return false
    }
    for i in 2...Int(sqrt(Double(n))) {
        if n % i == 0 {
            return false
        }
    }
    return true
}

func gcd(a: Int, b: Int) -> Int {
    if b == 0 {
        return a
    }
    return gcd(a: b, b: a % b)
}

func lcm(a: Int, b: Int) -> Int {
    if a == 0 || b == 0 {
        return 0
    }
    return (a * b) / gcd(a: a, b: b)
}

func numDigits(n: Int) -> Int {
    if n == 0 {
        return 1
    }
    var count = 0
    var temp = n
    while temp > 0 {
        temp /= 10
        count += 1
    }
    return count
}

func sumDigits(n: Int) -> Int {
    var sum = 0
    var temp = n
    while temp > 0 {
        sum += temp % 10
        temp /= 10
    }
    return sum
}

func productDigits(n: Int) -> Int {
    var product = 1
    var temp = n
    while temp > 0 {
        product *= temp % 10
        temp /= 10
    }
    return product
}
```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...Int(sqrt(Double(n))) {
        if n % i == 0 {
            return false
        }
    }
    return true
}

// Return the greatest common divisor of two given numbers.
// gcd(a: 6, b: 15) == 3
// gcd(a: 101, b: 101) == 101
// gcd(a: 101, b: 0) == 101
// gcd(a: 0, b: 101) == 101
// gcd(a: 101, b: 1) == 1
// gcd(a: 1, b: 101) == 1
// gcd(a: 0, b: 0) == 0
func gcd(a: Int, b: Int) -> Int {
    if b == 0 {
        return a
    }
    return gcd(a: b, b: a % b)
}

// Return the least common multiple of two given numbers.
// lcm(a: 6, b: 15) == 30
// lcm(a: 101, b: 101) == 101
// lcm(a: 101, b: 0) == 0
// lcm(a: 0, b: 101) == 0
// lcm(a: 101, b: 1) == 101
// lcm(a: 1, b: 101) == 101
// lcm(a: 0, b: 0) == 0
func lcm(a: Int, b: Int) -> Int {
    if a == 0 || b == 0 {
        return 0
    }
    return (a * b) / gcd(a: a, b: b)
}

// Return the number of digits in a given number.
// numDigits(n: 6) == 1
// numDigits(n: 101) == 3
// numDigits(n: 13441) == 5
// numDigits(n: 61) == 2
// numDigits(n: 4) == 1
// numDigits(n: 0) == 1
func numDigits(n: Int) -> Int {
    if n == 0 {
        return 1
    }
    var count = 0
    var temp = n
    while temp > 0 {
        temp /= 10
        count += 1
    }
    return count
}

// Return the sum of the digits in a given number.
// sumDigits(n: 6) == 6
// sumDigits(n: 101) == 2
// sumDigits(n: 13441) == 12
// sumDigits(n: 61) == 7
// sumDigits(n: 4) == 4
// sumDigits(n: 0) == 0
func sumDigits(n: Int) -> Int {
    var sum = 0
    var temp = n
    while temp > 0 {
        sum += temp % 10
        temp /= 10
    }
    return sum
}

// Return the product of the digits in a given number.
// productDigits(n: 6) == 6
// productDigits(n: 101) == 1
// productDigits(n: 13441) == 48
// productDigits(n: 61) == 6
// productDigits(n: 4) == 4
// productDigits(n: 0) == 0
func productDigits(n: Int) -> Int {
    var product = 1
    var temp = n
    while temp > 0 {
        product *= temp % 10
        temp /= 10
    }
    return product
}

// Return the number of digits in a given number that are even.
// numEvenDigits(n: 6) ==

func isPrime(n: Int) -> Bool {
    // write your code in Swift
    var isPrime = true
    for i in 2...n/2 {
        if n % i == 0 {
            isPrime = false
            break
        }
    }
    return isPrime
}
```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 {
    // write your code in Swift
    var isPrime = true
    for i in 2...n/2 {
        if n % i == 0 {
            isPrime = false
            break
        }
    }
    return isPrime
}

print(isPrime(n: 6))
print(isPrime(n: 101))
print(isPrime(n: 11))
print(isPrime(n: 13441))
print(isPrime(n: 61))
print(isPrime(n: 4))
print(isPrime(n: 1))

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // Fatal error: Range requires lowerBound <= upperBound

func sortThird(l: [Int]) -> [Int] {
    var l = l
    for (index, element) in l.enumerated() {
        if (index + 1) % 3 == 0 {
            l[index] = element
        }
    }
    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 (index, element) in l.enumerated() {
        if (index + 1) % 3 == 0 {
            l[index] = element
        }
    }
    return l
}
```
 // XCTAssertTrue failed

func sortThird(l: [Int]) -> [Int] {
    var sorted = l
    for i in 0...l.count {
        if i % 3 == 0 {
            sorted[i] = l[i].sorted()
        }
    }
    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 = l
    for i in 0...l.count {
        if i % 3 == 0 {
            sorted[i] = l[i].sorted()
        }
    }
    return sorted
}
```
sorted[i] = l[i].sorted() // value of type 'Int' has no member 'sorted'

func sortThird(l: [Int]) -> [Int] {
    var result = l
    for (index, value) in result.enumerated() {
        if index % 3 == 0 {
            result[index] = value
        } else {
            result[index] = value
        }
    }
    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 = l
    for (index, value) in result.enumerated() {
        if index % 3 == 0 {
            result[index] = value
        } else {
            result[index] = value
        }
    }
    return result
}

print(sortThird(l: [1, 2, 3]))
print(sortThird(l: [5, 6, 3, 4, 8, 9, 2]))

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

func sortThird(l: [Int]) -> [Int] {
    var result = l
    var sorted = l.filter { $0 % 3 == 0 }.sorted()
    for i in 0..<l.count {
        if i % 3 == 0 {
            result[i] = sorted[i / 3]
        }
    }
    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 = l
    var sorted = l.filter { $0 % 3 == 0 }.sorted()
    for i in 0..<l.count {
        if i % 3 == 0 {
            result[i] = sorted[i / 3]
        }
    }
    return result
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
var sorted = l.filter { $0 % 3 == 0 }.sorted() // variable 'sorted' was never mutated; consider changing to 'let' constant
 // XCTAssertTrue failed

func sortThird(l: [Int]) -> [Int] {
    var sorted = l
    for i in 0...l.count {
        if i % 3 == 0 {
            sorted[i] = l[i].sorted()
        }
    }
    return sorted
}

func sumFirstTwo(l: [Int]) -> Int {
    if l.count == 0 {
        return 0
    } else if l.count == 1 {
        return l[0]
    } else {
        return l[0] + l[1]
    }
}

func sumFirstTwo(l: [Int]) -> Int {
    if l.count == 0 {
        return 0
    } else if l.count == 1 {
        return l[0]
    } else if l.count == 2 {
        return l[0] + l[1]
    } else {
        return l[0] + l[1]
    }
}
```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 = l
    for i in 0...l.count {
        if i % 3 == 0 {
            sorted[i] = l[i].sorted()
        }
    }
    return sorted
}

// 1.1.2
// Given a list of integers, return the sum of the first two elements in the list.
// If the list is empty, return 0. If the list has only one element, return that element.
// sumFirstTwo(l: [1, 2, 3]) == 3
// sumFirstTwo(l: [5, 6, 3, 4, 8, 9, 2]) == 11
// sumFirstTwo(l: []) == 0
// sumFirstTwo(l: [5]) == 5
func sumFirstTwo(l: [Int]) -> Int {
    if l.count == 0 {
        return 0
    } else if l.count == 1 {
        return l[0]
    } else {
        return l[0] + l[1]
    }
}

// 1.1.3
// Given a list of integers, return the sum of the first two elements in the list.
// If the list is empty, return 0. If the list has only one element, return that element.
// If the list has only two elements, return the sum of the two elements.
// If the list has more than two elements, return the sum of the first two elements.
// sumFirstTwo(l: [1, 2, 3]) == 3
// sumFirstTwo(l: [5, 6, 3, 4, 8, 9, 2]) == 11
// sumFirstTwo(l: []) == 0
// sumFirstTwo(l: [5]) == 5
// sumFirstTwo(l: [5, 6]) == 11
// sumFirstTwo(l: [5, 6, 3, 4, 8, 9, 2]) == 11
func sumFirstTwo(l: [Int]) -> Int {
    if l.count == 0 {
        return 0
    } else if l.count == 1 {
        return l[0]
    } else if l.count == 2 {
        return l[0] + l[1]
    } else {
        return l[0] + l[1]
    }
}

// 1.1.4
// Given a list of integers, return the sum of the first two elements in the list.
// If the list is empty, return 0. If the list has only one element, return that element.
// If the list has only two elements, return the sum of the two elements.
// If the list has more than two elements, return the sum of the first two elements.
// If the list has more than two elements, return the sum of the first two elements.
// If the list has more than two elements, return the sum of the first two elements.
// If the list has more than two elements, return the sum of the first two elements.
// If the list has more than two elements, return the sum of the first two elements.
// If the list has more than two elements, return the sum of the first two elements.
// If the list has more than two elements, return the sum of the first two elements.
// If the list has more than two elements, return the sum of the first two elements.
// If the list has more than two elements, return the sum of the first two elements.
// If the list has more than two elements, return the sum of the first two elements.
// If the list has more than two elements, return the sum of the first two elements.
// If the list has more than two elements, return the sum of the first two elements.
// If the list has more than two elements, return the sum of the first two elements.
// If the list has more than two elements, return the sum of the first two elements.
// If the list has more than two elements, return the sum of the first two elements.
// If the list has more than two elements, return the sum of the first two elements.
// If the list has more than two elements, return the sum of the first two elements.
// If the list has more than two elements, return the sum of the first two elements.
// If the list has more than two elements, return the sum of
sorted[i] = l[i].sorted() // value of type 'Int' has no member 'sorted'
func sumFirstTwo(l: [Int]) -> Int { // invalid redeclaration of 'sumFirstTwo(l:)'

func sortThird(l: [Int]) -> [Int] {
    var result = l
    for i in 0...l.count - 1 {
        if i % 3 == 0 {
            result[i] = l[i]
        } else {
            result[i] = 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 = l
    for i in 0...l.count - 1 {
        if i % 3 == 0 {
            result[i] = l[i]
        } else {
            result[i] = l[i]
        }
    }
    return result
}

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

func sortThird(l: [Int]) -> [Int] {
    var sorted = l
    for i in 0..<l.count {
        if i % 3 == 0 {
            sorted[i] = l[i]
        }
    }
    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 = l
    for i in 0..<l.count {
        if i % 3 == 0 {
            sorted[i] = l[i]
        }
    }
    return sorted
}
```
 // XCTAssertTrue failed

func sortThird(l: [Int]) -> [Int] {
    var result = l
    for i in 0..<l.count {
        if i % 3 == 0 {
            result[i] = l[i]
        } else {
            result[i] = 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 = l
    for i in 0..<l.count {
        if i % 3 == 0 {
            result[i] = l[i]
        } else {
            result[i] = l[i]
        }
    }
    return result
}

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

func sortThird(l: [Int]) -> [Int] {
    var result = l
    for (index, element) in result.enumerated() {
        if (index + 1) % 3 == 0 {
            result[index] = l[index]
        }
    }
    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 = l
    for (index, element) in result.enumerated() {
        if (index + 1) % 3 == 0 {
            result[index] = l[index]
        }
    }
    return result
}
```
for (index, element) in result.enumerated() { // immutable value 'element' was never used; consider replacing with '_' or removing it
 // XCTAssertTrue failed

func sortThird(l: [Int]) -> [Int] {
    var result = l
    for i in 0...l.count - 1 {
        if i % 3 == 0 {
            result[i] = l[i]
        } else {
            result[i] = 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 = l
    for i in 0...l.count - 1 {
        if i % 3 == 0 {
            result[i] = l[i]
        } else {
            result[i] = l[i]
        }
    }
    return result
}

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

func unique(l: [Int]) -> [Int] {
    return l.sorted().reduce([Int](), { (acc, curr) in
        if acc.isEmpty || acc.last! != curr {
            acc.append(curr)
        }
        return acc
    })
}
```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().reduce([Int](), { (acc, curr) in
        if acc.isEmpty || acc.last! != curr {
            acc.append(curr)
        }
        return acc
    })
}

// 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().reduce([Int](), { (acc, curr) in
        if acc.isEmpty || acc.last! != curr {
            acc.append(curr)
        }
        return acc
    })
}

// 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().reduce([Int](), { (acc, curr) in
        if acc.isEmpty || acc.last! != curr {
            acc.append(curr)
        }
        return acc
    })
}

// 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().reduce([Int](), { (acc, curr) in
        if acc.isEmpty || acc.last! != curr {
            acc.append(curr)
        }
        return acc
    })
}

// 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().reduce([Int](), { (acc, curr) in
        if acc.isEmpty || acc.last! != curr {
            acc.append(curr)
        }
        return acc
    })
}

// 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().reduce([Int](), { (acc, curr) in
        if acc.isEmpty || acc.last! != curr {
            acc.append(curr)
        }
        return acc
    })
}

// 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().reduce([Int](), { (acc, curr) in
        if acc.isEmpty || acc.last! != curr {
            acc.append(curr)
        }
        return acc
    })
}

// 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().reduce([Int](), { (acc, curr) in
        if acc.isEmpty || acc.last! != curr {
            acc.
acc.append(curr) // cannot use mutating member on immutable value: 'acc' is a 'let' constant

func unique(l: [Int]) -> [Int] {
    var result: [Int] = []
    for i in l {
        if !result.contains(i) {
            result.append(i)
        }
    }
    return result.sorted()
}

func unique(l: [Int]) -> [Int] {
    return l.reduce([], { (result, i) in
        if !result.contains(i) {
            result.append(i)
        }
        return result
    }).sorted()
}
```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.sorted()
}

// 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.reduce([], { (result, i) in
        if !result.contains(i) {
            result.append(i)
        }
        return result
    }).sorted()
}

// 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.reduce([], { (result, i) in
        if !result.contains(i) {
            result.append(i)
        }
        return result
    }).sorted()
}

// 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.reduce([], { (result, i) in
        if !result.contains(i) {
            result.append(i)
        }
        return result
    }).sorted()
}

// 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.reduce([], { (result, i) in
        if !result.contains(i) {
            result.append(i)
        }
        return result
    }).sorted()
}

// 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.reduce([], { (result, i) in
        if !result.contains(i) {
            result.append(i)
        }
        return result
    }).sorted()
}

// 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.reduce([], { (result, i) in
        if !result.contains(i) {
            result.append(i)
        }
        return result
    }).sorted()
}

// 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.reduce([], { (result, i) in
        if !result.contains(i) {
            result.append(i)
        }
        return result
    }).sorted()
}

// Return sorted unique elements in an array
// unique(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [0, 2, 3
func unique(l: [Int]) -> [Int] { // invalid redeclaration of 'unique(l:)'
result.append(i) // cannot use mutating member on immutable value: 'result' is a 'let' constant

func unique(l: [Int]) -> [Int] {
    return l.sorted().reduce([Int](), { (result, element) in
        if result.isEmpty || result.last! != element {
            result.append(element)
        }
        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] {
    return l.sorted().reduce([Int](), { (result, element) in
        if result.isEmpty || result.last! != element {
            result.append(element)
        }
        return result
    })
}

unique(l: [5, 3, 5, 2, 3, 3, 9, 0, 123])
```
result.append(element) // cannot use mutating member on immutable value: 'result' is a 'let' constant

func unique(l: [Int]) -> [Int] {
    return l.sorted().reduce([Int](), { (acc, x) in
        if acc.last != x {
            acc.append(x)
        }
        return acc
    })
}
```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().reduce([Int](), { (acc, x) in
        if acc.last != x {
            acc.append(x)
        }
        return acc
    })
}

print(unique(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]))
```
acc.append(x) // cannot use mutating member on immutable value: 'acc' is a 'let' constant

func unique(l: [Int]) -> [Int] {
    return l.sorted().reduce([Int](), { (acc, curr) -> [Int] in
        if acc.last != curr {
            acc.append(curr)
        }
        return acc
    })
}
```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().reduce([Int](), { (acc, curr) -> [Int] in
        if acc.last != curr {
            acc.append(curr)
        }
        return acc
    })
}

// 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().reduce([Int](), { (acc, curr) -> [Int] in
        if acc.last != curr {
            acc.append(curr)
        }
        return acc
    })
}

// 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().reduce([Int](), { (acc, curr) -> [Int] in
        if acc.last != curr {
            acc.append(curr)
        }
        return acc
    })
}

// 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().reduce([Int](), { (acc, curr) -> [Int] in
        if acc.last != curr {
            acc.append(curr)
        }
        return acc
    })
}

// 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().reduce([Int](), { (acc, curr) -> [Int] in
        if acc.last != curr {
            acc.append(curr)
        }
        return acc
    })
}

// 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().reduce([Int](), { (acc, curr) -> [Int] in
        if acc.last != curr {
            acc.append(curr)
        }
        return acc
    })
}

// 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().reduce([Int](), { (acc, curr) -> [Int] in
        if acc.last != curr {
            acc.append(curr)
        }
        return acc
    })
}

// 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().reduce([Int](), { (acc, curr) -> [Int] in
        if acc.last != curr {
            acc.append(curr)
        }
acc.append(curr) // cannot use mutating member on immutable value: 'acc' is a 'let' constant

func unique(l: [Int]) -> [Int] {
    return l.sorted().reduce(into: [Int](), { (result, element) in
        if result.last != element {
            result.append(element)
        }
    })
}
```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().reduce(into: [Int](), { (result, element) in
        if result.last != element {
            result.append(element)
        }
    })
}
```

func unique(l: [Int]) -> [Int] {
    return l.sorted().reduce(into: [Int](), { (result, element) in
        if result.last != element {
            result.append(element)
        }
    })
}
```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().reduce(into: [Int](), { (result, element) in
        if result.last != element {
            result.append(element)
        }
    })
}

print(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().reduce(into: [Int](), { (acc, curr) in
        if acc.last != curr {
            acc.append(curr)
        }
    })
}
```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().reduce(into: [Int](), { (acc, curr) in
        if acc.last != curr {
            acc.append(curr)
        }
    })
}

unique(l: [5, 3, 5, 2, 3, 3, 9, 0, 123])
```

func unique(l: [Int]) -> [Int] {
    return l.reduce(into: [Int](), { (result, element) in
        if !result.contains(element) {
            result.append(element)
        }
    })
}
```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.reduce(into: [Int](), { (result, element) in
        if !result.contains(element) {
            result.append(element)
        }
    })
}
```
 // XCTAssertTrue failed

func unique(l: [Int]) -> [Int] {
    return l.sorted().filter { $0 != l[$0] }
}
```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().filter { $0 != l[$0] }
}

// 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().filter { $0 != l[$0] }
}

// 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().filter { $0 != l[$0] }
}

// 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().filter { $0 != l[$0] }
}

// 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().filter { $0 != l[$0] }
}

// 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().filter { $0 != l[$0] }
}

// 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().filter { $0 != l[$0] }
}

// 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().filter { $0 != l[$0] }
}

// 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().filter { $0 != l[$0] }
}

// 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().filter { $0 != l[$0] }
}

// 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
 // Fatal error: Index out of range

func maxElement(l: [Int]) -> Int {
    var max = l[0]
    for i in 1..<l.count {
        if l[i] > max {
            max = l[i]
        }
    }
    return max
}

func minElement(l: [Int]) -> Int {
    var min = l[0]
    for i in 1..<l.count {
        if l[i] < min {
            min = l[i]
        }
    }
    return min
}

func sum(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        sum += l[i]
    }
    return sum
}

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

func count(l: [Int]) -> Int {
    return l.count
}

func countGreaterThan(l: [Int], value: Int) -> Int {
    var count = 0
    for i in 0..<l.count {
        if l[i] > value {
            count += 1
        }
    }
    return count
}

func countLessThan(l: [Int], value: Int) -> Int {
    var count = 0
    for i in 0..<l.count {
        if l[i] < value {
            count += 1
        }
    }
    return count
}
```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 1..<l.count {
        if l[i] > max {
            max = l[i]
        }
    }
    return max
}

// Return minimum element in the array.
// minElement(l: [1, 2, 3]) == 1
// minElement(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == -10
func minElement(l: [Int]) -> Int {
    var min = l[0]
    for i in 1..<l.count {
        if l[i] < min {
            min = l[i]
        }
    }
    return min
}

// Return the sum of all elements in the array.
// sum(l: [1, 2, 3]) == 6
// sum(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 123
func sum(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        sum += l[i]
    }
    return sum
}

// Return the average of all elements in the array.
// average(l: [1, 2, 3]) == 2
// average(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 23
func average(l: [Int]) -> Int {
    return sum(l) / l.count
}

// Return the number of elements in the array.
// count(l: [1, 2, 3]) == 3
// count(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 11
func count(l: [Int]) -> Int {
    return l.count
}

// Return the number of elements in the array that are greater than the given value.
// countGreaterThan(l: [1, 2, 3], value: 2) == 1
// countGreaterThan(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10], value: 3) == 4
func countGreaterThan(l: [Int], value: Int) -> Int {
    var count = 0
    for i in 0..<l.count {
        if l[i] > value {
            count += 1
        }
    }
    return count
}

// Return the number of elements in the array that are less than the given value.
// countLessThan(l: [1, 2, 3], value: 2) == 1
// countLessThan(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10], value: 3) == 6
func countLessThan(l: [Int], value: Int) -> Int {
    var count = 0
    for i in 0..<l.count {
        if l[i] < value {
            count += 1
        }
    }
    return count
}

// Return the number of elements in the array that are equal to the given value.
// countEqual(l: [1, 2, 3], value: 2) == 1
// countEqual(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10], value: 3) == 2
func countEqual(l: [Int], value: Int) -> Int {
    var count = 0
    for i in 0..<l.count {
        if l[i] == value {
            count += 1
        }
    }
    return count
return sum(l) / l.count // missing argument label 'l:' in call

func maxElement(l: [Int]) -> Int {
    var max = l[0]
    for i in 1..<l.count {
        if l[i] > max {
            max = l[i]
        }
    }
    return max
}

func findElement(l: [Int], element: Int) -> Int? {
    for i in 0..<l.count {
        if l[i] == element {
            return i
        }
    }
    return nil
}

func findLastElement(l: [Int], element: Int) -> Int? {
    for i in (0..<l.count).reversed() {
        if l[i] == element {
            return i
        }
    }
    return nil
}

func countElement(l: [Int], element: Int) -> Int {
    var count = 0
    for i in 0..<l.count {
        if l[i] == element {
            count += 1
        }
    }
    return count
}
```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 1..<l.count {
        if l[i] > max {
            max = l[i]
        }
    }
    return max
}

// Return the index of the first occurrence of the given element in the array.
// findElement(l: [1, 2, 3], element: 3) == 2
// findElement(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10], element: 9) == 6
func findElement(l: [Int], element: Int) -> Int? {
    for i in 0..<l.count {
        if l[i] == element {
            return i
        }
    }
    return nil
}

// Return the index of the last occurrence of the given element in the array.
// findLastElement(l: [1, 2, 3], element: 3) == 2
// findLastElement(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10], element: 9) == 6
func findLastElement(l: [Int], element: Int) -> Int? {
    for i in (0..<l.count).reversed() {
        if l[i] == element {
            return i
        }
    }
    return nil
}

// Return the number of occurrences of the given element in the array.
// countElement(l: [1, 2, 3], element: 3) == 1
// countElement(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10], element: 9) == 1
func countElement(l: [Int], element: Int) -> Int {
    var count = 0
    for i in 0..<l.count {
        if l[i] == element {
            count += 1
        }
    }
    return count
}

// Return the number of occurrences of the given element in the array.
// countElement(l: [1, 2, 3], element: 3) == 1
// countElement(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10], element: 9) == 1
func countElement(l: [Int], element: Int) -> Int {
    var count = 0
    for i in 0..<l.count {
        if l[i] == element {
            count += 1
        }
    }
    return count
}

// Return the number of occurrences of the given element in the array.
// countElement(l: [1, 2, 3], element: 3) == 1
// countElement(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10], element: 9) == 1
func countElement(l: [Int], element: Int) -> Int {
    var count = 0
    for i in 0..<l.count {
        if l[i] == element {
            count += 1
        }
    }
    return count
}

// Return the number of occurrences of the given element in the array.
// countElement(l: [1, 2, 3], element: 3) == 1
// countElement(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10], element: 9) == 1
func countElement(l: [Int], element: Int) -> Int {
    var count = 0
    for i in 0..<l.count {
        if l[i] == element {
            count += 1
        }
    }
    return count
}

// Return the number of occurrences of the given element in the array

func maxElement(l: [Int]) -> Int {
    var max = l[0]
    for i in 1..<l.count {
        if l[i] > max {
            max = l[i]
        }
    }
    return max
}

func minElement(l: [Int]) -> Int {
    var min = l[0]
    for i in 1..<l.count {
        if l[i] < min {
            min = l[i]
        }
    }
    return min
}

func sum(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        sum += l[i]
    }
    return sum
}

func average(l: [Int]) -> Double {
    var sum = 0
    for i in 0..<l.count {
        sum += l[i]
    }
    return Double(sum) / Double(l.count)
}

func allPositive(l: [Int]) -> Bool {
    for i in 0..<l.count {
        if l[i] < 0 {
            return false
        }
    }
    return true
}

func allNegative(l: [Int]) -> Bool {
    for i in 0..<l.count {
        if l[i] > 0 {
            return false
        }
    }
    return true
}

func allZero(l: [Int]) -> Bool {
    for i in 0..<l.count {
        if l[i] != 0 {
            return false
        }
    }
    return true
}

func allEven(l: [Int]) -> Bool {
    for i in 0..<l.count {
        if l[i] % 2 != 0 {
            return false
        }
    }
    return true
}
```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 1..<l.count {
        if l[i] > max {
            max = l[i]
        }
    }
    return max
}

// Return minimum element in the array.
// minElement(l: [1, 2, 3]) == 1
// minElement(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == -10
func minElement(l: [Int]) -> Int {
    var min = l[0]
    for i in 1..<l.count {
        if l[i] < min {
            min = l[i]
        }
    }
    return min
}

// Return sum of all elements in the array.
// sum(l: [1, 2, 3]) == 6
// sum(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 123
func sum(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        sum += l[i]
    }
    return sum
}

// Return average of all elements in the array.
// average(l: [1, 2, 3]) == 2
// average(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 12.3
func average(l: [Int]) -> Double {
    var sum = 0
    for i in 0..<l.count {
        sum += l[i]
    }
    return Double(sum) / Double(l.count)
}

// Return true if all elements in the array are positive.
// allPositive(l: [1, 2, 3]) == true
// allPositive(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == false
func allPositive(l: [Int]) -> Bool {
    for i in 0..<l.count {
        if l[i] < 0 {
            return false
        }
    }
    return true
}

// Return true if all elements in the array are negative.
// allNegative(l: [-1, -2, -3]) == true
// allNegative(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == false
func allNegative(l: [Int]) -> Bool {
    for i in 0..<l.count {
        if l[i] > 0 {
            return false
        }
    }
    return true
}

// Return true if all elements in the array are zero.
// allZero(l: [0, 0, 0]) == true
// allZero(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == false
func allZero(l: [Int]) -> Bool {
    for i in 0..<l.count {
        if l[i] != 0 {
            return false
        }
    }
    return true
}

// Return true if all elements in the array are even.
// allEven(l: [2, 4, 6]) == true
// allEven(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == false
func allEven(l: [Int]) -> Bool {
    for i in 0..<l.count {
        if l[i] % 2 != 0 {
            return false
        }
    }
    return true
}

// Return true if all elements in the array are odd.
// allOdd(l: [

func maxElement(l: [Int]) -> Int {
    var max = l[0]
    for i in 1..<l.count {
        if l[i] > max {
            max = l[i]
        }
    }
    return max
}

func minElement(l: [Int]) -> Int {
    var min = l[0]
    for i in 1..<l.count {
        if l[i] < min {
            min = l[i]
        }
    }
    return min
}

func sum(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        sum += l[i]
    }
    return sum
}

func average(l: [Int]) -> Double {
    var sum = 0
    for i in 0..<l.count {
        sum += l[i]
    }
    return Double(sum) / Double(l.count)
}

func countGreaterThan(l: [Int], value: Int) -> Int {
    var count = 0
    for i in 0..<l.count {
        if l[i] > value {
            count += 1
        }
    }
    return count
}

func countLessThan(l: [Int], value: Int) -> Int {
    var count = 0
    for i in 0..<l.count {
        if l[i] < value {
            count += 1
        }
    }
    return count
}

func countEqual(l: [Int], value: Int) -> Int {
    var count = 0
    for i in 0..<l.count {
        if l[i] == value {
            count += 1
        }
    }
    return count
}
```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 1..<l.count {
        if l[i] > max {
            max = l[i]
        }
    }
    return max
}

// Return minimum element in the array.
// minElement(l: [1, 2, 3]) == 1
// minElement(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == -10
func minElement(l: [Int]) -> Int {
    var min = l[0]
    for i in 1..<l.count {
        if l[i] < min {
            min = l[i]
        }
    }
    return min
}

// Return the sum of all elements in the array.
// sum(l: [1, 2, 3]) == 6
// sum(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 123
func sum(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        sum += l[i]
    }
    return sum
}

// Return the average of all elements in the array.
// average(l: [1, 2, 3]) == 2
// average(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 20.3
func average(l: [Int]) -> Double {
    var sum = 0
    for i in 0..<l.count {
        sum += l[i]
    }
    return Double(sum) / Double(l.count)
}

// Return the number of elements in the array that are greater than the given value.
// countGreaterThan(l: [1, 2, 3], value: 2) == 1
// countGreaterThan(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10], value: 5) == 4
func countGreaterThan(l: [Int], value: Int) -> Int {
    var count = 0
    for i in 0..<l.count {
        if l[i] > value {
            count += 1
        }
    }
    return count
}

// Return the number of elements in the array that are less than the given value.
// countLessThan(l: [1, 2, 3], value: 2) == 1
// countLessThan(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10], value: 5) == 6
func countLessThan(l: [Int], value: Int) -> Int {
    var count = 0
    for i in 0..<l.count {
        if l[i] < value {
            count += 1
        }
    }
    return count
}

// Return the number of elements in the array that are equal to the given value.
// countEqual(l: [1, 2, 3], value: 2) == 1
// countEqual(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10], value: 5) == 1
func countEqual(l: [Int], value: Int) -> Int {
    var count = 0
    for i in 0..<l.count {
        if l[i] == value {
            count += 1
        }
    }
    return count
}

// Return the number of elements in the array that are not equal to the given value.
// countNotEqual(l: [1, 2, 3], value: 2) == 2
// countNotEqual(l: [5, 

func maxElement(l: [Int]) -> Int {
    var max = l[0]
    for i in 1..<l.count {
        if l[i] > max {
            max = l[i]
        }
    }
    return max
}

func minElement(l: [Int]) -> Int {
    var min = l[0]
    for i in 1..<l.count {
        if l[i] < min {
            min = l[i]
        }
    }
    return min
}

func sum(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        sum += l[i]
    }
    return sum
}

func average(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        sum += l[i]
    }
    return sum / l.count
}

func allPositive(l: [Int]) -> Bool {
    for i in 0..<l.count {
        if l[i] < 0 {
            return false
        }
    }
    return true
}

func allNegative(l: [Int]) -> Bool {
    for i in 0..<l.count {
        if l[i] > 0 {
            return false
        }
    }
    return true
}

func allZero(l: [Int]) -> Bool {
    for i in 0..<l.count {
        if l[i] != 0 {
            return false
        }
    }
    return true
}

func allEven(l: [Int]) -> Bool {
    for i in 0..<l.count {
        if l[i] % 2 != 0 {
            return false
        }
    }
    return true
}
```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 1..<l.count {
        if l[i] > max {
            max = l[i]
        }
    }
    return max
}

// Return minimum element in the array.
// minElement(l: [1, 2, 3]) == 1
// minElement(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == -10
func minElement(l: [Int]) -> Int {
    var min = l[0]
    for i in 1..<l.count {
        if l[i] < min {
            min = l[i]
        }
    }
    return min
}

// Return sum of all elements in the array.
// sum(l: [1, 2, 3]) == 6
// sum(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 123
func sum(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        sum += l[i]
    }
    return sum
}

// Return average of all elements in the array.
// average(l: [1, 2, 3]) == 2
// average(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 12
func average(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        sum += l[i]
    }
    return sum / l.count
}

// Return true if all elements in the array are positive.
// allPositive(l: [1, 2, 3]) == true
// allPositive(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == false
func allPositive(l: [Int]) -> Bool {
    for i in 0..<l.count {
        if l[i] < 0 {
            return false
        }
    }
    return true
}

// Return true if all elements in the array are negative.
// allNegative(l: [-1, -2, -3]) == true
// allNegative(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == false
func allNegative(l: [Int]) -> Bool {
    for i in 0..<l.count {
        if l[i] > 0 {
            return false
        }
    }
    return true
}

// Return true if all elements in the array are zero.
// allZero(l: [0, 0, 0]) == true
// allZero(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == false
func allZero(l: [Int]) -> Bool {
    for i in 0..<l.count {
        if l[i] != 0 {
            return false
        }
    }
    return true
}

// Return true if all elements in the array are even.
// allEven(l: [2, 4, 6]) == true
// allEven(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == false
func allEven(l: [Int]) -> Bool {
    for i in 0..<l.count {
        if l[i] % 2 != 0 {
            return false
        }
    }
    return true
}

// Return true if all elements in the array are odd.
// allOdd(l: [1, 3, 5])

func maxElement(l: [Int]) -> Int {
    return 0
}
```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 0
}
```
 // XCTAssertTrue failed

func maxElement(l: [Int]) -> Int {
    var max = l[0]
    for i in 1..<l.count {
        if l[i] > max {
            max = l[i]
        }
    }
    return max
}

func minElement(l: [Int]) -> Int {
    var min = l[0]
    for i in 1..<l.count {
        if l[i] < min {
            min = l[i]
        }
    }
    return min
}

func sum(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        sum += l[i]
    }
    return sum
}

func average(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        sum += l[i]
    }
    return sum / l.count
}

func evenCount(l: [Int]) -> Int {
    var count = 0
    for i in 0..<l.count {
        if l[i] % 2 == 0 {
            count += 1
        }
    }
    return count
}

func oddCount(l: [Int]) -> Int {
    var count = 0
    for i in 0..<l.count {
        if l[i] % 2 != 0 {
            count += 1
        }
    }
    return count
}

func divisibleBy3Count(l: [Int]) -> Int {
    var count = 0
    for i in 0..<l.count {
        if l[i] % 3 == 0 {
            count += 1
        }
    }
    return count
}
```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 1..<l.count {
        if l[i] > max {
            max = l[i]
        }
    }
    return max
}

// Return minimum element in the array.
// minElement(l: [1, 2, 3]) == 1
// minElement(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == -10
func minElement(l: [Int]) -> Int {
    var min = l[0]
    for i in 1..<l.count {
        if l[i] < min {
            min = l[i]
        }
    }
    return min
}

// Return sum of all elements in the array.
// sum(l: [1, 2, 3]) == 6
// sum(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 123
func sum(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        sum += l[i]
    }
    return sum
}

// Return average of all elements in the array.
// average(l: [1, 2, 3]) == 2
// average(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 12
func average(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        sum += l[i]
    }
    return sum / l.count
}

// Return number of even elements in the array.
// evenCount(l: [1, 2, 3]) == 1
// evenCount(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 4
func evenCount(l: [Int]) -> Int {
    var count = 0
    for i in 0..<l.count {
        if l[i] % 2 == 0 {
            count += 1
        }
    }
    return count
}

// Return number of odd elements in the array.
// oddCount(l: [1, 2, 3]) == 2
// oddCount(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 6
func oddCount(l: [Int]) -> Int {
    var count = 0
    for i in 0..<l.count {
        if l[i] % 2 != 0 {
            count += 1
        }
    }
    return count
}

// Return number of elements in the array that are divisible by 3.
// divisibleBy3Count(l: [1, 2, 3]) == 1
// divisibleBy3Count(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 5
func divisibleBy3Count(l: [Int]) -> Int {
    var count = 0
    for i in 0..<l.count {
        if l[i] % 3 == 0 {
            count += 1
        }
    }
    return count
}

// Return number of elements in the array that are divisible by 5.
// divisibleBy5Count(l: [1, 2, 3]) == 0
// divisibleBy5Count(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 3
func divisibleBy5Count(l: [Int]) -> Int {
    var count = 0
    for i in 0..<l.count {

func maxElement(l: [Int]) -> Int {
    var max = l[0]
    for i in 1..<l.count {
        if l[i] > max {
            max = l[i]
        }
    }
    return max
}

func minElement(l: [Int]) -> Int {
    var min = l[0]
    for i in 1..<l.count {
        if l[i] < min {
            min = l[i]
        }
    }
    return min
}

func sum(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        sum += l[i]
    }
    return sum
}

func average(l: [Int]) -> Double {
    var sum = 0
    for i in 0..<l.count {
        sum += l[i]
    }
    return Double(sum) / Double(l.count)
}

func count(l: [Int]) -> Int {
    return l.count
}

func countGreaterThan(l: [Int], value: Int) -> Int {
    var count = 0
    for i in 0..<l.count {
        if l[i] > value {
            count += 1
        }
    }
    return count
}

func countLessThan(l: [Int], value: Int) -> Int {
    var count = 0
    for i in 0..<l.count {
        if l[i] < value {
            count += 1
        }
    }
    return count
}
```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 1..<l.count {
        if l[i] > max {
            max = l[i]
        }
    }
    return max
}

// Return minimum element in the array.
// minElement(l: [1, 2, 3]) == 1
// minElement(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == -10
func minElement(l: [Int]) -> Int {
    var min = l[0]
    for i in 1..<l.count {
        if l[i] < min {
            min = l[i]
        }
    }
    return min
}

// Return the sum of all elements in the array.
// sum(l: [1, 2, 3]) == 6
// sum(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 113
func sum(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        sum += l[i]
    }
    return sum
}

// Return the average of all elements in the array.
// average(l: [1, 2, 3]) == 2
// average(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 11.3
func average(l: [Int]) -> Double {
    var sum = 0
    for i in 0..<l.count {
        sum += l[i]
    }
    return Double(sum) / Double(l.count)
}

// Return the number of elements in the array.
// count(l: [1, 2, 3]) == 3
// count(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 11
func count(l: [Int]) -> Int {
    return l.count
}

// Return the number of elements in the array that are greater than the given value.
// countGreaterThan(l: [1, 2, 3], value: 2) == 1
// countGreaterThan(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10], value: 5) == 4
func countGreaterThan(l: [Int], value: Int) -> Int {
    var count = 0
    for i in 0..<l.count {
        if l[i] > value {
            count += 1
        }
    }
    return count
}

// Return the number of elements in the array that are less than the given value.
// countLessThan(l: [1, 2, 3], value: 2) == 1
// countLessThan(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10], value: 5) == 6
func countLessThan(l: [Int], value: Int) -> Int {
    var count = 0
    for i in 0..<l.count {
        if l[i] < value {
            count += 1
        }
    }
    return count
}

// Return the number of elements in the array that are equal to the given value.
// countEqual(l: [1, 2, 3], value: 2) == 1
// countEqual(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10], value: 5) == 1
func countEqual(l: [Int], value: Int) -> Int {
    var count = 0
    for i

func maxElement(l: [Int]) -> Int {
    var max = l[0]
    for i in 1..<l.count {
        if l[i] > max {
            max = l[i]
        }
    }
    return max
}

func minElement(l: [Int]) -> Int {
    var min = l[0]
    for i in 1..<l.count {
        if l[i] < min {
            min = l[i]
        }
    }
    return min
}

func sum(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        sum += l[i]
    }
    return sum
}

func average(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        sum += l[i]
    }
    return sum / l.count
}

func count(l: [Int]) -> Int {
    return l.count
}

func count(l: [Int], value: Int) -> Int {
    var count = 0
    for i in 0..<l.count {
        if l[i] == value {
            count += 1
        }
    }
    return count
}

func countGreaterThan(l: [Int], value: Int) -> Int {
    var count = 0
    for i in 0..<l.count {
        if l[i] > value {
            count += 1
        }
    }
    return count
}
```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 1..<l.count {
        if l[i] > max {
            max = l[i]
        }
    }
    return max
}

// Return minimum element in the array.
// minElement(l: [1, 2, 3]) == 1
// minElement(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == -10
func minElement(l: [Int]) -> Int {
    var min = l[0]
    for i in 1..<l.count {
        if l[i] < min {
            min = l[i]
        }
    }
    return min
}

// Return the sum of all elements in the array.
// sum(l: [1, 2, 3]) == 6
// sum(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 121
func sum(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        sum += l[i]
    }
    return sum
}

// Return the average of all elements in the array.
// average(l: [1, 2, 3]) == 2
// average(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 12
func average(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        sum += l[i]
    }
    return sum / l.count
}

// Return the number of elements in the array.
// count(l: [1, 2, 3]) == 3
// count(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 11
func count(l: [Int]) -> Int {
    return l.count
}

// Return the number of elements in the array that are equal to the given value.
// count(l: [1, 2, 3], value: 2) == 1
// count(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10], value: 3) == 2
func count(l: [Int], value: Int) -> Int {
    var count = 0
    for i in 0..<l.count {
        if l[i] == value {
            count += 1
        }
    }
    return count
}

// Return the number of elements in the array that are greater than the given value.
// countGreaterThan(l: [1, 2, 3], value: 2) == 1
// countGreaterThan(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10], value: 3) == 4
func countGreaterThan(l: [Int], value: Int) -> Int {
    var count = 0
    for i in 0..<l.count {
        if l[i] > value {
            count += 1
        }
    }
    return count
}

// Return the number of elements in the array that are less than the given value.
// countLessThan(l: [1, 2, 3], value: 2) == 1
// countLessThan(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10], value: 3) == 6
func countLessThan(l: [Int], value: Int) -> Int {
    var count = 0
    for i in 0..<l.count {

func maxElement(l: [Int]) -> Int {
    var max = l[0]
    for i in 1..<l.count {
        if l[i] > max {
            max = l[i]
        }
    }
    return max
}

func minElement(l: [Int]) -> Int {
    var min = l[0]
    for i in 1..<l.count {
        if l[i] < min {
            min = l[i]
        }
    }
    return min
}

func sum(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        sum += l[i]
    }
    return sum
}

func average(l: [Int]) -> Double {
    var sum = 0
    for i in 0..<l.count {
        sum += l[i]
    }
    return Double(sum) / Double(l.count)
}

func allPositive(l: [Int]) -> Bool {
    for i in 0..<l.count {
        if l[i] < 0 {
            return false
        }
    }
    return true
}

func allNegative(l: [Int]) -> Bool {
    for i in 0..<l.count {
        if l[i] > 0 {
            return false
        }
    }
    return true
}

func allZero(l: [Int]) -> Bool {
    for i in 0..<l.count {
        if l[i] != 0 {
            return false
        }
    }
    return true
}

func allEven(l: [Int]) -> Bool {
    for i in 0..<l.count {
        if l[i] % 2 != 0 {
            return false
        }
    }
    return true
}
```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 1..<l.count {
        if l[i] > max {
            max = l[i]
        }
    }
    return max
}

// Return minimum element in the array.
// minElement(l: [1, 2, 3]) == 1
// minElement(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == -10
func minElement(l: [Int]) -> Int {
    var min = l[0]
    for i in 1..<l.count {
        if l[i] < min {
            min = l[i]
        }
    }
    return min
}

// Return sum of all elements in the array.
// sum(l: [1, 2, 3]) == 6
// sum(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 113
func sum(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        sum += l[i]
    }
    return sum
}

// Return average of all elements in the array.
// average(l: [1, 2, 3]) == 2
// average(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 11.3
func average(l: [Int]) -> Double {
    var sum = 0
    for i in 0..<l.count {
        sum += l[i]
    }
    return Double(sum) / Double(l.count)
}

// Return true if all elements in the array are positive.
// allPositive(l: [1, 2, 3]) == true
// allPositive(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == false
func allPositive(l: [Int]) -> Bool {
    for i in 0..<l.count {
        if l[i] < 0 {
            return false
        }
    }
    return true
}

// Return true if all elements in the array are negative.
// allNegative(l: [-1, -2, -3]) == true
// allNegative(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == false
func allNegative(l: [Int]) -> Bool {
    for i in 0..<l.count {
        if l[i] > 0 {
            return false
        }
    }
    return true
}

// Return true if all elements in the array are zero.
// allZero(l: [0, 0, 0]) == true
// allZero(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == false
func allZero(l: [Int]) -> Bool {
    for i in 0..<l.count {
        if l[i] != 0 {
            return false
        }
    }
    return true
}

// Return true if all elements in the array are even.
// allEven(l: [2, 4, 6]) == true
// allEven(l: [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == false
func allEven(l: [Int]) -> Bool {
    for i in 0..<l.count {
        if l[i] % 2 != 0 {
            return false
        }
    }
    return true
}

// Return true if all elements in the array are odd.
// allOdd(l: [

func fizzBuzz(n: Int) -> Int {
    var count = 0
    for i in 0..<n {
        if i % 11 == 0 || i % 13 == 0 {
            let num = i
            while num > 0 {
                if num % 10 == 7 {
                    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 0..<n {
        if i % 11 == 0 || i % 13 == 0 {
            let num = i
            while num > 0 {
                if num % 10 == 7 {
                    count += 1
                }
                num /= 10
            }
        }
    }
    return count
}

print(fizzBuzz(n: 50))
print(fizzBuzz(n: 78))
print(fizzBuzz(n: 79))
```
num /= 10 // left side of mutating operator isn't mutable: 'num' is a 'let' constant

func fizzBuzz(n: Int) -> Int {
    var count = 0
    for i in 0..<n {
        if i % 11 == 0 || i % 13 == 0 {
            let str = String(i)
            for char in str {
                if char == "7" {
                    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 0..<n {
        if i % 11 == 0 || i % 13 == 0 {
            let str = String(i)
            for char in str {
                if char == "7" {
                    count += 1
                }
            }
        }
    }
    return count
}

print(fizzBuzz(n: 50))
print(fizzBuzz(n: 78))
print(fizzBuzz(n: 79))
```

func fizzBuzz(n: Int) -> Int {
    var count = 0
    for i in 0..<n {
        if i % 11 == 0 || i % 13 == 0 {
            count += String(i).filter { $0 == "7" }.count
        }
    }
    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 0..<n {
        if i % 11 == 0 || i % 13 == 0 {
            count += String(i).filter { $0 == "7" }.count
        }
    }
    return count
}

print(fizzBuzz(n: 50))
print(fizzBuzz(n: 78))
print(fizzBuzz(n: 79))
```

func fizzBuzz(n: Int) -> Int {
    var count = 0
    for i in 0..<n {
        if i % 11 == 0 || i % 13 == 0 {
            count += String(i).filter { $0 == "7" }.count
        }
    }
    return count
}

import Foundation
```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 0..<n {
        if i % 11 == 0 || i % 13 == 0 {
            count += String(i).filter { $0 == "7" }.count
        }
    }
    return count
}

print(fizzBuzz(n: 50))
print(fizzBuzz(n: 78))
print(fizzBuzz(n: 79))

//: [Next](@next)<|endoftext|>//: [Previous](@previous)

import Foundation

//: # 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. 함수 선

func fizzBuzz(n: Int) -> Int {
    var count = 0
    for i in 0..<n {
        if i % 11 == 0 || i % 13 == 0 {
            let str = String(i)
            for char in str {
                if char == "7" {
                    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 0..<n {
        if i % 11 == 0 || i % 13 == 0 {
            let str = String(i)
            for char in str {
                if char == "7" {
                    count += 1
                }
            }
        }
    }
    return count
}

print(fizzBuzz(n: 50))
print(fizzBuzz(n: 78))
print(fizzBuzz(n: 79))
```

func fizzBuzz(n: Int) -> Int {
    var count = 0
    for i in 0..<n {
        if i % 11 == 0 || i % 13 == 0 {
            let str = String(i)
            for j in str {
                if j == "7" {
                    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 0..<n {
        if i % 11 == 0 || i % 13 == 0 {
            let str = String(i)
            for j in str {
                if j == "7" {
                    count += 1
                }
            }
        }
    }
    return count
}
print(fizzBuzz(n: 79))
```

func fizzBuzz(n: Int) -> Int {
    var count = 0
    for i in 0..<n {
        if i % 11 == 0 || i % 13 == 0 {
            let str = String(i)
            for char in str {
                if char == "7" {
                    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 0..<n {
        if i % 11 == 0 || i % 13 == 0 {
            let str = String(i)
            for char in str {
                if char == "7" {
                    count += 1
                }
            }
        }
    }
    return count
}
print(fizzBuzz(n: 50))
print(fizzBuzz(n: 78))
print(fizzBuzz(n: 79))
```

func fizzBuzz(n: Int) -> Int {
    var count = 0
    for i in 0..<n {
        if i % 11 == 0 || i % 13 == 0 {
            let str = String(i)
            for char in str {
                if char == "7" {
                    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 0..<n {
        if i % 11 == 0 || i % 13 == 0 {
            let str = String(i)
            for char in str {
                if char == "7" {
                    count += 1
                }
            }
        }
    }
    return count
}

print(fizzBuzz(n: 50))
print(fizzBuzz(n: 78))
print(fizzBuzz(n: 79))
```

func fizzBuzz(n: Int) -> Int {
    var count = 0
    for i in 0..<n {
        if i % 11 == 0 || i % 13 == 0 {
            let str = String(i)
            for char in str {
                if char == "7" {
                    count += 1
                }
            }
        }
    }
    return count
}

import Foundation
```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 0..<n {
        if i % 11 == 0 || i % 13 == 0 {
            let str = String(i)
            for char in str {
                if char == "7" {
                    count += 1
                }
            }
        }
    }
    return count
}

print(fizzBuzz(n: 50))
print(fizzBuzz(n: 78))
print(fizzBuzz(n: 79))

//: [Next](@next)<|endoftext|>//: [Previous](@previous)

import Foundation

//: # 1. 아래 코드를 실행하면 어떤 결과가 나올까요?

let a = 10
let b = 20

if a > b {
    print("a가 크다")
} else {
    print("b가 크다")
}

//: # 2. 아래 코드를 실행하면 어떤 결과가 나올까요?

let c = 10
let d = 20

if c > d {
    print("c가 크다")
} else if c == d {
    print("c와 d는 같다")
} else {
    print("d가 크다")
}

//: # 3. 아래 코드를 실행하면 어떤 결과가 나올까요?

let e = 10
let f = 20

if e > f {
    print("e가 크다")
} else if e == f {
    print("e와 f는 같다")
} else if e < f {
    print("f가 크다")
}

//: # 4. 아래 코드를 실행하면 어떤 결과가 나올까요?

let g = 10
let h = 20

if g > h {
    print("g가 크다")
} else if g == h {
    print("g와 h는 같다")
} else if g < h {
    print("h가 크다")
}

//: # 5. 아래 코드를 실행하면 어떤 결과가 나올까요?

let i = 10
let j = 20

if i > j {
    print("i가 크다")
} else if i == j {
    print("i와 j는 같다")
} else if i < j {
    print("j가 크다")
}

//: # 6. 아래 코드를 실행하면 어떤 결과가 나올까요?

let k = 10
let l = 20

if k > l {
    print("k가 크다")
} else if k == l {
    print("k와 l는 같다")
} else if k < l {
    print("l가 크다")
}

//:

func fizzBuzz(n: Int) -> Int {
    var count = 0
    for i in 0..<n {
        if i % 11 == 0 || i % 13 == 0 {
            let str = String(i)
            for j in str {
                if j == "7" {
                    count += 1
                }
            }
        }
    }
    return count
}

import Foundation

func reverseString(_ s: inout [Character]) {
    s.reverse()
}

func reverseString2(_ s: inout [Character]) {
    var left = 0
    var right = s.count - 1

    while left < right {
        s.swapAt(left, right)
        left += 1
        right -= 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 0..<n {
        if i % 11 == 0 || i % 13 == 0 {
            let str = String(i)
            for j in str {
                if j == "7" {
                    count += 1
                }
            }
        }
    }
    return count
}
print(fizzBuzz(n: 50))
print(fizzBuzz(n: 78))
print(fizzBuzz(n: 79))

//: [Next](@next)<|endoftext|>//: [Previous](@previous)

import Foundation

//: ## 1. 문자열 뒤집기
//: 문자열을 뒤집는 함수를 작성하라.
//: 입력값은 문자 배열이며, 리턴 없이 리스트 내부를 직접 조작하라.

func reverseString(_ s: inout [Character]) {
    s.reverse()
}

var s = ["h", "e", "l", "l", "o"]
reverseString(&s)
print(s)

var s2 = ["H", "a", "n", "n", "a", "h"]
reverseString(&s2)
print(s2)

//: ## 2. 문자열 뒤집기 2
//: 문자열을 뒤집는 함수를 작성하라.
//: 입력값은 문자 배열이며, 리턴 없이 리스트 내부를 직접 조작하라.

func reverseString2(_ s: inout [Character]) {
    var left = 0
    var right = s.count - 1

    while left < right {
        s.swapAt(left, right)
        left += 1
        right -= 1
    }
}

var s3 = ["h", "e", "l", "l", "o"]
reverseString2(&s3)
print(s3)

var s4 = ["H", "a", "n", "n", "a", "h"]
reverseString2(&s4)
print(s4)

//: [Next](@next)<|endoftext|>//: [Previous](@previous)

import Foundation

//: ## 1. 문자열 뒤집기
//: 문자열을 뒤집는 함수를 작성하라.
//: 입력값은 문자 배열이며, 리턴 없이 리스트 내부를 직접 조작하라.

func reverseString(_ s: inout [Character]) {
    s.reverse()
}

var s = ["h", "e", "l", "l", "o"]
reverseString(&s)
print(s)

var s2 = ["H", "a", "n", "n", "a", "h"]
reverseString(&s2)
print(s2)

//: ## 2. 문자열 뒤집기 2
//: 문자열을 뒤집는 함수를 작성하라.
//:

func sortEven(l: [Int]) -> [Int] {
    var result = l
    var even = l.filter { $0 % 2 == 0 }
    even.sort()
    for i in 0..<l.count {
        if i % 2 == 0 {
            result[i] = even.removeAtIndex(0)
        }
    }
    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
    var even = l.filter { $0 % 2 == 0 }
    even.sort()
    for i in 0..<l.count {
        if i % 2 == 0 {
            result[i] = even.removeAtIndex(0)
        }
    }
    return result
}

print(sortEven(l: [1, 2, 3]))
print(sortEven(l: [5, 6, 3, 4]))
```
result[i] = even.removeAtIndex(0) // value of type '[Int]' has no member 'removeAtIndex'

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]
        }
    }
    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]
        }
    }
    return l
}

print(sortEven(l: [1, 2, 3]))
print(sortEven(l: [5, 6, 3, 4]))
```
 // XCTAssertTrue failed

func sortEven(l: [Int]) -> [Int] {
    var sorted = l
    for i in 0..<l.count {
        if i % 2 == 0 {
            sorted[i] = l[i]
        }
    }
    return sorted
}
```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 sorted = l
    for i in 0..<l.count {
        if i % 2 == 0 {
            sorted[i] = l[i]
        }
    }
    return sorted
}
```
 // XCTAssertTrue failed

func sortEven(l: [Int]) -> [Int] {
    var sorted = l
    for i in 0..<l.count {
        if i % 2 == 0 {
            sorted[i] = l[i]
        }
    }
    return sorted
}
```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 sorted = l
    for i in 0..<l.count {
        if i % 2 == 0 {
            sorted[i] = l[i]
        }
    }
    return sorted
}
```
 // XCTAssertTrue failed

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]
        }
    }
    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 != 0 {
            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 0..<l.count {
        if i % 2 == 0 {
            l[i] = l[i]
        } else {
            l[i] = l[i]
        }
    }
    return l
}

print(sortEven(l: [1, 2, 3]))
print(sortEven(l: [5, 6, 3, 4]))

// 2. Write a function that takes an array of integers and returns the sum of the even indicies.
// sumEven(l: [1, 2, 3]) == 2
// sumEven(l: [5, 6, 3, 4]) == 9
func sumEven(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        if i % 2 == 0 {
            sum += l[i]
        }
    }
    return sum
}

print(sumEven(l: [1, 2, 3]))
print(sumEven(l: [5, 6, 3, 4]))

// 3. Write a function that takes an array of integers and returns the sum of the odd indicies.
// sumOdd(l: [1, 2, 3]) == 3
// sumOdd(l: [5, 6, 3, 4]) == 10
func sumOdd(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        if i % 2 != 0 {
            sum += l[i]
        }
    }
    return sum
}

print(sumOdd(l: [1, 2, 3]))
print(sumOdd(l: [5, 6, 3, 4]))

// 4. Write a function that takes an array of integers and returns the sum of the even indicies.
// sumEven(l: [1, 2, 3]) == 2
// sumEven(l: [5, 6, 3, 4]) == 9
func sumEven(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        if i % 2 == 0 {
            sum += l[i]
        }
    }
    return sum
}

print(sumEven(l: [1, 2, 3]))
print(sumEven(l: [5, 6, 3, 4]))

// 5. Write a function that takes an array of integers and returns the sum of the odd indicies.
// sumOdd(l: [1, 2, 3]) == 3
// sumOdd(l: [5, 6, 3, 4]) == 10
func sumOdd(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        if i % 2 != 0 {
            sum += l[i]
        }
    }
    return sum
}

print(sumOdd(l: [1, 2, 3]))
print(sumOdd(l: [5, 6, 3, 4]))

// 6. Write a function that takes an array of integers and returns the sum of the even indicies.
// sumEven(l: [1, 2, 3]) == 2
// sumEven(l: [5, 6, 3, 4]) == 9
func sumEven(l: [Int]) -> Int {
    var sum = 0
    for i in 0..<l.count {
        if i % 2 == 0 {
            sum += l[i]
        }
    }
    return sum
}

print(sumEven(l: [1, 2, 3]))
print(sumEven(l: [5, 6, 3, 4]))

// 7. Write a function that takes an array of integers and returns the sum of the odd indicies.
// sumOdd(l: [1, 2, 3]) == 3
// sumOdd(l: [5
 // XCTAssertTrue failed

func sortEven(l: [Int]) -> [Int] {
    var sorted = l
    for i in 0..<l.count {
        if i % 2 == 0 {
            sorted[i] = l[i]
        }
    }
    return sorted
}
```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 sorted = l
    for i in 0..<l.count {
        if i % 2 == 0 {
            sorted[i] = l[i]
        }
    }
    return sorted
}

print(sortEven(l: [1, 2, 3]))
print(sortEven(l: [5, 6, 3, 4]))
```
 // XCTAssertTrue failed

func sortEven(l: [Int]) -> [Int] {
    var l = l
    for i in 0..<l.count {
        if i % 2 == 0 {
            l[i] = l.filter { $0 % 2 == 0 }.sorted().first!
        }
    }
    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.filter { $0 % 2 == 0 }.sorted().first!
        }
    }
    return l
}
```
 // XCTAssertTrue failed

func sortEven(l: [Int]) -> [Int] {
    var l = l
    var even = l.filter { $0 % 2 == 0 }
    even.sort()
    for i in 0..<l.count {
        if i % 2 == 0 {
            l[i] = even[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
    var even = l.filter { $0 % 2 == 0 }
    even.sort()
    for i in 0..<l.count {
        if i % 2 == 0 {
            l[i] = even[i / 2]
        }
    }
    return l
}
```
 // Fatal error: Index out of range

func sortEven(l: [Int]) -> [Int] {
    var sorted = l
    for i in 0...l.count {
        if i % 2 == 0 {
            sorted[i] = l[i]
        }
    }
    return sorted
}
```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 sorted = l
    for i in 0...l.count {
        if i % 2 == 0 {
            sorted[i] = l[i]
        }
    }
    return sorted
}
```
 // XCTAssertTrue failed

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]
        }
    }
    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]
        }
    }
    return l
}
```
 // XCTAssertTrue failed

func primeFib(n: Int) -> Int {
    // your code here
}
```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 {
    // your code here
}
```
} // missing return in global function expected to return 'Int'

func primeFib(n: Int) -> Int {
    // your code here
}
```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 {
    // your code here
}
```
} // missing return in global function expected to return 'Int'

func primeFib(n: Int) -> Int {
    // your code here
}
```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 {
    // your code here
}
```
} // missing return in global function expected to return 'Int'

```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 fibs = [Int]()
    fibs.append(2)
    fibs.append(3)
    fibs.append(5)
    fibs.append(13)
    fibs.append(89)
    fibs.append(233)
    fibs.append(1597)
    fibs.append(28657)
    fibs.append(514229)
    fibs.append(433494437)
    fibs.append(2971215073)
    fibs.append(99194853094755497)
    fibs.append(1066340417491710595814572169)
    fibs.append(19134702400093278081449423917)
    fibs.append(478361013738440623130639578230)
    fibs.append(12200160415121876738577578025633)
    fibs.append(205746265431479177575286102386305)
    fibs.append(4323415669469123035117517678864953)
    fibs.append(103829926346412989188620039151172289)
    fibs.append(170052004145631452336341635009700822225)
    fibs.append(36543529616230293255288515133151144970936)
    fibs.append(1104330181053174733573529739402094655940427)
    fibs.append(20816961791416539088592344070497205797472708)
    fibs.append(5946274021764615471547056298568092841510265346)
    fibs.append(11978510988648274956995104304028791729754898081)
    fibs.append(291339781965194799400251004121209134246392157187)
    fibs.append(8089121075914683608859642779413393147244394365396)
    fibs.append(19116319757318169665438660760401973589850705023907)
    fibs.append(498454011879227757658487506491253827298949318346349)
    fibs.append(1304969544928578979991563889682985
XCTAssertTrue(primeFib(n: 1) == 2) // cannot find 'primeFib' in scope
XCTAssertTrue(primeFib(n: 2) == 3) // cannot find 'primeFib' in scope
XCTAssertTrue(primeFib(n: 3) == 5) // cannot find 'primeFib' in scope
XCTAssertTrue(primeFib(n: 4) == 13) // cannot find 'primeFib' in scope
XCTAssertTrue(primeFib(n: 5) == 89) // cannot find 'primeFib' in scope
XCTAssertTrue(primeFib(n: 6) == 233) // cannot find 'primeFib' in scope
XCTAssertTrue(primeFib(n: 7) == 1597) // cannot find 'primeFib' in scope
XCTAssertTrue(primeFib(n: 8) == 28657) // cannot find 'primeFib' in scope
XCTAssertTrue(primeFib(n: 9) == 514229) // cannot find 'primeFib' in scope
XCTAssertTrue(primeFib(n: 10) == 433494437) // cannot find 'primeFib' in scope

func primeFib(n: Int) -> Int {
    // your code here
}
```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 {
    // your code here
}
```
} // missing return in global function expected to return 'Int'

func primeFib(n: Int) -> Int {
    var fibs = [Int]()
    fibs.append(2)
    fibs.append(3)
    var i = 2
    while fibs.count < n {
        let next = fibs[i - 1] + fibs[i - 2]
        if isPrime(next) {
            fibs.append(next)
        }
        i += 1
    }
    return fibs[n - 1]
}

func isPrime(_ n: Int) -> Bool {
    if n < 2 {
        return false
    }
    for i in 2...Int(sqrt(Double(n))) {
        if n % i == 0 {
            return false
        }
    }
    return true
}
```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 fibs = [Int]()
    fibs.append(2)
    fibs.append(3)
    var i = 2
    while fibs.count < n {
        let next = fibs[i - 1] + fibs[i - 2]
        if isPrime(next) {
            fibs.append(next)
        }
        i += 1
    }
    return fibs[n - 1]
}

// isPrime returns true if n is a prime number.
func isPrime(_ n: Int) -> Bool {
    if n < 2 {
        return false
    }
    for i in 2...Int(sqrt(Double(n))) {
        if n % i == 0 {
            return false
        }
    }
    return true
}

print(primeFib(n: 1))
print(primeFib(n: 2))
print(primeFib(n: 3))
print(primeFib(n: 4))
print(primeFib(n: 5))
```
 // Fatal error: Index out of range

func primeFib(n: Int) -> Int {
    // your code here
}
```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 {
    // your code here
}
```
} // missing return in global function expected to return 'Int'

func primeFib(n: Int) -> Int {
    var fib = [2, 3]
    var i = 2
    while fib.count < n {
        let next = fib[i-1] + fib[i-2]
        if isPrime(next) {
            fib.append(next)
        }
        i += 1
    }
    return fib[n-1]
}

func isPrime(_ n: Int) -> Bool {
    if n < 2 {
        return false
    }
    for i in 2..<n {
        if n % i == 0 {
            return false
        }
    }
    return true
}
```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 = [2, 3]
    var i = 2
    while fib.count < n {
        let next = fib[i-1] + fib[i-2]
        if isPrime(next) {
            fib.append(next)
        }
        i += 1
    }
    return fib[n-1]
}

// isPrime returns true if n is a prime number.
func isPrime(_ n: Int) -> Bool {
    if n < 2 {
        return false
    }
    for i in 2..<n {
        if n % i == 0 {
            return false
        }
    }
    return true
}

print(primeFib(n: 1))
print(primeFib(n: 2))
print(primeFib(n: 3))
print(primeFib(n: 4))
print(primeFib(n: 5))
```
 // Fatal error: Index out of range

func primeFib(n: Int) -> Int {
    var fibs = [Int]()
    fibs.append(2)
    fibs.append(3)
    var i = 2
    while fibs.count < n {
        let nextFib = fibs[i-1] + fibs[i-2]
        if isPrime(nextFib) {
            fibs.append(nextFib)
        }
        i += 1
    }
    return fibs[n-1]
}

func isPrime(_ n: Int) -> Bool {
    if n < 2 {
        return false
    }
    for i in 2...Int(sqrt(Double(n))) {
        if n % i == 0 {
            return false
        }
    }
    return true
}
```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 fibs = [Int]()
    fibs.append(2)
    fibs.append(3)
    var i = 2
    while fibs.count < n {
        let nextFib = fibs[i-1] + fibs[i-2]
        if isPrime(nextFib) {
            fibs.append(nextFib)
        }
        i += 1
    }
    return fibs[n-1]
}

// isPrime returns true if the number is prime, false otherwise.
func isPrime(_ n: Int) -> Bool {
    if n < 2 {
        return false
    }
    for i in 2...Int(sqrt(Double(n))) {
        if n % i == 0 {
            return false
        }
    }
    return true
}

print(primeFib(n: 1)) // 2
print(primeFib(n: 2)) // 3
print(primeFib(n: 3)) // 5
print(primeFib(n: 4)) // 13
print(primeFib(n: 5)) // 89
```
 // Fatal error: Index out of range

func primeFib(n: Int) -> Int {
    var fibs = [2, 3]
    var i = 2
    while fibs.count < n {
        let nextFib = fibs[i-1] + fibs[i-2]
        if isPrime(nextFib) {
            fibs.append(nextFib)
        }
        i += 1
    }
    return fibs[n-1]
}

func isPrime(_ n: Int) -> Bool {
    if n <= 1 {
        return false
    }
    for i in 2...Int(sqrt(Double(n))) {
        if n % i == 0 {
            return false
        }
    }
    return true
}

func isSquare(_ n: Int) -> Bool {
    let sqrt = Int(sqrt(Double(n)))
    return sqrt * sqrt == n
}

func isFibonacci(_ n: Int) -> Bool {
    return isSquare(5 * n * n + 4) || isSquare(5 * n * n - 4)
}
```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 fibs = [2, 3]
    var i = 2
    while fibs.count < n {
        let nextFib = fibs[i-1] + fibs[i-2]
        if isPrime(nextFib) {
            fibs.append(nextFib)
        }
        i += 1
    }
    return fibs[n-1]
}

// isPrime returns true if the number is prime.
func isPrime(_ n: Int) -> Bool {
    if n <= 1 {
        return false
    }
    for i in 2...Int(sqrt(Double(n))) {
        if n % i == 0 {
            return false
        }
    }
    return true
}

// isSquare returns true if the number is a perfect square.
func isSquare(_ n: Int) -> Bool {
    let sqrt = Int(sqrt(Double(n)))
    return sqrt * sqrt == n
}

// isFibonacci returns true if the number is a Fibonacci number.
func isFibonacci(_ n: Int) -> Bool {
    return isSquare(5 * n * n + 4) || isSquare(5 * n * n - 4)
}

// primeFib 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 fibs = [2, 3]
    var i = 2
    while fibs.count < n {
        let nextFib = fibs[i-1] + fibs[i-2]
        if isPrime(nextFib) {
            fibs.append(nextFib)
        }
        i += 1
    }
    return fibs[n-1]
}

// isPrime returns true if the number is prime.
func isPrime(_ n: Int) -> Bool {
    if n <= 1 {
        return false
    }
    for i in 2...Int(sqrt(Double(n))) {
        if n % i == 0 {
            return false
        }
    }
    return true
}

// isSquare returns true if the number is a perfect square.
func isSquare(_ n: Int) -> Bool {
    let sqrt = Int(sqrt(Double(n)))
    return sqrt * sqrt == n
}

// isFibonacci returns true if the number is a Fibonacci number.
func isFibonacci(_ n: Int) -> Bool {
    return isSquare(5 * n * n + 4) || isSquare(5 * n * n - 4)
}

// primeFib 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 fibs = [2, 3]
    var i = 2
    while fibs.count < n {
        let nextFib = fibs[i-1] + fibs[i-2]
        if isPrime(nextFib) {
            fibs.append(nextFib)
        }
        i += 1
    }
    return fibs[n-1]
}

// isPrime returns true if the number is prime.
func isPrime(_ n: Int) -> Bool {
    if n <= 1 {
        return false
    }
    for i in 2...Int(sqrt(Double(n))) {
        if n % i == 0 {
            return false
        }
    }
    return true
}

// is
 // Fatal error: Index out of range

func triplesSumToZero(l: [Int]) -> Bool {
    // Insert your code here
}
```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 {
    // Insert your code here
}
```
} // missing return in global function expected to return 'Bool'

func triplesSumToZero(l: [Int]) -> Bool {
    // Your code goes here
}
```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 goes here
}
```
} // missing return in global function expected to return 'Bool'

func triplesSumToZero(l: [Int]) -> Bool {
    // Insert your code for triplesSumToZero 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 {
    // Insert your code for triplesSumToZero here
    return false
}
```
 // XCTAssertTrue failed

func triplesSumToZero(l: [Int]) -> Bool {
    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 {
    return false
}
```
 // XCTAssertTrue failed

func triplesSumToZero(l: [Int]) -> Bool {
    // Your code goes here
}
```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 goes here
}
```
} // missing return in global function expected to return 'Bool'

func triplesSumToZero(l: [Int]) -> Bool {
    var result = false
    for i in 0...l.count-3 {
        for j in i+1...l.count-2 {
            for k in j+1...l.count-1 {
                if l[i] + l[j] + l[k] == 0 {
                    result = true
                }
            }
        }
    }
    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
    for i in 0...l.count-3 {
        for j in i+1...l.count-2 {
            for k in j+1...l.count-1 {
                if l[i] + l[j] + l[k] == 0 {
                    result = true
                }
            }
        }
    }
    return result
}

print(triplesSumToZero(l: [1, 3, 5, 0]))
print(triplesSumToZero(l: [1, 3, -2, 1]))
print(triplesSumToZero(l: [1, 2, 3, 7]))
print(triplesSumToZero(l: [2, 4, -5, 3, 9, 7]))
print(triplesSumToZero(l: [1]))
```
 // Fatal error: Range requires lowerBound <= upperBound

func triplesSumToZero(l: [Int]) -> Bool {
    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 {
    return false
}
```
 // XCTAssertTrue failed

func triplesSumToZero(l: [Int]) -> Bool {
    var result = 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 {
                    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
    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 {
                    result = true
                    break
                }
            }
        }
    }
    return result
}

print(triplesSumToZero(l: [1, 3, 5, 0]))
print(triplesSumToZero(l: [1, 3, -2, 1]))
print(triplesSumToZero(l: [1, 2, 3, 7]))
print(triplesSumToZero(l: [2, 4, -5, 3, 9, 7]))
print(triplesSumToZero(l: [1]))

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

func triplesSumToZero(l: [Int]) -> Bool {
    // write 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 {
    // write your code here
    return false
}
```
 // XCTAssertTrue failed

func triplesSumToZero(l: [Int]) -> Bool {
    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 {
    return false
}
```
 // XCTAssertTrue failed

func carRaceCollision(n: Int) -> Int {
    // Write your code here
    return 0
}
```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 {
    // Write your code here
    return 0
}

// Example 1:
// Input: n = 1
// Output: 1
// Explanation:
// The first car starts at position 0 and is going to the right.
// The second car starts at position 10 and is going to the left.
// They will collide at position 5.

// Example 2:
// Input: n = 2
// Output: 4
// Explanation:
// There are 4 ways two cars can collide:
// - The first car starts at position 0 and is going to the right; the second car starts at position 10 and is going to the left.
// - The first car starts at position 0 and is going to the right; the second car starts at position 11 and is going to the left.
// - The first car starts at position 1 and is going to the right; the second car starts at position 10 and is going to the left.
// - The first car starts at position 1 and is going to the right; the second car starts at position 11 and is going to the left.

// Example 3:
// Input: n = 3
// Output: 9
// Explanation:
// There are 9 ways three cars can collide:
// - The first car starts at position 0 and is going to the right; the second car starts at position 10 and is going to the left; the third car starts at position 20 and is going to the left.
// - The first car starts at position 0 and is going to the right; the second car starts at position 11 and is going to the left; the third car starts at position 20 and is going to the left.
// - The first car starts at position 1 and is going to the right; the second car starts at position 10 and is going to the left; the third car starts at position 20 and is going to the left.
// - The first car starts at position 1 and is going to the right; the second car starts at position 11 and is going to the left; the third car starts at position 20 and is going to the left.
// - The first car starts at position 2 and is going to the right; the second car starts at position 10 and is going to the left; the third car starts at position 20 and is going to the left.
// - The first car starts at position 2 and is going to the right; the second car starts at position 11 and is going to the left; the third car starts at position 20 and is going to the left.
// - The first car starts at position 10 and is going to the right; the second car starts at position 20 and is going to the left; the third car starts at position 30 and is going to the left.
// - The first car starts at position 11 and is going to the right; the second car starts at position 20 and is going to the left; the third car starts at position 30 and is going to the left.
// - The first car starts at position 10 and is going to the right; the second car starts at position 21 and is going to the left; the third car starts at position 30 and is going to the left.
// - The first car starts at position 11 and is going to the right; the second car starts at position 21 and is going to the left; the third car starts at position 30 and is going to the left.

// Constraints:
// 1 <= n <= 10^9
// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // XCTAssertTrue failed

func carRaceCollision(n: Int) -> Int {
    // TODO: Implement this function
    return 0
}
```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 {
    // TODO: Implement this function
    return 0
}

// Test cases
print(carRaceCollision(n: 1)) // 0
print(carRaceCollision(n: 2)) // 1
print(carRaceCollision(n: 3)) // 3
print(carRaceCollision(n: 4)) // 6
print(carRaceCollision(n: 5)) // 10
print(carRaceCollision(n: 6)) // 15
print(carRaceCollision(n: 7)) // 21
print(carRaceCollision(n: 8)) // 28
print(carRaceCollision(n: 9)) // 36
print(carRaceCollision(n: 10)) // 45
print(carRaceCollision(n: 11)) // 55
print(carRaceCollision(n: 12)) // 66
print(carRaceCollision(n: 13)) // 78
print(carRaceCollision(n: 14)) // 91
print(carRaceCollision(n: 15)) // 105
print(carRaceCollision(n: 16)) // 120
print(carRaceCollision(n: 17)) // 136
print(carRaceCollision(n: 18)) // 153
print(carRaceCollision(n: 19)) // 171
print(carRaceCollision(n: 20)) // 190
print(carRaceCollision(n: 21)) // 210
print(carRaceCollision(n: 22)) // 231
print(carRaceCollision(n: 23)) // 253
print(carRaceCollision(n: 24)) // 276
print(carRaceCollision(n: 25)) // 300
print(carRaceCollision(n: 26)) // 325
print(carRaceCollision(n: 27)) // 351
print(carRaceCollision(n: 28)) // 378
print(carRaceCollision(n: 29)) // 406
print(carRaceCollision(n: 30)) // 435
print(carRaceCollision(n: 31)) // 465
print(carRaceCollision(n: 32)) // 496
print(carRaceCollision(n: 33)) // 528
print(carRaceCollision(n: 34)) // 561
print(carRaceCollision(n: 35)) // 595
print(carRaceCollision(n: 36)) // 630
print(carRaceCollision(n: 37)) // 666
print(carRaceCollision(n: 38)) // 703
print(carRaceCollision(n: 39)) // 741
print(carRaceCollision(n: 40)) // 780
print(carRaceCollision(n: 41)) // 820
print(carRaceCollision(n: 42)) // 861
print(carRaceCollision(n: 43)) // 903
print(carRaceCollision(n: 44)) // 946
print(carRaceCollision(n: 45)) // 990
print(carRaceCollision(n: 46)) // 1035
print(carRaceCollision(n: 47)) // 1081
print(carRaceCollision(n: 48)) // 1128
print(carRaceCollision(n: 49)) // 1176
print(carRaceCollision(n: 50)) // 1225
print(carRaceCollision(n: 51)) // 1275
print(car
 // XCTAssertTrue failed

func carRaceCollision(n: Int) -> Int {
    // Write your code here
    return 0
}
```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 {
    // Write your code here
    return 0
}

print(carRaceCollision(n: 1))
print(carRaceCollision(n: 2))
print(carRaceCollision(n: 3))
print(carRaceCollision(n: 4))
print(carRaceCollision(n: 5))
print(carRaceCollision(n: 6))
print(carRaceCollision(n: 7))
print(carRaceCollision(n: 8))
print(carRaceCollision(n: 9))
print(carRaceCollision(n: 10))
print(carRaceCollision(n: 11))
print(carRaceCollision(n: 12))
print(carRaceCollision(n: 13))
print(carRaceCollision(n: 14))
print(carRaceCollision(n: 15))
print(carRaceCollision(n: 16))
print(carRaceCollision(n: 17))
print(carRaceCollision(n: 18))
print(carRaceCollision(n: 19))
print(carRaceCollision(n: 20))
print(carRaceCollision(n: 21))
print(carRaceCollision(n: 22))
print(carRaceCollision(n: 23))
print(carRaceCollision(n: 24))
print(carRaceCollision(n: 25))
print(carRaceCollision(n: 26))
print(carRaceCollision(n: 27))
print(carRaceCollision(n: 28))
print(carRaceCollision(n: 29))
print(carRaceCollision(n: 30))
print(carRaceCollision(n: 31))
print(carRaceCollision(n: 32))
print(carRaceCollision(n: 33))
print(carRaceCollision(n: 34))
print(carRaceCollision(n: 35))
print(carRaceCollision(n: 36))
print(carRaceCollision(n: 37))
print(carRaceCollision(n: 38))
print(carRaceCollision(n: 39))
print(carRaceCollision(n: 40))
print(carRaceCollision(n: 41))
print(carRaceCollision(n: 42))
print(carRaceCollision(n: 43))
print(carRaceCollision(n: 44))
print(carRaceCollision(n: 45))
print(carRaceCollision(n: 46))
print(carRaceCollision(n: 47))
print(carRaceCollision(n: 48))
print(carRaceCollision(n: 49))
print(carRaceCollision(n: 50))
print(carRaceCollision(n: 51))
print(carRaceCollision(n: 52))
print(carRaceCollision(n: 53))
print(carRaceCollision(n: 54))
print(carRaceCollision(n: 55))
print(carRaceCollision(n: 56))
print(carRaceCollision(n: 57))
print(carRaceCollision(n: 58))
print(carRaceCollision(n: 59))
print(carRaceCollision(n: 60))
print(carRaceCollision(n: 61))
print(carRaceCollision(n: 62))
print(carRaceCollision(n: 63))
print(carRaceCollision(n: 64))
print(carRaceCollision(n: 65))
print(carRaceCollision(n: 66))
print(carRaceCollision(n: 67))
print(carRaceCollision(n: 6
 // XCTAssertTrue failed

func carRaceCollision(n: Int) -> Int {
    return 0
}
```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 {
    return 0
}

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

func carRaceCollision(n: Int) -> Int {
    // Write your code here
    return 0
}
```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 {
    // Write your code here
    return 0
}

print(carRaceCollision(n: 10)) // 45
print(carRaceCollision(n: 100)) // 4950
print(carRaceCollision(n: 1000)) // 499500
print(carRaceCollision(n: 10000)) // 49995000
print(carRaceCollision(n: 100000)) // 4999950000
print(carRaceCollision(n: 1000000)) // 499999500000
print(carRaceCollision(n: 10000000)) // 49999995000000
print(carRaceCollision(n: 100000000)) // 4999999950000000
print(carRaceCollision(n: 1000000000)) // 499999999500000000
print(carRaceCollision(n: 10000000000)) // 4999999999500000000

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

func carRaceCollision(n: Int) -> Int {
    // Write your code here
    return 0
}
```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 {
    // Write your code here
    return 0
}

// Example:
// Input: n = 3
// Output: 3
// Explanation:
// The first car starts at position 0 and is moving right to left.
// The second car starts at position 1 and is moving left to right.
// The third car starts at position 2 and is moving right to left.
// The first car hits the second car.
// The second car hits the third car.
// The third car hits the first car.
// Therefore, there are 3 collisions.

// Input: n = 2
// Output: 0
// Explanation:
// The first car starts at position 0 and is moving right to left.
// The second car starts at position 1 and is moving left to right.
// There are no collisions.

// Input: n = 1
// Output: 0
// Explanation:
// There is only one car, so there are no collisions.

// Input: n = 0
// Output: 0
// Explanation:
// There are no cars, so there are no collisions.

// Input: n = 4
// Output: 6
// Explanation:
// The first car starts at position 0 and is moving right to left.
// The second car starts at position 1 and is moving left to right.
// The third car starts at position 2 and is moving right to left.
// The fourth car starts at position 3 and is moving left to right.
// The first car hits the second car.
// The second car hits the third car.
// The third car hits the fourth car.
// The fourth car hits the first car.
// The first car hits the third car.
// The third car hits the second car.
// Therefore, there are 6 collisions.

// Input: n = 5
// Output: 10
// Explanation:
// The first car starts at position 0 and is moving right to left.
// The second car starts at position 1 and is moving left to right.
// The third car starts at position 2 and is moving right to left.
// The fourth car starts at position 3 and is moving left to right.
// The fifth car starts at position 4 and is moving right to left.
// The first car hits the second car.
// The second car hits the third car.
// The third car hits the fourth car.
// The fourth car hits the fifth car.
// The fifth car hits the first car.
// The first car hits the third car.
// The third car hits the fifth car.
// The fifth car hits the second car.
// The second car hits the fourth car.
// The fourth car hits the first car.
// Therefore, there are 10 collisions.

// Input: n = 6
// Output: 15
// Explanation:
// The first car starts at position 0 and is moving right to left.
// The second car starts at position 1 and is moving left to right.
// The third car starts at position 2 and is moving right to left.
// The fourth car starts at position 3 and is moving left to right.
// The fifth car starts at position 4 and is moving right to left.
// The sixth car starts at position 5 and is moving left to right.
// The first car hits the second car.
// The second car hits the third car.
// The third car hits the fourth car.
// The fourth car hits the fifth car.
// The fifth car hits the sixth car.
// The sixth car hits the first car.
// The first car hits the third car.
// The third car hits the fifth car.
// The fifth car hits the second car.
// The second car hits the fourth car.
// The fourth car hits the sixth car.
// The sixth car hits the third car.
// The third car hits the first car.
// The first car hits the fifth car.
// The fifth car hits the fourth car.
// The fourth car hits the second car.
// The second car hits the sixth car.
// The sixth car hits the fifth car.
// Therefore, there are 15 collisions.

// Input: n = 7
// Output: 21
// Explanation:
// The first car starts at position 0 and is moving right to left.
// The second car starts at position 1 and is moving left to right.
// The third car starts at position 2 and is moving right to left.
// The fourth car starts
 // XCTAssertTrue failed

func carRaceCollision(n: Int) -> Int {
    // Write your code here
    return 0
}
```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 {
    // Write your code here
    return 0
}

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

func carRaceCollision(n: Int) -> Int {
    return n * (n - 1) / 2
}
```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 {
    return n * (n - 1) / 2
}

// Example:
carRaceCollision(n: 3) // 3

// Example:
carRaceCollision(n: 10) // 45

// Example:
carRaceCollision(n: 100) // 4950

// Example:
carRaceCollision(n: 1000) // 499500

// Example:
carRaceCollision(n: 10000) // 49995000

// Example:
carRaceCollision(n: 100000) // 4999950000

// Example:
carRaceCollision(n: 1000000) // 499999500000

// Example:
carRaceCollision(n: 10000000) // 49999995000000

// Example:
carRaceCollision(n: 100000000) // 4999999950000000

// Example:
carRaceCollision(n: 1000000000) // 499999999500000000

// Example:
carRaceCollision(n: 10000000000) // 49999999995000000000

// Example:
carRaceCollision(n: 100000000000) // 4999999999950000000000

// Example:
carRaceCollision(n: 1000000000000) // 499999999999500000000000

// Example:
carRaceCollision(n: 10000000000000) // 49999999999995000000000000

// Example:
carRaceCollision(n: 100000000000000) // 4999999999999950000000000000

// Example:
carRaceCollision(n: 1000000000000000) // 499999999999999500000000000000

// Example:
carRaceCollision(n: 10000000000000000) // 49999999999999995000000000000000

// Example:
carRaceCollision(n: 100000000000000000) // 4999999999999999950000000000000000

// Example:
carRaceCollision(n: 1000000000000000000) // 499999999999999999500000000000000000

// Example:
carRaceCollision(n: 10000000000000000000) // 49999999999999999995000000000000000000

// Example:
carRaceCollision(n: 100000000000000000000) // 499999999999999999
 // XCTAssertTrue failed

func carRaceCollision(n: Int) -> Int {
    return 0
}
```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 {
    return 0
}

print(carRaceCollision(n: 1)) // 0
print(carRaceCollision(n: 2)) // 1
print(carRaceCollision(n: 3)) // 3
print(carRaceCollision(n: 4)) // 6
print(carRaceCollision(n: 5)) // 10
print(carRaceCollision(n: 6)) // 15
print(carRaceCollision(n: 7)) // 21
print(carRaceCollision(n: 8)) // 28
print(carRaceCollision(n: 9)) // 36
print(carRaceCollision(n: 10)) // 45
print(carRaceCollision(n: 11)) // 55
print(carRaceCollision(n: 12)) // 66
print(carRaceCollision(n: 13)) // 78
print(carRaceCollision(n: 14)) // 91
print(carRaceCollision(n: 15)) // 105
print(carRaceCollision(n: 16)) // 120
print(carRaceCollision(n: 17)) // 136
print(carRaceCollision(n: 18)) // 153
print(carRaceCollision(n: 19)) // 171
print(carRaceCollision(n: 20)) // 190
print(carRaceCollision(n: 21)) // 210
print(carRaceCollision(n: 22)) // 231
print(carRaceCollision(n: 23)) // 253
print(carRaceCollision(n: 24)) // 276
print(carRaceCollision(n: 25)) // 300
print(carRaceCollision(n: 26)) // 325
print(carRaceCollision(n: 27)) // 351
print(carRaceCollision(n: 28)) // 378
print(carRaceCollision(n: 29)) // 406
print(carRaceCollision(n: 30)) // 435
print(carRaceCollision(n: 31)) // 465
print(carRaceCollision(n: 32)) // 496
print(carRaceCollision(n: 33)) // 528
print(carRaceCollision(n: 34)) // 561
print(carRaceCollision(n: 35)) // 595
print(carRaceCollision(n: 36)) // 630
print(carRaceCollision(n: 37)) // 666
print(carRaceCollision(n: 38)) // 703
print(carRaceCollision(n: 39)) // 741
print(carRaceCollision(n: 40)) // 780
print(carRaceCollision(n: 41)) // 820
print(carRaceCollision(n: 42)) // 861
print(carRaceCollision(n: 43)) // 903
print(carRaceCollision(n: 44)) // 946
print(carRaceCollision(n: 45)) // 990
print(carRaceCollision(n: 46)) // 1035
print(carRaceCollision(n: 47)) // 1081
print(carRaceCollision(n: 48)) // 1128
print(carRaceCollision(n: 49)) // 1176
print(carRaceCollision(n: 50)) // 1225
print(carRaceCollision(n: 51)) // 1275
print(carRaceCollision(n: 52)) // 
 // XCTAssertTrue failed

func carRaceCollision(n: Int) -> Int {
    return n * (n - 1) / 2
}
```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 {
    return n * (n - 1) / 2
}

print(carRaceCollision(n: 10))
print(carRaceCollision(n: 100))
print(carRaceCollision(n: 1000))
print(carRaceCollision(n: 10000))
print(carRaceCollision(n: 100000))
print(carRaceCollision(n: 1000000))
print(carRaceCollision(n: 10000000))
print(carRaceCollision(n: 100000000))
print(carRaceCollision(n: 1000000000))
print(carRaceCollision(n: 10000000000))
print(carRaceCollision(n: 100000000000))
print(carRaceCollision(n: 1000000000000))
print(carRaceCollision(n: 10000000000000))
print(carRaceCollision(n: 100000000000000))
print(carRaceCollision(n: 1000000000000000))
print(carRaceCollision(n: 10000000000000000))
print(carRaceCollision(n: 100000000000000000))
print(carRaceCollision(n: 1000000000000000000))

// Output:
// 45
// 4950
// 499500
// 49995000
// 4999950000
// 499999500000
// 49999995000000
// 4999999950000000
// 499999999500000000
// 49999999995000000000
// 4999999999950000000000
// 499999999999500000000000
// 49999999999995000000000000
// 4999999999999950000000000000
// 499999999999999500000000000000
// 49999999999999995000000000000000
// 4999999999999999950000000000000000
// 499999999999999999500000000000000000

// Time complexity: O(1)
// Space complexity: O(1)
```
 // XCTAssertTrue failed

func incrList(l: [Int]) -> [Int] {
    return []
}
```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 []
}
```
 // XCTAssertTrue failed

func incrList(l: [Int]) -> [Int] {
    return l.map { $0 + 1 }
}

func decrList(l: [Int]) -> [Int] {
    return l.map { $0 - 1 }
}

func doubleList(l: [Int]) -> [Int] {
    return l.map { $0 * 2 }
}

func halveList(l: [Int]) -> [Int] {
    return l.map { $0 / 2 }
}

func squareList(l: [Int]) -> [Int] {
    return l.map { $0 * $0 }
}

func cubeList(l: [Int]) -> [Int] {
    return l.map { $0 * $0 * $0 }
}

func powerList(l: [Int]) -> [Int] {
    return l.map { $0 * $0 * $0 * $0 }
}
```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 }
}

// Return array with elements decremented by 1.
// decrList(l: [1, 2, 3]) == [0, 1, 2]
// decrList(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [4, 2, 4, 1, 2, 2, 8, -1, 122]
func decrList(l: [Int]) -> [Int] {
    return l.map { $0 - 1 }
}

// Return array with elements multiplied by 2.
// doubleList(l: [1, 2, 3]) == [2, 4, 6]
// doubleList(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [10, 6, 10, 4, 6, 6, 18, 0, 246]
func doubleList(l: [Int]) -> [Int] {
    return l.map { $0 * 2 }
}

// Return array with elements divided by 2.
// halveList(l: [1, 2, 3]) == [0, 1, 1]
// halveList(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [2, 1, 2, 1, 1, 1, 4, 0, 61]
func halveList(l: [Int]) -> [Int] {
    return l.map { $0 / 2 }
}

// Return array with elements squared.
// squareList(l: [1, 2, 3]) == [1, 4, 9]
// squareList(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [25, 9, 25, 4, 9, 9, 81, 0, 15129]
func squareList(l: [Int]) -> [Int] {
    return l.map { $0 * $0 }
}

// Return array with elements cubed.
// cubeList(l: [1, 2, 3]) == [1, 8, 27]
// cubeList(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [125, 27, 125, 8, 27, 27, 729, 0, 1867703]
func cubeList(l: [Int]) -> [Int] {
    return l.map { $0 * $0 * $0 }
}

// Return array with elements raised to the power of 4.
// powerList(l: [1, 2, 3]) == [1, 16, 81]
// powerList(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [625, 81, 625, 16, 81, 81, 6561, 0, 1807209209]
func powerList(l: [Int]) -> [Int] {
    return l.map { $0 * $0 * $0 * $0 }
}

// Return array with elements raised to the power of 5.
// powerList(l: [1, 2, 3]) == [1, 32, 243]
// powerList(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [3125, 243, 3125, 32, 243, 243, 59049, 0, 768680945]
func powerList(l: [Int]) -> [Int] {
    

func incrList(l: [Int]) -> [Int] {
    // ...
}
```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] {
    // ...
}
```
} // missing return in global function expected to return '[Int]'

func incrList(l: [Int]) -> [Int] {
    // ...
}
```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] {
    // ...
}
```
} // missing return in global function expected to return '[Int]'

func incrList(l: [Int]) -> [Int] {
    return l.map { $0 + 1 }
}

func decrList(l: [Int]) -> [Int] {
    return l.map { $0 - 1 }
}

func doubleList(l: [Int]) -> [Int] {
    return l.map { $0 * 2 }
}

func halveList(l: [Int]) -> [Int] {
    return l.map { $0 / 2 }
}

func squareList(l: [Int]) -> [Int] {
    return l.map { $0 * $0 }
}

func cubeList(l: [Int]) -> [Int] {
    return l.map { $0 * $0 * $0 }
}

func powerList(l: [Int]) -> [Int] {
    return l.map { $0 * $0 * $0 * $0 }
}
```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 }
}

// Return array with elements decremented by 1.
// decrList(l: [1, 2, 3]) == [0, 1, 2]
// decrList(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [4, 2, 4, 1, 2, 2, 8, -1, 122]
func decrList(l: [Int]) -> [Int] {
    return l.map { $0 - 1 }
}

// Return array with elements multiplied by 2.
// doubleList(l: [1, 2, 3]) == [2, 4, 6]
// doubleList(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [10, 6, 10, 4, 6, 6, 18, 0, 246]
func doubleList(l: [Int]) -> [Int] {
    return l.map { $0 * 2 }
}

// Return array with elements divided by 2.
// halveList(l: [1, 2, 3]) == [0, 1, 1]
// halveList(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [2, 1, 2, 1, 1, 1, 4, 0, 61]
func halveList(l: [Int]) -> [Int] {
    return l.map { $0 / 2 }
}

// Return array with elements squared.
// squareList(l: [1, 2, 3]) == [1, 4, 9]
// squareList(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [25, 9, 25, 4, 9, 9, 81, 0, 15129]
func squareList(l: [Int]) -> [Int] {
    return l.map { $0 * $0 }
}

// Return array with elements cubed.
// cubeList(l: [1, 2, 3]) == [1, 8, 27]
// cubeList(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [125, 27, 125, 8, 27, 27, 729, 0, 1867703]
func cubeList(l: [Int]) -> [Int] {
    return l.map { $0 * $0 * $0 }
}

// Return array with elements raised to the power of 4.
// powerList(l: [1, 2, 3]) == [1, 16, 81]
// powerList(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [625, 81, 625, 16, 81, 81, 6561, 0, 180864609]
func powerList(l: [Int]) -> [Int] {
    return l.map { $0 * $0 * $0 * $0 }
}

// Return array with elements raised to the power of 5.
// powerList(l: [1, 2, 3]) == [1, 32, 243]
// powerList(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]) == [3125, 243, 3125, 32, 243, 243, 59049, 0, 7625597484987]
func powerList(l: [Int]) -> [Int]

func incrList(l: [Int]) -> [Int] {
    return []
}
```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 []
}
```
 // XCTAssertTrue failed

func incrList(l: [Int]) -> [Int] {
    // TODO: Implement
}
```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] {
    // TODO: Implement
}
```
} // missing return in global function expected to return '[Int]'

func incrList(l: [Int]) -> [Int] {
    // Your code here
}
```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] {
    // Your code here
}
```
} // missing return in global function expected to return '[Int]'

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] {
    var result = [Int]()
    for i in l {
        result.append(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 = [Int]()
    for i in l {
        result.append(i + 1)
    }
    return result
}

print(incrList(l: [1, 2, 3]))
print(incrList(l: [5, 3, 5, 2, 3, 3, 9, 0, 123]))
```

func pairsSumToZero(l: [Int]) -> Bool {
    // Your code goes here
}
```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 {
    // Your code goes here
}
```
} // missing return in global function expected to return 'Bool'

func pairsSumToZero(l: [Int]) -> Bool {
    var set = Set<Int>()
    for i in l {
        if set.contains(-i) {
            return true
        }
        set.insert(i)
    }
    return false
}

func repeat(s: String, n: Int) -> String {
    var result = ""
    for _ in 0..<n {
        result += s
    }
    return result
}

func removeDuplicates(s: String) -> String {
    var result = ""
    var set = Set<Character>()
    for c in s {
        if !set.contains(c) {
            result.append(c)
            set.insert(c)
        }
    }
    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 set = Set<Int>()
    for i in l {
        if set.contains(-i) {
            return true
        }
        set.insert(i)
    }
    return false
}

print(pairsSumToZero(l: [1, 3, 5, 0]))
print(pairsSumToZero(l: [1, 3, -2, 1]))
print(pairsSumToZero(l: [1, 2, 3, 7]))
print(pairsSumToZero(l: [2, 4, -5, 3, 5, 7]))
print(pairsSumToZero(l: [1]))

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

// Given a string s and an integer n, return a string that represents s
// repeated n times.
// repeat(s: "cat", n: 2) == "catcat"
// repeat(s: "cat", n: 0) == ""
// repeat(s: "cat", n: 3) == "catcatcat"
func repeat(s: String, n: Int) -> String {
    var result = ""
    for _ in 0..<n {
        result += s
    }
    return result
}

print(repeat(s: "cat", n: 2))
print(repeat(s: "cat", n: 0))
print(repeat(s: "cat", n: 3))

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

// Given a string s, return a new string that is s with any duplicate characters removed.
// removeDuplicates(s: "cat") == "cat"
// removeDuplicates(s: "caat") == "cat"
// removeDuplicates(s: "ccaat") == "cat"
func removeDuplicates(s: String) -> String {
    var result = ""
    var set = Set<Character>()
    for c in s {
        if !set.contains(c) {
            result.append(c)
            set.insert(c)
        }
    }
    return result
}

print(removeDuplicates(s: "cat"))
print(removeDuplicates(s: "caat"))
print(removeDuplicates(s: "ccaat"))

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

// Given a string s, return a new string that is s with any duplicate characters removed.
// removeDuplicates(s: "cat") == "cat"
// removeDuplicates(s: "caat") == "cat"
// removeDuplicates(s: "ccaat") == "cat"
func removeDuplicates(s: String) -> String {
    var result = ""
    var set = Set<Character>()
    for c in s {
        if !set.contains(c) {
            result.append(c)
            set.insert(c)
        }
    }
    return result
}

print(removeDuplicates(s: "cat"))
print(removeDuplicates(s: "caat"))
print(removeDuplicates(s: "ccaat"))

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

// Given a string s, return a new string that is s with any duplicate characters removed.
// removeDuplicates(s: "cat") == "cat"
// removeDuplicates(s: "caat") == "cat"
// removeDuplicates(s: "ccaat") == "cat"
func removeDuplicates(s: String) -> String {
    var result = ""
    var set = Set<Character>()
    for c in s {
        if !set.contains(c) {
            result.append(c)
            set.insert(c)
        }
    }
    return result
}

print(removeDup
func repeat(s: String, n: Int) -> String { // keyword 'repeat' cannot be used as an identifier here

func pairsSumToZero(l: [Int]) -> Bool {
    // Fill in the body of this function.
    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 {
    // Fill in the body of this function.
    return false
}
```
 // XCTAssertTrue failed

func pairsSumToZero(l: [Int]) -> Bool {
    // Fill in the body of this function.
}
```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 {
    // Fill in the body of this function.
}
```
} // missing return in global function expected to return 'Bool'

func pairsSumToZero(l: [Int]) -> Bool {
    // TODO: write your code here
    return false
}

func pairsSumToZeroSet(l: [Int]) -> Bool {
    // TODO: write your code here
    return false
}

func pairsSumToZeroSort(l: [Int]) -> Bool {
    // TODO: write your code here
    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 {
    // TODO: write your code here
    return false
}

// pairs_sum_to_zero_set 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 pairsSumToZeroSet(l: [Int]) -> Bool {
    // TODO: write your code here
    return false
}

// pairs_sum_to_zero_sort 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 pairsSumToZeroSort(l: [Int]) -> Bool {
    // TODO: write your code here
    return false
}

// pairs_sum_to_zero_sort 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 pairsSumToZeroSort(l: [Int]) -> Bool {
    // TODO: write your code here
    return false
}

// pairs_sum_to_zero_sort 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 pairsSumToZeroSort(l: [Int]) -> Bool {
    // TODO: write your code here
    return false
}

// pairs_sum_to_zero_sort 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 pairsSumToZeroSort(l: [Int]) -> Bool {
    // TODO: write your code here
    return false
}

// pairs_sum_to_zero_sort 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, 
 // XCTAssertTrue failed

func pairsSumToZero(l: [Int]) -> Bool {
    // TODO: write your code here
    return false
}

func pairsSumToZeroSet(l: [Int]) -> Bool {
    // TODO: write your code here
    return false
}

func pairsSumToZeroSort(l: [Int]) -> Bool {
    // TODO: write your code here
    return false
}

func pairsSumToZeroCount(l: [Int]) -> Bool {
    // TODO: write your code here
    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 {
    // TODO: write your code here
    return false
}

// pairs_sum_to_zero_set 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.
// pairsSumToZeroSet(l: [1, 3, 5, 0]) == false
// pairsSumToZeroSet(l: [1, 3, -2, 1]) == false
// pairsSumToZeroSet(l: [1, 2, 3, 7]) == false
// pairsSumToZeroSet(l: [2, 4, -5, 3, 5, 7]) == true
// pairsSumToZeroSet(l: [1]) == false
func pairsSumToZeroSet(l: [Int]) -> Bool {
    // TODO: write your code here
    return false
}

// pairs_sum_to_zero_sort 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.
// pairsSumToZeroSort(l: [1, 3, 5, 0]) == false
// pairsSumToZeroSort(l: [1, 3, -2, 1]) == false
// pairsSumToZeroSort(l: [1, 2, 3, 7]) == false
// pairsSumToZeroSort(l: [2, 4, -5, 3, 5, 7]) == true
// pairsSumToZeroSort(l: [1]) == false
func pairsSumToZeroSort(l: [Int]) -> Bool {
    // TODO: write your code here
    return false
}

// pairs_sum_to_zero_count 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.
// pairsSumToZeroCount(l: [1, 3, 5, 0]) == false
// pairsSumToZeroCount(l: [1, 3, -2, 1]) == false
// pairsSumToZeroCount(l: [1, 2, 3, 7]) == false
// pairsSumToZeroCount(l: [2, 4, -5, 3, 5, 7]) == true
// pairsSumToZeroCount(l: [1]) == false
func pairsSumToZeroCount(l: [Int]) -> Bool {
    // TODO: write your code here
    return false
}

// pairs_sum_to_zero_count 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.
// pairsSumToZeroCount(l: [1, 3, 5, 0]) == false
// pairsSumToZeroCount(l: [1, 3, -2, 1]) == false
// pairsSumToZeroCount(l: [1, 2, 3, 7]) == false
// pairsSumToZeroCount(l: [2, 4, -5, 3, 5, 7]) == true
// pairsSumToZeroCount(l: [1]) == false
func pairsSumToZeroCount(l: [Int]) -> Bool {
    // TODO: write your code here
    return false
}

// pairs_sum_to_zero_count 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.
// pairsSumToZeroCount(l: [1, 3, 5, 0]) == false
// pairsSumToZeroCount(l: [1, 3, -2, 1]) == false
// pairsSumToZeroCount(l: [1, 2, 3, 7]) == false
// pairsSumToZeroCount(l: [2, 4, -5, 3, 5, 7]) == true
// pairsSumToZeroCount(l: [1]) == false
func pairsSumToZeroCount(l: [Int]) -> Bool {
    // TODO: write your code here
    return false
}

// pairs_sum_to_zero_count takes an array of integers as an input.
// it returns true if there are two distinct elements in the
 // XCTAssertTrue failed

func pairsSumToZero(l: [Int]) -> Bool {
    // TODO: write your code here
    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 {
    // TODO: write your code here
    return false
}

print(pairsSumToZero(l: [1, 3, 5, 0]))
print(pairsSumToZero(l: [1, 3, -2, 1]))
print(pairsSumToZero(l: [1, 2, 3, 7]))
print(pairsSumToZero(l: [2, 4, -5, 3, 5, 7]))
print(pairsSumToZero(l: [1]))
```
 // XCTAssertTrue failed

func pairsSumToZero(l: [Int]) -> Bool {
    var set = Set<Int>()
    for i in l {
        if set.contains(-i) {
            return true
        }
        set.insert(i)
    }
    return false
}

func pairsSumToZeroSet(l: [Int]) -> Bool {
    var set = Set<Int>()
    for i in l {
        if set.contains(-i) {
            return true
        }
        set.insert(i)
    }
    return false
}

func pairsSumToZeroMap(l: [Int]) -> Bool {
    var map = [Int: Bool]()
    for i in l {
        if map[i] != nil {
            return true
        }
        map[i] = true
    }
    return false
}

func pairsSumToZeroMap2(l: [Int]) -> Bool {
    var map = [Int: Bool]()
    for i in l {
        if map[i] != nil {
            return true
        }
        map[i] = true
    }
    return false
}

func pairsSumToZeroMap3(l: [Int]) -> Bool {
    var map = [Int: Bool]()
    for i in l {
        if map[i] != nil {
            return true
        }
        map[i] = 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 {
    var set = Set<Int>()
    for i in l {
        if set.contains(-i) {
            return true
        }
        set.insert(i)
    }
    return false
}

// pairs_sum_to_zero_set 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.
// pairsSumToZeroSet(l: [1, 3, 5, 0]) == false
// pairsSumToZeroSet(l: [1, 3, -2, 1]) == false
// pairsSumToZeroSet(l: [1, 2, 3, 7]) == false
// pairsSumToZeroSet(l: [2, 4, -5, 3, 5, 7]) == true
// pairsSumToZeroSet(l: [1]) == false
func pairsSumToZeroSet(l: [Int]) -> Bool {
    var set = Set<Int>()
    for i in l {
        if set.contains(-i) {
            return true
        }
        set.insert(i)
    }
    return false
}

// pairs_sum_to_zero_map 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.
// pairsSumToZeroMap(l: [1, 3, 5, 0]) == false
// pairsSumToZeroMap(l: [1, 3, -2, 1]) == false
// pairsSumToZeroMap(l: [1, 2, 3, 7]) == false
// pairsSumToZeroMap(l: [2, 4, -5, 3, 5, 7]) == true
// pairsSumToZeroMap(l: [1]) == false
func pairsSumToZeroMap(l: [Int]) -> Bool {
    var map = [Int: Bool]()
    for i in l {
        if map[i] != nil {
            return true
        }
        map[i] = true
    }
    return false
}

// pairs_sum_to_zero_map_2 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.
// pairsSumToZeroMap2(l: [1, 3, 5, 0]) == false
// pairsSumToZeroMap2(l: [1, 3, -2, 1]) == false
// pairsSumToZeroMap2(l: [1, 2, 3, 7]) == false
// pairsSumToZeroMap2(l: [2, 4, -5, 3, 5, 7]) == true
// pairsSumToZeroMap2(l: [1]) == false
func pairsSumToZeroMap2(l: [Int]) -> Bool {
    var map = [Int: Bool]()
    for i in l {
        if map[i] != nil {
            return true
        }
        map[i] = true
    }
    return false
}

// pairs_sum_to_zero_map_3 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.
// pairsSumToZeroMap3(l: [1, 3, 5, 0]) == false
// pairsSumToZeroMap3(l: [1, 3, -2, 1]) == false
// pairsSumToZeroMap3(l: [1, 2, 3, 7]) == false
// pairsSumToZeroMap3(l: [2, 4, -5, 3, 5, 7]) == true
// pairsSumToZeroMap3(l: [1]) == false
func pairsSumToZeroMap3(l: [Int]) -> Bool {
    var map = [Int: Bool]()
    for i in l {
        if map[i] != nil {
            return true
        }
        map[i] = true
    }
    return false
}

// pairs_sum_to_zero_map_4 takes an array of integers as an input.

func pairsSumToZero(l: [Int]) -> Bool {
    // TODO: write your code here
    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 {
    // TODO: write your code here
    return false
}
```
 // XCTAssertTrue failed

func pairsSumToZero(l: [Int]) -> Bool {
    var set = Set<Int>()
    for i in l {
        if set.contains(-i) {
            return true
        }
        set.insert(i)
    }
    return false
}

func pairsSumToZeroSet(l: [Int]) -> Bool {
    var set = Set<Int>()
    for i in l {
        if set.contains(-i) {
            return true
        }
        set.insert(i)
    }
    return false
}

func pairsSumToZeroMap(l: [Int]) -> Bool {
    var map = [Int: Bool]()
    for i in l {
        if map[i] != nil {
            return true
        }
        map[i] = true
    }
    return false
}

func pairsSumToZeroMap2(l: [Int]) -> Bool {
    var map = [Int: Bool]()
    for i in l {
        if map[i] != nil {
            return true
        }
        map[i] = true
    }
    return false
}

func pairsSumToZeroMap3(l: [Int]) -> Bool {
    var map = [Int: Bool]()
    for i in l {
        if map[i] != nil {
            return true
        }
        map[i] = 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 {
    var set = Set<Int>()
    for i in l {
        if set.contains(-i) {
            return true
        }
        set.insert(i)
    }
    return false
}

// pairs_sum_to_zero_set 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.
// pairsSumToZeroSet(l: [1, 3, 5, 0]) == false
// pairsSumToZeroSet(l: [1, 3, -2, 1]) == false
// pairsSumToZeroSet(l: [1, 2, 3, 7]) == false
// pairsSumToZeroSet(l: [2, 4, -5, 3, 5, 7]) == true
// pairsSumToZeroSet(l: [1]) == false
func pairsSumToZeroSet(l: [Int]) -> Bool {
    var set = Set<Int>()
    for i in l {
        if set.contains(-i) {
            return true
        }
        set.insert(i)
    }
    return false
}

// pairs_sum_to_zero_map 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.
// pairsSumToZeroMap(l: [1, 3, 5, 0]) == false
// pairsSumToZeroMap(l: [1, 3, -2, 1]) == false
// pairsSumToZeroMap(l: [1, 2, 3, 7]) == false
// pairsSumToZeroMap(l: [2, 4, -5, 3, 5, 7]) == true
// pairsSumToZeroMap(l: [1]) == false
func pairsSumToZeroMap(l: [Int]) -> Bool {
    var map = [Int: Bool]()
    for i in l {
        if map[i] != nil {
            return true
        }
        map[i] = true
    }
    return false
}

// pairs_sum_to_zero_map_2 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.
// pairsSumToZeroMap2(l: [1, 3, 5, 0]) == false
// pairsSumToZeroMap2(l: [1, 3, -2, 1]) == false
// pairsSumToZeroMap2(l: [1, 2, 3, 7]) == false
// pairsSumToZeroMap2(l: [2, 4, -5, 3, 5, 7]) == true
// pairsSumToZeroMap2(l: [1]) == false
func pairsSumToZeroMap2(l: [Int]) -> Bool {
    var map = [Int: Bool]()
    for i in l {
        if map[i] != nil {
            return true
        }
        map[i] = true
    }
    return false
}

// pairs_sum_to_zero_map_3 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.
// pairsSumToZeroMap3(l: [1, 3, 5, 0]) == false
// pairsSumToZeroMap3(l: [1, 3, -2, 1]) == false
// pairsSumToZeroMap3(l: [1, 2, 3, 7]) == false
// pairsSumToZeroMap3(l: [2, 4, -5, 3, 5, 7]) == true
// pairsSumToZeroMap3(l: [1]) == false
func pairsSumToZeroMap3(l: [Int]) -> Bool {
    var map = [Int: Bool]()
    for i in l {
        if map[i] != nil {
            return true
        }
        map[i] = true
    }
    return false
}

// pairs_sum_to_zero_map_4 takes an array of integers as an input.

func changeBase(x: Int, base: Int) -> String {
    var result = ""
    var remainder = 0
    var quotient = x
    while quotient > 0 {
        remainder = quotient % base
        quotient = quotient / base
        result = String(remainder) + result
    }
    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 = 0
    var quotient = x
    while quotient > 0 {
        remainder = quotient % base
        quotient = quotient / base
        result = String(remainder) + result
    }
    return result
}

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

func changeBase(x: Int, base: Int) -> String {
    var result = ""
    var x = x
    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 = ""
    var x = x
    while x > 0 {
        result = String(x % base) + result
        x /= base
    }
    return result
}

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

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
}

print(changeBase(x: 8, base: 3))
print(changeBase(x: 8, base: 2))
print(changeBase(x: 7, base: 2))
```

func changeBase(x: Int, base: Int) -> String {
    var result = ""
    var number = x
    while number > 0 {
        result = String(number % base) + result
        number = 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 = number / base
    }
    return result
}

print(changeBase(x: 8, base: 3))
print(changeBase(x: 8, base: 2))
print(changeBase(x: 7, base: 2))
```

func changeBase(x: Int, base: Int) -> String {
    var result = ""
    var x = x
    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 = ""
    var x = x
    while x > 0 {
        result = String(x % base) + result
        x /= base
    }
    return result
}

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

func changeBase(x: Int, base: Int) -> String {
    var result = ""
    var num = x
    while num > 0 {
        result = String(num % base) + result
        num /= 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 num = x
    while num > 0 {
        result = String(num % base) + result
        num /= base
    }
    return result
}

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

func changeBase(x: Int, base: Int) -> String {
    var result = ""
    var num = x
    while num > 0 {
        result = String(num % base) + result
        num /= 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 num = x
    while num > 0 {
        result = String(num % base) + result
        num /= base
    }
    return result
}

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

func changeBase(x: Int, base: Int) -> String {
    var result = ""
    var temp = x
    while temp > 0 {
        result = String(temp % base) + result
        temp = temp / 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 temp = x
    while temp > 0 {
        result = String(temp % base) + result
        temp = temp / base
    }
    return result
}

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

func changeBase(x: Int, base: Int) -> String {
    var result = ""
    var num = x
    while num > 0 {
        result = String(num % base) + result
        num /= 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 num = x
    while num > 0 {
        result = String(num % base) + result
        num /= base
    }
    return result
}

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

func changeBase(x: Int, base: Int) -> String {
    var result = ""
    var remainder = 0
    var quotient = x
    while quotient > 0 {
        remainder = quotient % base
        quotient = quotient / base
        result = String(remainder) + result
    }
    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 = 0
    var quotient = x
    while quotient > 0 {
        remainder = quotient % base
        quotient = quotient / base
        result = String(remainder) + result
    }
    return result
}

// 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 = 0
    var quotient = x
    while quotient > 0 {
        remainder = quotient % base
        quotient = quotient / base
        result = String(remainder) + result
    }
    return result
}

// 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 = 0
    var quotient = x
    while quotient > 0 {
        remainder = quotient % base
        quotient = quotient / base
        result = String(remainder) + result
    }
    return result
}

// 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 = 0
    var quotient = x
    while quotient > 0 {
        remainder = quotient % base
        quotient = quotient / base
        result = String(remainder) + result
    }
    return result
}

// 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 = 0
    var quotient = x
    while quotient > 0 {
        remainder = quotient % base
        quotient = quotient / base
        result = String(remainder) + result
    }
    return result
}

// 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 = 0
    var quotient = x
    while quotient > 0 {
        remainder = quotient % base
        quotient = quotient / base
        result = String(remainder) + result
    }
    return result
}

// 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)

func triangleArea(a: Int, h: Int) -> Double {
    return Double(a) * Double(h) / 2
}

func triangleArea(a: Double, h: Double) -> Double {
    return a * h / 2
}

func triangleArea(a: Float, h: Float) -> Double {
    return Double(a) * Double(h) / 2
}

func triangleArea(a: Float, h: Double) -> Double {
    return a * h / 2
}

func triangleArea(a: Double, h: Float) -> Double {
    return a * h / 2
}

func triangleArea(a: Int, h: Float) -> Double {
    return Double(a) * Double(h) / 2
}

func triangleArea(a: Int, h: Double) -> Double {
    return Double(a) * Double(h) / 2
}

func triangleArea(a: Float, h: Int) -> Double {
    return Double(a) * Double(h) / 2
}

func triangleArea(a: Double, h: Int) -> Double {
    return a * Double(h) / 2
}

func triangleArea(a: Double, h: Float) -> Double {
    return a * Double(h) / 2
}

func triangleArea(a: Float, h: Double) -> Double {
    return Double(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 Double(a) * Double(h) / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Double, h: Double) -> Double {
    return a * h / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Float, h: Float) -> Double {
    return Double(a) * Double(h) / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Float, h: Double) -> Double {
    return a * h / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Double, h: Float) -> Double {
    return a * h / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Double, h: Double) -> Double {
    return a * h / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Float, h: Float) -> Double {
    return Double(a) * Double(h) / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Int, h: Float) -> Double {
    return Double(a) * Double(h) / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Int, h: Double) -> Double {
    return Double(a) * Double(h) / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Float, h: Int) -> Double {
    return Double(a) * Double(h) / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Double, h: Int) -> Double {
    return a * Double(h) / 2
}

// 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) * Double(h) / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Double, h: Float) -> Double {
    return a * Double(h) / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Float, h: Double) -> Double {
    return Double(a) * h / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Double, h: Double) -> Double {
    return a * h / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Float, h: Float) -> Double {
    return Double(a) * Double(h) / 2
}

// Given length of a side and high return
return a * h / 2 // cannot convert value of type 'Float' to expected argument type 'Double'
return a * h / 2 // cannot convert value of type 'Float' to expected argument type 'Double'
func triangleArea(a: Double, h: Float) -> Double { // invalid redeclaration of 'triangleArea(a:h:)'
func triangleArea(a: Float, h: Double) -> Double { // invalid redeclaration of 'triangleArea(a:h:)'

func triangleArea(a: Int, h: Int) -> Double {
    return Double(a) * Double(h) / 2
}

func triangleArea(a: Double, h: Double) -> 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 Double(a) * Double(h) / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Double, h: Double) -> Double {
    return a * h / 2
}
```

func triangleArea(a: Int, h: Int) -> Double {
    return Double(a) * Double(h) / 2
}

func triangleArea(a: Double, h: Double) -> Double {
    return a * h / 2
}

func triangleArea(a: Float, h: Float) -> Double {
    return Double(a) * Double(h) / 2
}

func triangleArea(a: Double, h: Int) -> Double {
    return a * Double(h) / 2
}

func triangleArea(a: Int, h: Double) -> Double {
    return Double(a) * h / 2
}

func triangleArea(a: Float, h: Int) -> Double {
    return Double(a) * Double(h) / 2
}

func triangleArea(a: Int, h: Float) -> Double {
    return Double(a) * Double(h) / 2
}

func triangleArea(a: Float, h: Double) -> Double {
    return Double(a) * h / 2
}

func triangleArea(a: Double, h: Float) -> Double {
    return a * Double(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 Double(a) * Double(h) / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Double, h: Double) -> Double {
    return a * h / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Float, h: Float) -> Double {
    return Double(a) * Double(h) / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Double, h: Int) -> Double {
    return a * Double(h) / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Int, h: Double) -> Double {
    return Double(a) * h / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Float, h: Int) -> Double {
    return Double(a) * Double(h) / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Int, h: Float) -> Double {
    return Double(a) * Double(h) / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Float, h: Double) -> Double {
    return Double(a) * h / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Double, h: Float) -> Double {
    return a * Double(h) / 2
}
```

func triangleArea(a: Int, h: Int) -> Double {
    return Double(a) * Double(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 Double(a) * Double(h) / 2
}
```

func triangleArea(a: Int, h: Int) -> Double {
    return Double(a) * Double(h) / 2
}

func squareArea(a: Int) -> Int {
    return a * a
}

func cubeArea(a: Int) -> Int {
    return a * a * a
}

func sphereArea(a: Int) -> Double {
    return Double(a) * Double(a) * Double.pi * 4
}

func cylinderArea(a: Int, h: Int) -> Double {
    return Double(a) * Double(a) * Double.pi * 2 + Double(a) * Double.pi * Double(h) * 2
}

func coneArea(a: Int, h: Int) -> Double {
    return Double(a) * Double(a) * Double.pi + Double(a) * Double.pi * Double(h)
}

func pyramidArea(a: Int, h: Int) -> Int {
    return a * a + a * h * 2
}

func tetrahedronArea(a: Int) -> Double {
    return Double(a) * Double(a) * sqrt(3)
}

func octahedronArea(a: Int) -> Double {
    return Double(a) * Double(a) * sqrt(3) * 2
}

func dodecahedronArea(a: Int) -> Double {
    return Double(a) * Double(a) * sqrt(26) * 3
}

func icosahedronArea(a: Int) -> Double {
    return Double(a) * Double(a) * sqrt(30) * 3
}

func hexahedronArea(a: Int) -> Int {
    return a * a * 6
}

func heptahedronArea(a: Int) -> Double {
    return Double(a) * Double(a) * sqrt(70) * 4
}
```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) * Double(h) / 2
}

// Given length of a side return area for a square.
// squareArea(a: 5) == 25
func squareArea(a: Int) -> Int {
    return a * a
}

// Given length of a side return area for a cube.
// cubeArea(a: 5) == 125
func cubeArea(a: Int) -> Int {
    return a * a * a
}

// Given length of a side return area for a sphere.
// sphereArea(a: 5) == 314.1592653589793
func sphereArea(a: Int) -> Double {
    return Double(a) * Double(a) * Double.pi * 4
}

// Given length of a side return area for a cylinder.
// cylinderArea(a: 5, h: 3) == 282.74333882308138
func cylinderArea(a: Int, h: Int) -> Double {
    return Double(a) * Double(a) * Double.pi * 2 + Double(a) * Double.pi * Double(h) * 2
}

// Given length of a side return area for a cone.
// coneArea(a: 5, h: 3) == 157.07963267948966
func coneArea(a: Int, h: Int) -> Double {
    return Double(a) * Double(a) * Double.pi + Double(a) * Double.pi * Double(h)
}

// Given length of a side return area for a pyramid.
// pyramidArea(a: 5, h: 3) == 35
func pyramidArea(a: Int, h: Int) -> Int {
    return a * a + a * h * 2
}

// Given length of a side return area for a tetrahedron.
// tetrahedronArea(a: 5) == 43.30127018922193
func tetrahedronArea(a: Int) -> Double {
    return Double(a) * Double(a) * sqrt(3)
}

// Given length of a side return area for a octahedron.
// octahedronArea(a: 5) == 115.47005383792515
func octahedronArea(a: Int) -> Double {
    return Double(a) * Double(a) * sqrt(3) * 2
}

// Given length of a side return area for a dodecahedron.
// dodecahedronArea(a: 5) == 319.4807752189385
func dodecahedronArea(a: Int) -> Double {
    return Double(a) * Double(a) * sqrt(26) * 3
}

// Given length of a side return area for a icosahedron.
// icosahedronArea(a: 5) == 319.4807752189385
func icosahedronArea(a: Int) -> Double {
    return Double(a) * Double(a) * sqrt(30) * 3
}

// Given length of a side return area for a hexahedron.
// hexahedronArea(a: 5) == 150
func hexahedronArea(a: Int) -> Int {
    return a * a * 6
}

// Given length of a side return area for a heptahedron.
// heptahedronArea(a: 5) == 208.8481828341595
func heptahedronArea(a: Int) -> Double {
    return Double(a) * Double(a) * sqrt(70) * 4
}

// Given length of a side return area for a octahedron.
// octahedronArea(a: 5) == 115.47005383792515
func octahedronArea(a: Int) -> Double {
    return Double(a) * Double(a) * sqrt(3) * 2
}

// Given length of a side return area

func triangleArea(a: Int, h: Int) -> Double {
    return Double(a) * Double(h) / 2
}

func triangleArea(a: Double, h: Double) -> Double {
    return a * h / 2
}

func triangleArea(a: Float, h: Float) -> Double {
    return Double(a) * Double(h) / 2
}

func triangleArea(a: CGFloat, h: CGFloat) -> Double {
    return Double(a) * Double(h) / 2
}

func triangleArea(a: UInt, h: UInt) -> Double {
    return Double(a) * Double(h) / 2
}

func triangleArea(a: UInt8, h: UInt8) -> Double {
    return Double(a) * Double(h) / 2
}

func triangleArea(a: UInt16, h: UInt16) -> Double {
    return Double(a) * Double(h) / 2
}

func triangleArea(a: UInt32, h: UInt32) -> Double {
    return Double(a) * Double(h) / 2
}

func triangleArea(a: UInt64, h: UInt64) -> Double {
    return Double(a) * Double(h) / 2
}

func triangleArea(a: UIntPtr, h: UIntPtr) -> Double {
    return Double(a) * Double(h) / 2
}

func triangleArea(a: Int8, h: Int8) -> Double {
    return Double(a) * Double(h) / 2
}

func triangleArea(a: Int16, h: Int16) -> Double {
    return Double(a) * Double(h) / 2
}

func triangleArea(a: Int32, h: Int32) -> Double {
    return Double(a) * Double(h) / 2
}

func triangleArea(a: Int64, h: Int64) -> Double {
    return Double(a) * Double(h) / 2
}

func triangleArea(a: IntPtr, h: IntPtr) -> Double {
    return Double(a) * Double(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 Double(a) * Double(h) / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Double, h: Double) -> Double {
    return a * h / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Float, h: Float) -> Double {
    return Double(a) * Double(h) / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: CGFloat, h: CGFloat) -> Double {
    return Double(a) * Double(h) / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: UInt, h: UInt) -> Double {
    return Double(a) * Double(h) / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: UInt8, h: UInt8) -> Double {
    return Double(a) * Double(h) / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: UInt16, h: UInt16) -> Double {
    return Double(a) * Double(h) / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: UInt32, h: UInt32) -> Double {
    return Double(a) * Double(h) / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: UInt64, h: UInt64) -> Double {
    return Double(a) * Double(h) / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: UIntPtr, h: UIntPtr) -> Double {
    return Double(a) * Double(h) / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Int8, h: Int8) -> Double {
    return Double(a) * Double(h) / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Int16, h: Int16) -> Double {
    return Double(a) * Double(h) / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Int32, h: Int32) -> Double {
    return Double(a) * Double(h) / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Int64, h: Int64) -> Double {
    return Double(a) * Double(h) / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: IntPtr, h: IntPtr) -> Double {
    return Double(a) * Double(h) / 2
}
func triangleArea(a: UIntPtr, h: UIntPtr) -> Double { // cannot find type 'UIntPtr' in scope
func triangleArea(a: UIntPtr, h: UIntPtr) -> Double { // cannot find type 'UIntPtr' in scope
func triangleArea(a: IntPtr, h: IntPtr) -> Double { // cannot find type 'IntPtr' in scope
func triangleArea(a: IntPtr, h: IntPtr) -> Double { // cannot find type 'IntPtr' in scope

func triangleArea(a: Int, h: Int) -> Double {
    return Double(a) * Double(h) / 2
}

func triangleArea(a: Double, h: Double) -> Double {
    return a * h / 2
}

func triangleArea(a: Float, h: Float) -> Double {
    return Double(a) * Double(h) / 2
}

func triangleArea(a: CGFloat, h: CGFloat) -> Double {
    return Double(a) * Double(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 Double(a) * Double(h) / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Double, h: Double) -> Double {
    return a * h / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Float, h: Float) -> Double {
    return Double(a) * Double(h) / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: CGFloat, h: CGFloat) -> Double {
    return Double(a) * Double(h) / 2
}
```

func triangleArea(a: Int, h: Int) -> Double {
    return Double(a) * Double(h) / 2
}

func triangleArea(a: Double, h: Double) -> Double {
    return a * h / 2
}

func triangleArea(a: Float, h: Float) -> Double {
    return Double(a) * Double(h) / 2
}

func triangleArea(a: CGFloat, h: CGFloat) -> Double {
    return Double(a) * Double(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 Double(a) * Double(h) / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Double, h: Double) -> Double {
    return a * h / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: Float, h: Float) -> Double {
    return Double(a) * Double(h) / 2
}

// Given length of a side and high return area for a triangle.
// triangleArea(a: 5, h: 3) == 7.5
func triangleArea(a: CGFloat, h: CGFloat) -> Double {
    return Double(a) * Double(h) / 2
}
```

func triangleArea(a: Int, h: Int) -> Double {
    return Double(a) * Double(h) / 2
}

func squareArea(a: Int) -> Int {
    return a * a
}

func cubeArea(a: Int) -> Int {
    return a * a * a
}

func sphereArea(a: Int) -> Double {
    return Double(a) * Double(a) * Double.pi * 4
}

func cylinderArea(a: Int, h: Int) -> Double {
    return Double(a) * Double(a) * Double.pi * 2 + Double(a) * Double.pi * Double(h) * 2
}

func coneArea(a: Int, h: Int) -> Double {
    return Double(a) * Double(a) * Double.pi + Double(a) * Double.pi * sqrt(Double(a) * Double(a) + Double(h) * Double(h))
}

func pyramidArea(a: Int, h: Int) -> Int {
    return a * a + 2 * a * Int(sqrt(Double(a) * Double(a) + Double(h) * Double(h)))
}

func tetrahedronArea(a: Int) -> Double {
    return sqrt(3) * Double(a) * Double(a)
}

func octahedronArea(a: Int) -> Double {
    return sqrt(3) * Double(a) * Double(a) * 2
}

func dodecahedronArea(a: Int) -> Double {
    return sqrt(25 + 10 * sqrt(5)) * Double(a) * Double(a)
}

func icosahedronArea(a: Int) -> Double {
    return sqrt(3) * Double(a) * Double(a) * 5
}

func hexahedronArea(a: Int) -> Int {
    return a * a * 6
}

func heptahedronArea(a: Int) -> Double {
    return sqrt(70) * Double(a) * Double(a)
}
```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) * Double(h) / 2
}

// Given length of a side return area for a square.
// squareArea(a: 5) == 25
func squareArea(a: Int) -> Int {
    return a * a
}

// Given length of a side return area for a cube.
// cubeArea(a: 5) == 125
func cubeArea(a: Int) -> Int {
    return a * a * a
}

// Given length of a side return area for a sphere.
// sphereArea(a: 5) == 314.1592653589793
func sphereArea(a: Int) -> Double {
    return Double(a) * Double(a) * Double.pi * 4
}

// Given length of a side return area for a cylinder.
// cylinderArea(a: 5, h: 3) == 282.7433388230814
func cylinderArea(a: Int, h: Int) -> Double {
    return Double(a) * Double(a) * Double.pi * 2 + Double(a) * Double.pi * Double(h) * 2
}

// Given length of a side return area for a cone.
// coneArea(a: 5, h: 3) == 157.07963267948966
func coneArea(a: Int, h: Int) -> Double {
    return Double(a) * Double(a) * Double.pi + Double(a) * Double.pi * sqrt(Double(a) * Double(a) + Double(h) * Double(h))
}

// Given length of a side return area for a pyramid.
// pyramidArea(a: 5, h: 3) == 50
func pyramidArea(a: Int, h: Int) -> Int {
    return a * a + 2 * a * Int(sqrt(Double(a) * Double(a) + Double(h) * Double(h)))
}

// Given length of a side return area for a tetrahedron.
// tetrahedronArea(a: 5) == 43.30127018922193
func tetrahedronArea(a: Int) -> Double {
    return sqrt(3) * Double(a) * Double(a)
}

// Given length of a side return area for a octahedron.
// octahedronArea(a: 5) == 170.71067811865475
func octahedronArea(a: Int) -> Double {
    return sqrt(3) * Double(a) * Double(a) * 2
}

// Given length of a side return area for a dodecahedron.
// dodecahedronArea(a: 5) == 339.6928830599999
func dodecahedronArea(a: Int) -> Double {
    return sqrt(25 + 10 * sqrt(5)) * Double(a) * Double(a)
}

// Given length of a side return area for a icosahedron.
// icosahedronArea(a: 5) == 305.3285946617978
func icosahedronArea(a: Int) -> Double {
    return sqrt(3) * Double(a) * Double(a) * 5
}

// Given length of a side return area for a hexahedron.
// hexahedronArea(a: 5) == 150
func hexahedronArea(a: Int) -> Int {
    return a * a * 6
}

// Given length of a side return area for a heptahedron.
// heptahedronArea(a: 5) == 211.4213562373095
func heptahedronArea(a: Int) -> Double {
    return sqrt(70) * Double(a) * Double(a)
}

// Given length of a side return area for a octahedron.
// octahedronArea(a: 5) == 170.71067811865475
func octahedronArea(

func triangleArea(a: Int, h: Int) -> Double {
    return Double(a) * Double(h) / 2
}

func squareArea(a: Int) -> Int {
    return a * a
}

func cubeArea(a: Int) -> Int {
    return a * a * a
}

func sphereArea(a: Int) -> Double {
    return Double(a) * Double(a) * Double.pi * 4
}

func cylinderArea(a: Int, h: Int) -> Double {
    return Double(a) * Double(a) * Double.pi * 2 + Double(a) * Double(h) * Double.pi * 2
}

func coneArea(a: Int, h: Int) -> Double {
    return Double(a) * Double(a) * Double.pi + Double(a) * Double.sqrt(Double(a) * Double(a) + Double(h) * Double(h)) * Double.pi
}

func pyramidArea(a: Int, h: Int) -> Double {
    return Double(a) * Double(a) + Double(a) * Double.sqrt(Double(a) * Double(a) + Double(h) * Double(h)) * 2
}

func tetrahedronArea(a: Int) -> Double {
    return Double(a) * Double(a) * Double.sqrt(3)
}

func octahedronArea(a: Int) -> Double {
    return Double(a) * Double(a) * Double.sqrt(3) * 2
}

func dodecahedronArea(a: Int) -> Double {
    return Double(a) * Double(a) * Double.sqrt(3) * 5
}

func icosahedronArea(a: Int) -> Double {
    return Double(a) * Double(a) * Double.sqrt(3) * 10
}

func hexahedronArea(a: Int) -> Double {
    return Double(a) * Double(a) * 6
}

func heptahedronArea(a: Int) -> Double {
    return Double(a) * Double(a) * Double.sqrt(7) * 7
}
```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) * Double(h) / 2
}

// Given length of a side return area for a square.
// squareArea(a: 5) == 25
func squareArea(a: Int) -> Int {
    return a * a
}

// Given length of a side return area for a cube.
// cubeArea(a: 5) == 125
func cubeArea(a: Int) -> Int {
    return a * a * a
}

// Given length of a side return area for a sphere.
// sphereArea(a: 5) == 314.1592653589793
func sphereArea(a: Int) -> Double {
    return Double(a) * Double(a) * Double.pi * 4
}

// Given length of a side return area for a cylinder.
// cylinderArea(a: 5, h: 3) == 282.74333882308138
func cylinderArea(a: Int, h: Int) -> Double {
    return Double(a) * Double(a) * Double.pi * 2 + Double(a) * Double(h) * Double.pi * 2
}

// Given length of a side return area for a cone.
// coneArea(a: 5, h: 3) == 157.07963267948966
func coneArea(a: Int, h: Int) -> Double {
    return Double(a) * Double(a) * Double.pi + Double(a) * Double.sqrt(Double(a) * Double(a) + Double(h) * Double(h)) * Double.pi
}

// Given length of a side return area for a pyramid.
// pyramidArea(a: 5, h: 3) == 135.0
func pyramidArea(a: Int, h: Int) -> Double {
    return Double(a) * Double(a) + Double(a) * Double.sqrt(Double(a) * Double(a) + Double(h) * Double(h)) * 2
}

// Given length of a side return area for a tetrahedron.
// tetrahedronArea(a: 5) == 43.30127018922193
func tetrahedronArea(a: Int) -> Double {
    return Double(a) * Double(a) * Double.sqrt(3)
}

// Given length of a side return area for a octahedron.
// octahedronArea(a: 5) == 150.0
func octahedronArea(a: Int) -> Double {
    return Double(a) * Double(a) * Double.sqrt(3) * 2
}

// Given length of a side return area for a dodecahedron.
// dodecahedronArea(a: 5) == 328.7469395182824
func dodecahedronArea(a: Int) -> Double {
    return Double(a) * Double(a) * Double.sqrt(3) * 5
}

// Given length of a side return area for a icosahedron.
// icosahedronArea(a: 5) == 572.4542442670434
func icosahedronArea(a: Int) -> Double {
    return Double(a) * Double(a) * Double.sqrt(3) * 10
}

// Given length of a side return area for a hexahedron.
// hexahedronArea(a: 5) == 150.0
func hexahedronArea(a: Int) -> Double {
    return Double(a) * Double(a) * 6
}

// Given length of a side return area for a heptahedron.
// heptahedronArea(a: 5) == 217.8885001682617
func heptahedronArea(a: Int) -> Double {
    return Double(a) * Double(a) * Double.sqrt(7) * 7
}

// Given length of a side return area for a octahedron.
// octahedronArea(a: 5) == 150.0
func oct

func fib4(n: Int) -> Int {
    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 {
    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]
}

print(fib4(n: 5))
print(fib4(n: 6))
print(fib4(n: 7))

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

func fib4(n: Int) -> Int {
    // your code here
}
```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 {
    // your code here
}
```
} // missing return in global function expected to return 'Int'

func fib4(n: Int) -> Int {
    // Your code here
}
```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 {
    // Your code here
}
```
} // missing return in global function expected to return 'Int'

func fib4(n: Int) -> Int {
    if n < 0 {
        return 0
    }
    if n == 0 || n == 1 {
        return 0
    }
    if n == 2 {
        return 2
    }
    if n == 3 {
        return 0
    }
    var fib4 = [Int](repeating: 0, count: n + 1)
    fib4[2] = 2
    for i in 4...n {
        fib4[i] = 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 == 0 || n == 1 {
        return 0
    }
    if n == 2 {
        return 2
    }
    if n == 3 {
        return 0
    }
    var fib4 = [Int](repeating: 0, count: n + 1)
    fib4[2] = 2
    for i in 4...n {
        fib4[i] = fib4[i - 1] + fib4[i - 2] + fib4[i - 3] + fib4[i - 4]
    }
    return fib4[n]
}

print(fib4(n: 5))
print(fib4(n: 6))
print(fib4(n: 7))
print(fib4(n: 8))
print(fib4(n: 9))
print(fib4(n: 10))
print(fib4(n: 11))
print(fib4(n: 12))
print(fib4(n: 13))
print(fib4(n: 14))
print(fib4(n: 15))
print(fib4(n: 16))
print(fib4(n: 17))
print(fib4(n: 18))
print(fib4(n: 19))
print(fib4(n: 20))
print(fib4(n: 21))
print(fib4(n: 22))
print(fib4(n: 23))
print(fib4(n: 24))
print(fib4(n: 25))
print(fib4(n: 26))
print(fib4(n: 27))
print(fib4(n: 28))
print(fib4(n: 29))
print(fib4(n: 30))
print(fib4(n: 31))
print(fib4(n: 32))
print(fib4(n: 33))
print(fib4(n: 34))
print(fib4(n: 35))
print(fib4(n: 36))
print(fib4(n: 37))
print(fib4(n: 38))
print(fib4(n: 39))
print(fib4(n: 40))
print(fib4(n: 41))
print(fib4(n: 42))
print(fib4(n: 43))
print(fib4(n: 44))
print(fib4(n: 45))
print(fib4(n: 46))
print(fib4(n: 47))
print(fib4(n: 48))
print(fib4(n: 49))
print(fib4(n: 50))
print(fib4(n: 51))
print(fib4(n: 52))
print(fib4(n: 53))
print(fib4(n: 54))
print(fib4(n: 55))
print(fib4(n: 56))
print(fib4(n: 57))
print(fib4(n: 58))
print(fib4(n: 59))
print(fib4(n: 60))
print(fib4(n: 61))
print(fib4(n: 62))
print(fib4(n: 63))
print(fib4(n: 64))
print(fib4(n: 65))
print(fib4(n: 66))
print(fib4(n: 67))
print(fib4(n: 68))
print(fib4(n: 69))
print(fib4(n: 70))
print(fib4(n: 71))
print(fib4(n: 72))
print(fib4(n: 73))
print(fib4(n: 74))
print(fib4(n: 75))
print(fib4(

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 {
        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
    } else if n == 1 {
        return 0
    } else if n == 2 {
        return 2
    } else if n == 3 {
        return 0
    } else {
        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]
    }
}

print(fib4(n: 5))
print(fib4(n: 6))
print(fib4(n: 7))
print(fib4(n: 8))
print(fib4(n: 9))
print(fib4(n: 10))
print(fib4(n: 11))
print(fib4(n: 12))
print(fib4(n: 13))
print(fib4(n: 14))
print(fib4(n: 15))
print(fib4(n: 16))
print(fib4(n: 17))
print(fib4(n: 18))
print(fib4(n: 19))
print(fib4(n: 20))
print(fib4(n: 21))
print(fib4(n: 22))
print(fib4(n: 23))
print(fib4(n: 24))
print(fib4(n: 25))
print(fib4(n: 26))
print(fib4(n: 27))
print(fib4(n: 28))
print(fib4(n: 29))
print(fib4(n: 30))
print(fib4(n: 31))
print(fib4(n: 32))
print(fib4(n: 33))
print(fib4(n: 34))
print(fib4(n: 35))
print(fib4(n: 36))
print(fib4(n: 37))
print(fib4(n: 38))
print(fib4(n: 39))
print(fib4(n: 40))
print(fib4(n: 41))
print(fib4(n: 42))
print(fib4(n: 43))
print(fib4(n: 44))
print(fib4(n: 45))
print(fib4(n: 46))
print(fib4(n: 47))
print(fib4(n: 48))
print(fib4(n: 49))
print(fib4(n: 50))
print(fib4(n: 51))
print(fib4(n: 52))
print(fib4(n: 53))
print(fib4(n: 54))
print(fib4(n: 55))
print(fib4(n: 56))
print(fib4(n: 57))
print(fib4(n: 58))
print(fib4(n: 59))
print(fib4(n: 60))
print(fib4(n: 61))
print(fib4(n: 62))
print(fib4(n: 63))
print(fib4(n: 64))
print(fib4(n: 65))
print(fib4(n: 66))
print(fib4(n: 67))
print(fib4(n: 68))
print(fib4(n: 69))
print(fib4(n: 70))
print(fib4(n: 71))
print(fib4(n: 72))
print(fib4(n: 73))
print(fib4(n: 74))
print(fib4(n: 75))
print(fib4(n: 76))
print(fib4(n: 77))
print(fib4

func fib4(n: Int) -> Int {
    if n < 0 { return 0 }
    if n == 0 { return 0 }
    if n == 1 { return 0 }
    if n == 2 { return 2 }
    if n == 3 { return 0 }

    var a = 0
    var b = 0
    var c = 2
    var d = 0

    for _ in 4...n {
        let temp = a + b + c + d
        a = b
        b = c
        c = d
        d = temp
    }

    return d
}
```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 == 0 { return 0 }
    if n == 1 { return 0 }
    if n == 2 { return 2 }
    if n == 3 { return 0 }

    var a = 0
    var b = 0
    var c = 2
    var d = 0

    for _ in 4...n {
        let temp = a + b + c + d
        a = b
        b = c
        c = d
        d = temp
    }

    return d
}

print(fib4(n: 5))
print(fib4(n: 6))
print(fib4(n: 7))
```

func fib4(n: Int) -> Int {
    // TODO: Implement
    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 {
    // TODO: Implement
    return 0
}
```
 // XCTAssertTrue failed

func fib4(n: Int) -> Int {
    if n < 0 {
        return 0
    }
    if n == 0 || 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 == 0 || 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]
}

print(fib4(n: 5))
print(fib4(n: 6))
print(fib4(n: 7))
print(fib4(n: 8))
print(fib4(n: 9))
print(fib4(n: 10))
print(fib4(n: 11))
print(fib4(n: 12))
print(fib4(n: 13))
print(fib4(n: 14))
print(fib4(n: 15))
print(fib4(n: 16))
print(fib4(n: 17))
print(fib4(n: 18))
print(fib4(n: 19))
print(fib4(n: 20))
print(fib4(n: 21))
print(fib4(n: 22))
print(fib4(n: 23))
print(fib4(n: 24))
print(fib4(n: 25))
print(fib4(n: 26))
print(fib4(n: 27))
print(fib4(n: 28))
print(fib4(n: 29))
print(fib4(n: 30))
print(fib4(n: 31))
print(fib4(n: 32))
print(fib4(n: 33))
print(fib4(n: 34))
print(fib4(n: 35))
print(fib4(n: 36))
print(fib4(n: 37))
print(fib4(n: 38))
print(fib4(n: 39))
print(fib4(n: 40))
print(fib4(n: 41))
print(fib4(n: 42))
print(fib4(n: 43))
print(fib4(n: 44))
print(fib4(n: 45))
print(fib4(n: 46))
print(fib4(n: 47))
print(fib4(n: 48))
print(fib4(n: 49))
print(fib4(n: 50))
print(fib4(n: 51))
print(fib4(n: 52))
print(fib4(n: 53))
print(fib4(n: 54))
print(fib4(n: 55))
print(fib4(n: 56))
print(fib4(n: 57))
print(fib4(n: 58))
print(fib4(n: 59))
print(fib4(n: 60))
print(fib4(n: 61))
print(fib4(n: 62))
print(fib4(n: 63))
print(fib4(n: 64))
print(fib4(n: 65))
print(fib4(n: 66))
print(fib4(n: 67))
print(fib4(n: 68))
print(fib4(n: 69))
print(fib4(n: 70))
print(fib4(n: 71))
print(fib4(n: 72))
print(fib4(n: 73))
print(fib4(n: 74))
print(fib4(n: 75))
print(fib4(n: 76))
print(fib4(n: 7

func fib4(n: Int) -> Int {
    // TODO: Implement this function
    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 {
    // TODO: Implement this function
    return 0
}
```
 // XCTAssertTrue failed

func fib4(n: Int) -> Int {
    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 {
    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]
}

print(fib4(n: 5))
print(fib4(n: 6))
print(fib4(n: 7))
```

func median(l: [Int]) -> Double {
    // ...
}
```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 {
    // ...
}
```
} // missing return in global function expected to return 'Double'

func median(l: [Int]) -> Double {
    // TODO: Implement
}
```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 {
    // TODO: Implement
}
```
} // missing return in global function expected to return 'Double'

func median(l: [Int]) -> Double {
    // ...
}
```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 {
    // ...
}
```
} // missing return in global function expected to return 'Double'

func median(l: [Int]) -> Double {
    // TODO: Implement this function
}
```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 {
    // TODO: Implement this function
}
```
} // missing return in global function expected to return 'Double'

func median(l: [Int]) -> Double {
    // TODO: Implement
}
```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 {
    // TODO: Implement
}
```
} // missing return in global function expected to return 'Double'

func median(l: [Int]) -> Double {
    // TODO: implement
}
```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 {
    // TODO: implement
}
```
} // missing return in global function expected to return 'Double'

func median(l: [Int]) -> Double {
    // ...
}
```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 {
    // ...
}
```
} // missing return in global function expected to return 'Double'

func median(l: [Int]) -> Double {
    // ...
}
```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 {
    // ...
}
```
} // missing return in global function expected to return 'Double'

func median(l: [Int]) -> Double {
    // TODO: Implement this function
    return 0
}
```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 {
    // TODO: Implement this function
    return 0
}
```
 // XCTAssertTrue failed

func median(l: [Int]) -> Double {
    // TODO: Implement
    return 0.0
}
```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 {
    // TODO: Implement
    return 0.0
}
```
 // XCTAssertTrue failed

func isPalindrome(text: String) -> Bool {
    // write your code here
}
```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 {
    // write your code here
}
```
} // missing return in global function expected to return 'Bool'

func isPalindrome(text: String) -> Bool {
    // write your code here
}
```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 {
    // write your code here
}
```
} // missing return in global function expected to return 'Bool'

func isPalindrome(text: String) -> Bool {
    // write your code here
}
```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 {
    // write your code here
}
```
} // missing return in global function expected to return 'Bool'

func isPalindrome(text: String) -> Bool {
    // write your code here
}
```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 {
    // write your code here
}
```
} // missing return in global function expected to return 'Bool'

func isPalindrome(text: String) -> Bool {
    // write your code here
}
```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 {
    // write your code here
}
```
} // missing return in global function expected to return 'Bool'

func isPalindrome(text: String) -> Bool {
    // write your code here
}
```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 {
    // write your code here
}
```
} // missing return in global function expected to return 'Bool'

func isPalindrome(text: String) -> Bool {
    var text = text
    var isPalindrome = true
    for index in 0..<text.count/2 {
        if text[index] != text[text.count - index - 1] {
            isPalindrome = false
            break
        }
    }
    return isPalindrome
}
```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 text = text
    var isPalindrome = true
    for index in 0..<text.count/2 {
        if text[index] != text[text.count - index - 1] {
            isPalindrome = false
            break
        }
    }
    return isPalindrome
}

print(isPalindrome(text: ""))
print(isPalindrome(text: "aba"))
print(isPalindrome(text: "aaaaa"))
print(isPalindrome(text: "zbcd"))
```
var text = text // variable 'text' was never mutated; consider changing to 'let' constant
if text[index] != text[text.count - index - 1] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.
if text[index] != text[text.count - index - 1] { // 'subscript(_:)' is unavailable: cannot subscript String with an Int, use a String.Index instead.

func isPalindrome(text: String) -> Bool {
    // write your code here
}
```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 {
    // write your code here
}
```
} // missing return in global function expected to return 'Bool'

func isPalindrome(text: String) -> Bool {
    // write your code here
}
```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 {
    // write your code here
}
```
} // missing return in global function expected to return 'Bool'

func isPalindrome(text: String) -> Bool {
    var reversed = ""
    for letter in text {
        reversed = String(letter) + reversed
    }
    return 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 {
    var reversed = ""
    for letter in text {
        reversed = String(letter) + reversed
    }
    return reversed == text
}

print(isPalindrome(text: ""))
print(isPalindrome(text: "aba"))
print(isPalindrome(text: "aaaaa"))
print(isPalindrome(text: "zbcd"))
```

func modp(n: Int, p: Int) -> Int {
    var res = 1
    var a = 2
    while n > 0 {
        if n % 2 == 1 {
            res = (res * a) % p
        }
        a = (a * a) % p
        n /= 2
    }
    return res
}
```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 {
    var res = 1
    var a = 2
    while n > 0 {
        if n % 2 == 1 {
            res = (res * a) % p
        }
        a = (a * a) % p
        n /= 2
    }
    return res
}

// Return true if n is prime.
// isPrime(n: 2) == true
// isPrime(n: 3) == true
// isPrime(n: 4) == false
// isPrime(n: 5) == true
// isPrime(n: 6) == false
// isPrime(n: 7) == true
// isPrime(n: 8) == false
// isPrime(n: 9) == false
// isPrime(n: 10) == false
// isPrime(n: 11) == true
// isPrime(n: 12) == false
// isPrime(n: 13) == true
// isPrime(n: 14) == false
// isPrime(n: 15) == false
// isPrime(n: 16) == false
// isPrime(n: 17) == true
// isPrime(n: 18) == false
// isPrime(n: 19) == true
// isPrime(n: 20) == false
// isPrime(n: 21) == false
// isPrime(n: 22) == false
// isPrime(n: 23) == true
// isPrime(n: 24) == false
// isPrime(n: 25) == false
// isPrime(n: 26) == false
// isPrime(n: 27) == false
// isPrime(n: 28) == false
// isPrime(n: 29) == true
// isPrime(n: 30) == false
// isPrime(n: 31) == true
// isPrime(n: 32) == false
// isPrime(n: 33) == false
// isPrime(n: 34) == false
// isPrime(n: 35) == false
// isPrime(n: 36) == false
// isPrime(n: 37) == true
// isPrime(n: 38) == false
// isPrime(n: 39) == false
// isPrime(n: 40) == false
// isPrime(n: 41) == true
// isPrime(n: 42) == false
// isPrime(n: 43) == true
// isPrime(n: 44) == false
// isPrime(n: 45) == false
// isPrime(n: 46) == false
// isPrime(n: 47) == true
// isPrime(n: 48) == false
// isPrime(n: 49) == false
// isPrime(n: 50) == false
// isPrime(n: 51) == false
// isPrime(n: 52) == false
// isPrime(n: 53) == true
// isPrime(n: 54) == false
// isPrime(n: 55) == false
// isPrime(n: 56) == false
// isPrime(n: 57) == false
// isPrime(n: 58) == false
// isPrime(n: 59) == true
// isPrime(n: 60) == false
// isPrime(n: 61) == true
// isPrime(n: 62) == false
// isPrime(n: 63) == false
// isPrime(n: 64) == false
// isPrime(n: 65) == false
// isPrime(n: 66) == false
// isPrime(n: 67) == true
// isPrime(n: 68) == false
// isPrime(n: 6
n /= 2 // left side of mutating operator isn't mutable: 'n' is a 'let' constant

func modp(n: Int, p: Int) -> Int {
    var res = 1
    var x = 2
    while n > 0 {
        if n % 2 == 1 {
            res = (res * x) % p
        }
        x = (x * x) % p
        n /= 2
    }
    return res
}

func gcd(a: Int, b: Int) -> Int {
    if b == 0 {
        return a
    }
    return gcd(a: b, b: a % b)
}

func lcm(a: Int, b: Int) -> Int {
    return a * b / gcd(a: a, b: b)
}

func modinv(a: Int, m: Int) -> Int {
    var t = 0
    var newt = 1
    var r = m
    var newr = a
    while newr != 0 {
        let q = r / newr
        (t, newt) = (newt, t - q * newt)
        (r, newr) = (newr, r - q * newr)
    }
    if r > 1 {
        return -1
    }
    if t < 0 {
        t += m
    }
    return t
}

func eulerPhi(n: Int) -> Int {
    var res = n
    for i in 2...Int(sqrt(Double(n))) {
        if n % i == 0 {
            res = res / i * (i - 1)
            while n % i == 0 {
                n /= i
            }
        }
    }
    if n > 1 {
        res = res / n * (n - 1)
    }
    return res
}
```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 {
    var res = 1
    var x = 2
    while n > 0 {
        if n % 2 == 1 {
            res = (res * x) % p
        }
        x = (x * x) % p
        n /= 2
    }
    return res
}

// Return the greatest common divisor of a and b.
// gcd(a: 12, b: 8) == 4
// gcd(a: 12, b: 13) == 1
func gcd(a: Int, b: Int) -> Int {
    if b == 0 {
        return a
    }
    return gcd(a: b, b: a % b)
}

// Return the least common multiple of a and b.
// lcm(a: 4, b: 6) == 12
// lcm(a: 4, b: 5) == 20
func lcm(a: Int, b: Int) -> Int {
    return a * b / gcd(a: a, b: b)
}

// Return the modular multiplicative inverse of a modulo m.
// modinv(a: 3, m: 11) == 4
// modinv(a: 10, m: 17) == 12
func modinv(a: Int, m: Int) -> Int {
    var t = 0
    var newt = 1
    var r = m
    var newr = a
    while newr != 0 {
        let q = r / newr
        (t, newt) = (newt, t - q * newt)
        (r, newr) = (newr, r - q * newr)
    }
    if r > 1 {
        return -1
    }
    if t < 0 {
        t += m
    }
    return t
}

// Return the number of integers in [1, n] that are coprime with n.
// eulerPhi(n: 1) == 1
// eulerPhi(n: 2) == 1
// eulerPhi(n: 3) == 2
// eulerPhi(n: 4) == 2
// eulerPhi(n: 5) == 4
// eulerPhi(n: 6) == 2
// eulerPhi(n: 7) == 6
// eulerPhi(n: 8) == 4
// eulerPhi(n: 9) == 6
// eulerPhi(n: 10) == 4
func eulerPhi(n: Int) -> Int {
    var res = n
    for i in 2...Int(sqrt(Double(n))) {
        if n % i == 0 {
            res = res / i * (i - 1)
            while n % i == 0 {
                n /= i
            }
        }
    }
    if n > 1 {
        res = res / n * (n - 1)
    }
    return res
}

// Return the prime factorization of n.
// primeFactorization(n: 1) == []
// primeFactorization(n: 2) == [(2, 1)]
// primeFactorization(n: 3) == [(3, 1)]
// primeFactorization(n: 4) == [(2, 2)]
// primeFactorization(n: 5) == [(5, 1)]
// primeFactorization(n: 6) == [(2, 1), (3, 1)]
// primeFactorization(n: 7) == [(7, 1)]
// primeFactorization(n: 8) == [(2, 3)]
// primeFactorization(n: 9) == [(3, 2)]
// primeFactorization(n: 10) == [(2, 1), (5, 1)]
func primeFactorization(n: Int) -> [(Int, Int)] {
    var res = [(Int, Int)]()
    for i in 2...Int(sqrt(Double(n))) {
        if n % i == 0 {
            var count = 0
            while n % i == 0 {
                n /= i
                count
n /= 2 // left side of mutating operator isn't mutable: 'n' is a 'let' constant
n /= i // left side of mutating operator isn't mutable: 'n' is a 'let' constant

func modp(n: Int, p: Int) -> Int {
    var n = n
    var p = p
    var res = 1
    while n > 0 {
        if n % 2 == 1 {
            res = (res * p) % 1000000007
        }
        n /= 2
        p = (p * p) % 1000000007
    }
    return res
}

func dominoTiling(n: Int) -> Int {
    var n = n
    var res = 0
    var a = 1
    var b = 0
    while n > 0 {
        res = (res + a) % 1000000007
        let c = (a + b) % 1000000007
        a = b
        b = c
        n -= 1
    }
    return res
}

func dominoAndTrominoTiling(n: Int) -> Int {
    var n = n
    var res = 0
    var a = 1
    var b = 0
    while n > 0 {
        res = (res + a) % 1000000007
        let c = (a + b) % 1000000007
        a = b
        b = c
        n -= 1
    }
    return res
}
```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 {
    var n = n
    var p = p
    var res = 1
    while n > 0 {
        if n % 2 == 1 {
            res = (res * p) % 1000000007
        }
        n /= 2
        p = (p * p) % 1000000007
    }
    return res
}

// Return the number of ways to tile a 2 x n rectangle with 2 x 1 dominoes.
// dominoTiling(n: 3) == 5
// dominoTiling(n: 10) == 2183
// dominoTiling(n: 100) == 247955073
func dominoTiling(n: Int) -> Int {
    var n = n
    var res = 0
    var a = 1
    var b = 0
    while n > 0 {
        res = (res + a) % 1000000007
        let c = (a + b) % 1000000007
        a = b
        b = c
        n -= 1
    }
    return res
}

// Return the number of ways to tile a 2 x n rectangle with 2 x 1 dominoes and 2 x 2 squares.
// dominoAndTrominoTiling(n: 3) == 11
// dominoAndTrominoTiling(n: 10) == 252
// dominoAndTrominoTiling(n: 100) == 979232805
func dominoAndTrominoTiling(n: Int) -> Int {
    var n = n
    var res = 0
    var a = 1
    var b = 0
    while n > 0 {
        res = (res + a) % 1000000007
        let c = (a + b) % 1000000007
        a = b
        b = c
        n -= 1
    }
    return res
}

// Return the number of ways to tile a 2 x n rectangle with 2 x 1 dominoes and 2 x 2 squares.
// dominoAndTrominoTiling(n: 3) == 11
// dominoAndTrominoTiling(n: 10) == 252
// dominoAndTrominoTiling(n: 100) == 979232805
func dominoAndTrominoTiling(n: Int) -> Int {
    var n = n
    var res = 0
    var a = 1
    var b = 0
    while n > 0 {
        res = (res + a) % 1000000007
        let c = (a + b) % 1000000007
        a = b
        b = c
        n -= 1
    }
    return res
}

// Return the number of ways to tile a 2 x n rectangle with 2 x 1 dominoes and 2 x 2 squares.
// dominoAndTrominoTiling(n: 3) == 11
// dominoAndTrominoTiling(n: 10) == 252
// dominoAndTrominoTiling(n: 100) == 979232805
func dominoAndTrominoTiling(n: Int) -> Int {
    var n = n
    var res = 0
    var a = 1
    var b = 0
    while n > 0 {
        res = (res + a) % 1000000007
        let c = (a + b) % 1000000007
        a = b
        b = c
        n -= 1
    }
    return res
}

// Return the number of ways to tile a 2 x n rectangle with 2 x 1 dominoes and 2 x 2 squares.
// dominoAndTrominoTiling(n: 3
 // XCTAssertTrue failed

func modp(n: Int, p: Int) -> Int {
    var res = 1
    var a = 2
    while n > 0 {
        if n % 2 == 1 {
            res = (res * a) % p
        }
        a = (a * a) % p
        n /= 2
    }
    return res
}
```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 {
    var res = 1
    var a = 2
    while n > 0 {
        if n % 2 == 1 {
            res = (res * a) % p
        }
        a = (a * a) % p
        n /= 2
    }
    return res
}

// Return true if n is prime.
// isPrime(n: 2) == true
// isPrime(n: 3) == true
// isPrime(n: 4) == false
// isPrime(n: 5) == true
// isPrime(n: 6) == false
// isPrime(n: 7) == true
// isPrime(n: 8) == false
// isPrime(n: 9) == false
// isPrime(n: 10) == false
// isPrime(n: 11) == true
// isPrime(n: 12) == false
// isPrime(n: 13) == true
// isPrime(n: 14) == false
// isPrime(n: 15) == false
// isPrime(n: 16) == false
// isPrime(n: 17) == true
// isPrime(n: 18) == false
// isPrime(n: 19) == true
// isPrime(n: 20) == false
// isPrime(n: 21) == false
// isPrime(n: 22) == false
// isPrime(n: 23) == true
// isPrime(n: 24) == false
// isPrime(n: 25) == false
// isPrime(n: 26) == false
// isPrime(n: 27) == false
// isPrime(n: 28) == false
// isPrime(n: 29) == true
// isPrime(n: 30) == false
// isPrime(n: 31) == true
// isPrime(n: 32) == false
// isPrime(n: 33) == false
// isPrime(n: 34) == false
// isPrime(n: 35) == false
// isPrime(n: 36) == false
// isPrime(n: 37) == true
// isPrime(n: 38) == false
// isPrime(n: 39) == false
// isPrime(n: 40) == false
// isPrime(n: 41) == true
// isPrime(n: 42) == false
// isPrime(n: 43) == true
// isPrime(n: 44) == false
// isPrime(n: 45) == false
// isPrime(n: 46) == false
// isPrime(n: 47) == true
// isPrime(n: 48) == false
// isPrime(n: 49) == false
// isPrime(n: 50) == false
// isPrime(n: 51) == false
// isPrime(n: 52) == false
// isPrime(n: 53) == true
// isPrime(n: 54) == false
// isPrime(n: 55) == false
// isPrime(n: 56) == false
// isPrime(n: 57) == false
// isPrime(n: 58) == false
// isPrime(n: 59) == true
// isPrime(n: 60) == false
// isPrime(n: 61) == true
// isPrime(n: 62) == false
// isPrime(n: 63) == false
// isPrime(n: 64) == false
// isPrime(n: 65) == false
// isPrime(n: 66) == false
// isPrime(n: 67) == true
// isPrime(n: 68) == false
// isPrime(n: 6
n /= 2 // left side of mutating operator isn't mutable: 'n' is a 'let' constant

func modp(n: Int, p: Int) -> Int {
    var n = n
    var res = 1
    while n > 0 {
        if n % 2 == 1 {
            res = (res * 2) % p
        }
        n /= 2
    }
    return res
}

func gcd(a: Int, b: Int) -> Int {
    var a = a
    var b = b
    while b > 0 {
        let r = a % b
        a = b
        b = r
    }
    return a
}

func lcm(a: Int, b: Int) -> Int {
    return a * b / gcd(a: a, b: b)
}

func modinv(a: Int, m: Int) -> Int {
    var a = a
    var b = m
    var t = 0
    var newt = 1
    var r = m
    var newr = a
    while newr > 0 {
        let q = r / newr
        let t = newt
        newt = t - q * newt
        let r = newr
        newr = r - q * newr
    }
    if r > 1 {
        return -1
    }
    if t < 0 {
        t += m
    }
    return t
}
```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 {
    var n = n
    var res = 1
    while n > 0 {
        if n % 2 == 1 {
            res = (res * 2) % p
        }
        n /= 2
    }
    return res
}

// Return the greatest common divisor of a and b.
// gcd(a: 12, b: 8) == 4
// gcd(a: 1101, b: 101) == 1
// gcd(a: 100, b: 101) == 1
func gcd(a: Int, b: Int) -> Int {
    var a = a
    var b = b
    while b > 0 {
        let r = a % b
        a = b
        b = r
    }
    return a
}

// Return the least common multiple of a and b.
// lcm(a: 12, b: 8) == 24
// lcm(a: 1101, b: 101) == 1101
// lcm(a: 100, b: 101) == 10100
func lcm(a: Int, b: Int) -> Int {
    return a * b / gcd(a: a, b: b)
}

// Return the modular multiplicative inverse of a modulo m.
// modinv(a: 2, m: 5) == 3
// modinv(a: 1101, m: 101) == 1
// modinv(a: 100, m: 101) == 1
func modinv(a: Int, m: Int) -> Int {
    var a = a
    var b = m
    var t = 0
    var newt = 1
    var r = m
    var newr = a
    while newr > 0 {
        let q = r / newr
        let t = newt
        newt = t - q * newt
        let r = newr
        newr = r - q * newr
    }
    if r > 1 {
        return -1
    }
    if t < 0 {
        t += m
    }
    return t
}

// Return the modular multiplicative inverse of a modulo m.
// modinv(a: 2, m: 5) == 3
// modinv(a: 1101, m: 101) == 1
// modinv(a: 100, m: 101) == 1
func modinv(a: Int, m: Int) -> Int {
    var a = a
    var b = m
    var t = 0
    var newt = 1
    var r = m
    var newr = a
    while newr > 0 {
        let q = r / newr
        let t = newt
        newt = t - q * newt
        let r = newr
        newr = r - q * newr
    }
    if r > 1 {
        return -1
    }
    if t < 0 {
        t += m
    }
    return t
}

// Return the modular multiplicative inverse of a modulo m.
// modinv(a: 2, m: 5) == 3
// modinv(a: 1101, m: 101) == 1
// modinv(a: 100, m: 101) == 1
func modinv(a: Int, m: Int) -> Int {
    var a = a
    var b = m
    var t = 0
    var newt = 1
    var r = m
    var newr = a
    while newr > 0 {
        let q = r / newr
        let t = newt
        newt = t - q * newt
        let r = newr
        newr = r - q * newr
    }
    if r > 1 {
        return -1
    }
    if t < 0 {
        t += m
    }
    return t
}

// Return the modular multiplicative inverse of a modulo m.
// modinv(a
var a = a // variable 'a' was never mutated; consider changing to 'let' constant
var b = m // initialization of variable 'b' was never used; consider replacing with assignment to '_' or removing it
var r = m // variable 'r' was never mutated; consider changing to 'let' constant
 // XCTAssertTrue failed

func modp(n: Int, p: Int) -> Int {
    if n == 0 { return 1 }
    if n % 2 == 0 {
        let m = modp(n: n / 2, p: p)
        return (m * m) % p
    } else {
        return (modp(n: n - 1, p: p) * 3) % 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 {
    if n == 0 { return 1 }
    if n % 2 == 0 {
        let m = modp(n: n / 2, p: p)
        return (m * m) % p
    } else {
        return (modp(n: n - 1, p: p) * 3) % p
    }
}

print(modp(n: 3, p: 5))
print(modp(n: 1101, p: 101))
print(modp(n: 0, p: 101))
print(modp(n: 3, p: 11))
print(modp(n: 100, p: 101))
```
 // XCTAssertTrue failed

func modp(n: Int, p: Int) -> Int {
    var n = n
    var p = p
    var res = 1
    while n > 0 {
        if n % 2 == 1 {
            res = (res * p) % 101
        }
        n = n / 2
        p = (p * p) % 101
    }
    return res
}
```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 {
    var n = n
    var p = p
    var res = 1
    while n > 0 {
        if n % 2 == 1 {
            res = (res * p) % 101
        }
        n = n / 2
        p = (p * p) % 101
    }
    return res
}

print(modp(n: 3, p: 5))
print(modp(n: 1101, p: 101))
print(modp(n: 0, p: 101))
print(modp(n: 3, p: 11))
print(modp(n: 100, p: 101))
```
 // XCTAssertTrue failed

func modp(n: Int, p: Int) -> Int {
    if n == 0 { return 1 }
    if n % 2 == 0 {
        let m = modp(n: n / 2, p: p)
        return (m * m) % p
    } else {
        return (modp(n: n - 1, p: p) * 3) % 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 {
    if n == 0 { return 1 }
    if n % 2 == 0 {
        let m = modp(n: n / 2, p: p)
        return (m * m) % p
    } else {
        return (modp(n: n - 1, p: p) * 3) % p
    }
}

print(modp(n: 3, p: 5))
print(modp(n: 1101, p: 101))
print(modp(n: 0, p: 101))
print(modp(n: 3, p: 11))
print(modp(n: 100, p: 101))
```
 // XCTAssertTrue failed

func modp(n: Int, p: Int) -> Int {
    var n = n
    var res = 1
    while n > 0 {
        if n % 2 == 1 {
            res = (res * 2) % p
        }
        n /= 2
    }
    return res
}

func numOnes(n: Int) -> Int {
    var n = n
    var res = 0
    while n > 0 {
        res += n % 2
        n /= 2
    }
    return res
}

func numOnes2(n: Int) -> Int {
    var n = n
    var res = 0
    while n > 0 {
        res += 1
        n &= n - 1
    }
    return res
}

func numOnes3(n: Int) -> Int {
    var n = n
    var res = 0
    while n > 0 {
        res += n & 1
        n >>= 1
    }
    return res
}
```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 {
    var n = n
    var res = 1
    while n > 0 {
        if n % 2 == 1 {
            res = (res * 2) % p
        }
        n /= 2
    }
    return res
}

// Return the number of 1s in the binary representation of n.
// numOnes(n: 0) == 0
// numOnes(n: 1) == 1
// numOnes(n: 2) == 1
// numOnes(n: 3) == 2
// numOnes(n: 4) == 1
// numOnes(n: 5) == 2
// numOnes(n: 6) == 2
// numOnes(n: 7) == 3
// numOnes(n: 8) == 1
// numOnes(n: 9) == 2
// numOnes(n: 10) == 2
// numOnes(n: 11) == 3
// numOnes(n: 12) == 2
// numOnes(n: 13) == 3
// numOnes(n: 14) == 3
// numOnes(n: 15) == 4
func numOnes(n: Int) -> Int {
    var n = n
    var res = 0
    while n > 0 {
        res += n % 2
        n /= 2
    }
    return res
}

// Return the number of 1s in the binary representation of n.
// numOnes2(n: 0) == 0
// numOnes2(n: 1) == 1
// numOnes2(n: 2) == 1
// numOnes2(n: 3) == 2
// numOnes2(n: 4) == 1
// numOnes2(n: 5) == 2
// numOnes2(n: 6) == 2
// numOnes2(n: 7) == 3
// numOnes2(n: 8) == 1
// numOnes2(n: 9) == 2
// numOnes2(n: 10) == 2
// numOnes2(n: 11) == 3
// numOnes2(n: 12) == 2
// numOnes2(n: 13) == 3
// numOnes2(n: 14) == 3
// numOnes2(n: 15) == 4
func numOnes2(n: Int) -> Int {
    var n = n
    var res = 0
    while n > 0 {
        res += 1
        n &= n - 1
    }
    return res
}

// Return the number of 1s in the binary representation of n.
// numOnes3(n: 0) == 0
// numOnes3(n: 1) == 1
// numOnes3(n: 2) == 1
// numOnes3(n: 3) == 2
// numOnes3(n: 4) == 1
// numOnes3(n: 5) == 2
// numOnes3(n: 6) == 2
// numOnes3(n: 7) == 3
// numOnes3(n: 8) == 1
// numOnes3(n: 9) == 2
// numOnes3(n: 10) == 2
// numOnes3(n: 11) == 3
// numOnes3(n: 12) == 2
// numOnes3(n: 13) == 3
// numOnes3(n: 14) == 3
// numOnes3(n: 15) == 4
func numOnes3(n: Int) -> Int {
    var n = n
    var res = 0
    while n > 0 {
        res += n & 1
        n >>= 1
    }
    return res
}

// Return the number of 1s in the binary
 // XCTAssertTrue failed

func modp(n: Int, p: Int) -> Int {
    var n = n
    var res = 1
    while n > 0 {
        if n % 2 == 1 {
            res = (res * 2) % p
        }
        n /= 2
    }
    return res
}

func gcd(a: Int, b: Int) -> Int {
    if b == 0 {
        return a
    }
    return gcd(a: b, b: a % b)
}

func lcm(a: Int, b: Int) -> Int {
    return a * b / gcd(a: a, b: b)
}
```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 {
    var n = n
    var res = 1
    while n > 0 {
        if n % 2 == 1 {
            res = (res * 2) % p
        }
        n /= 2
    }
    return res
}

// Return the greatest common divisor of a and b.
// gcd(a: 12, b: 8) == 4
// gcd(a: 11, b: 1) == 1
// gcd(a: 11, b: 0) == 11
func gcd(a: Int, b: Int) -> Int {
    if b == 0 {
        return a
    }
    return gcd(a: b, b: a % b)
}

// Return the least common multiple of a and b.
// lcm(a: 12, b: 8) == 24
// lcm(a: 11, b: 1) == 11
// lcm(a: 11, b: 0) == 0
func lcm(a: Int, b: Int) -> Int {
    return a * b / gcd(a: a, b: b)
}

// Return the greatest common divisor of a and b.
// gcd(a: 12, b: 8) == 4
// gcd(a: 11, b: 1) == 1
// gcd(a: 11, b: 0) == 11
func gcd(a: Int, b: Int) -> Int {
    if b == 0 {
        return a
    }
    return gcd(a: b, b: a % b)
}

// Return the least common multiple of a and b.
// lcm(a: 12, b: 8) == 24
// lcm(a: 11, b: 1) == 11
// lcm(a: 11, b: 0) == 0
func lcm(a: Int, b: Int) -> Int {
    return a * b / gcd(a: a, b: b)
}

// Return the greatest common divisor of a and b.
// gcd(a: 12, b: 8) == 4
// gcd(a: 11, b: 1) == 1
// gcd(a: 11, b: 0) == 11
func gcd(a: Int, b: Int) -> Int {
    if b == 0 {
        return a
    }
    return gcd(a: b, b: a % b)
}

// Return the least common multiple of a and b.
// lcm(a: 12, b: 8) == 24
// lcm(a: 11, b: 1) == 11
// lcm(a: 11, b: 0) == 0
func lcm(a: Int, b: Int) -> Int {
    return a * b / gcd(a: a, b: b)
}

// Return the greatest common divisor of a and b.
// gcd(a: 12, b: 8) == 4
// gcd(a: 11, b: 1) == 1
// gcd(a: 11, b: 0) == 11
func gcd(a: Int, b: Int) -> Int {
    if b == 0 {
        return a
    }
    return gcd(a: b, b: a % b)
}

// Return the least common multiple of a and b.
// lcm(a: 12, b: 8) == 24
// lcm(a: 11, b: 1) == 11
// lcm(a: 11, b: 0) == 0
func lcm(a: Int, b: Int) -> Int {
    return a * b / gcd(a: a, b: b)
}

// Return the greatest common divisor of a and b.
// gcd(a: 12, b: 8) == 4
// gcd(a: 11, b: 1) ==
 // XCTAssertTrue failed

func removeVowels(text: String) -> String {
    // your code here
}
```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 {
    // your code here
}
```
} // missing return in global function expected to return 'String'

func removeVowels(text: String) -> String {
    // write your code here
}
```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 {
    // write your code here
}
```
} // missing return in global function expected to return 'String'

func removeVowels(text: String) -> String {
    // write your code here
}
```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 {
    // write your code here
}
```
} // missing return in global function expected to return 'String'

func removeVowels(text: String) -> String {
    // write your code here
}
```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 {
    // write your code here
}
```
} // missing return in global function expected to return 'String'

func removeVowels(text: String) -> String {
    // write your code here
}
```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 {
    // write your code here
}
```
} // missing return in global function expected to return 'String'

func removeVowels(text: String) -> String {
    // write your code here
}
```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 {
    // write your code here
}
```
} // missing return in global function expected to return 'String'

func removeVowels(text: String) -> String {
    // write your code here
}
```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 {
    // write your code here
}
```
} // missing return in global function expected to return 'String'

func removeVowels(text: String) -> String {
    return ""
}
```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 {
    return ""
}
```
 // XCTAssertTrue failed

func removeVowels(text: String) -> String {
    var result = ""
    for char in text {
        if !(char == "a" || char == "e" || char == "i" || char == "o" || char == "u" || char == "A" || char == "E" || char == "I" || char == "O" || char == "U") {
            result += String(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" || char == "A" || char == "E" || char == "I" || char == "O" || char == "U") {
            result += String(char)
        }
    }
    return result
}

print(removeVowels(text: "abcdef"))
print(removeVowels(text: "aaaaa"))
print(removeVowels(text: "aaBAA"))
print(removeVowels(text: "zbcd"))
```

func removeVowels(text: String) -> String {
    var result = ""
    for char in text {
        if !(char == "a" || char == "e" || char == "i" || char == "o" || char == "u" || char == "A" || char == "E" || char == "I" || char == "O" || char == "U") {
            result.append(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" || char == "A" || char == "E" || char == "I" || char == "O" || char == "U") {
            result.append(char)
        }
    }
    return result
}

print(removeVowels(text: "abcdef"))
print(removeVowels(text: "aaaaa"))
print(removeVowels(text: "aaBAA"))
print(removeVowels(text: "zbcd"))
```

func belowThreshold(l: [Int], t: Int) -> Bool {
    // TODO: implement
}
```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 {
    // TODO: implement
}
```
} // missing return in global function expected to return 'Bool'

func belowThreshold(l: [Int], t: Int) -> Bool {
    // Your code here
}
```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 {
    // Your code here
}
```
} // missing return in global function expected to return 'Bool'

func belowThreshold(l: [Int], t: Int) -> Bool {
    // TODO: implement
}
```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 {
    // TODO: implement
}
```
} // missing return in global function expected to return 'Bool'

func belowThreshold(l: [Int], t: Int) -> Bool {
    // TODO: implement
}
```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 {
    // TODO: implement
}
```
} // missing return in global function expected to return 'Bool'

func belowThreshold(l: [Int], t: Int) -> Bool {
    // ...
}
```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 {
    // ...
}
```
} // missing return in global function expected to return 'Bool'

func belowThreshold(l: [Int], t: Int) -> Bool {
    return l.reduce(true, { (acc, x) -> Bool in
        return acc && x < 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.reduce(true, { (acc, x) -> Bool in
        return acc && x < t
    })
}
```

func belowThreshold(l: [Int], t: Int) -> Bool {
    // TODO
}
```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 {
    // TODO
}
```
} // missing return in global function expected to return 'Bool'

func belowThreshold(l: [Int], t: Int) -> Bool {
    // TODO: Implement
    return false
}
```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 {
    // TODO: Implement
    return false
}
```
 // XCTAssertTrue failed

func belowThreshold(l: [Int], t: Int) -> Bool {
    // TODO
}
```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 {
    // TODO
}
```
} // missing return in global function expected to return 'Bool'

func belowThreshold(l: [Int], t: Int) -> Bool {
    return l.reduce(true, { (acc, x) -> Bool in
        return acc && x < 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.reduce(true, { (acc, x) -> Bool in
        return acc && x < t
    })
}
```