Skip to content

Instantly share code, notes, and snippets.

@woodycatliu
Last active April 1, 2021 04:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save woodycatliu/7dd85f438f0128457564e27c875436f1 to your computer and use it in GitHub Desktop.
Save woodycatliu/7dd85f438f0128457564e27c875436f1 to your computer and use it in GitHub Desktop.
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