# 2016-04-16 Codility supports Swift

If you didn't know Codility: it's a company that devises programming tests that are used to test applicants for a job opening. Besides that, other uses are simply to exercise oneself, gaining skills in solving programming puzzles.

And now it supports Swift! I've been having fun doing some small puzzles here and there. For example, this is my solution to the Number of Intersecting Disks problem.

And for Lesson 7, the Brackets test, here is the solution I came up with:

`    //: Playground - noun: a place where people can play`
`    import UIKit`
```    enum Bracket: Character {
case squareOpen = "["
case squareClose = "]"
case roundOpen = "("
case roundClose = ")"
case curlyOpen = "{"
case curlyClose = "}"
}```
```    public func solution(inout S : String) -> Int {
var bracketStack: Array<Bracket> = []

for bracketChar in S.characters {
guard let bracket = Bracket(rawValue: bracketChar) else {
return 0
}

switch bracket {
case .squareOpen, .roundOpen, .curlyOpen:
bracketStack.append(bracket)
case .squareClose:
if let b = bracketStack.popLast() {
if b != .squareOpen {
return 0
}
} else {
return 0
}
case .roundClose:
if let b = bracketStack.popLast() {
if b != .roundOpen {
return 0
}
} else {
return 0
}
case .curlyClose:
if let b = bracketStack.popLast() {
if b != .curlyOpen {
return 0
}
} else {
return 0
}
}
}

if bracketStack.count > 0 {
return 0
}

return 1
}```
```    var validString = "{[()()]}"
var invalidString = "([)()]"```
```    solution(&validString)
solution(&invalidString)```