Swift: The Number of Full Rounds You Have Played (+ Test Cases)
swift\nclass Solution {\n    private func timeStr2Int(_ time: String) -> Int {\n        let split = time.split(separator: ":")\n        return (Int(split[0]) ??
```swift\nclass Solution {\n    private func timeStr2Int(_ time: String) -> Int {\n        let split = time.split(separator: ":")\n        return (Int(split[0]) ?? 0) * 60 + (Int(split[1]) ?? 0)\n    }\n    func numberOfRounds(_ startTime: String, _ finishTime: String) -> Int {\n        var s = timeStr2Int(startTime), f = timeStr2Int(finishTime)\n        if f < s { f += 24 * 60 }\n        var result = 0\n        for t in s...f where t % 15 == 0 && f-t >= 15 { result += 1 }\n        return result\n    }\n}\n```\n\n```swift\nimport XCTest\n\n// Executed 3 tests, with 0 failures (0 unexpected) in 0.034 (0.036) seconds\n\nclass Tests: XCTestCase {\n    private let s = Solution()\n    func test1() {\n        let result = s.numberOfRounds("12:01", "12:44")\n        XCTAssertEqual(result, 1)\n    }\n    func test2() {\n        let result = s.numberOfRounds("20:00", "06:00")\n        XCTAssertEqual(result, 40)\n    }\n    func test3() {\n        let result = s.numberOfRounds("00:00", "23:59")\n        XCTAssertEqual(result, 95)\n    }\n}\n\nTests.defaultTestSuite.run()\n```
['Swift']