Last active
April 1, 2021 04:04
-
-
Save woodycatliu/7dd85f438f0128457564e27c875436f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
let input = """ | |
3 | |
4 | |
4 2 1 3 | |
2 | |
1 2 | |
7 | |
7 6 5 4 3 2 1 | |
""" | |
var lines = input.components(separatedBy: "\n") | |
func readLine() -> String? { | |
let firstStr = lines.first | |
lines.remove(at: 0) | |
return firstStr! | |
} | |
func getIntegersOf(line: String, separatedBy separator: String) -> [Int] { | |
let stringArray = line.components(separatedBy: separator) | |
return stringArray.map { Int($0)! } | |
} | |
for input in lines { | |
if input.count > 1 { | |
// dosomething | |
//...回家補上 | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment