Skip to content

Instantly share code, notes, and snippets.

@acevif
Last active January 5, 2023 08:14
Show Gist options
  • Save acevif/00915d2f44f6bc890558de61b5e714a2 to your computer and use it in GitHub Desktop.
Save acevif/00915d2f44f6bc890558de61b5e714a2 to your computer and use it in GitHub Desktop.
atcoder swift snippet
/* atcoder swift snippet */
func readLineOfInt() -> Int {
Int(readLine()!)!
}
func readLineOfInts() -> [Int] {
readLine()!.split(separator: " ").map { Int($0)! }
}
func readLinesOfSingleInt(_ n: Int) -> [Int] {
var result: [Int] = []
for _ in 1 ... n {
let integer = Int(readLine()!)!
result.append(integer)
}
return result
}
extension Array where Element: Hashable {
var uniqued: Self {
Array(Set(self))
}
}
extension String {
func splitWithSpace() -> [String] {
split(separator: " ")
.map(String.init)
}
}
func printN(
_ items: Any...,
separator: String = " "
) {
print(items, separator, terminator: "")
}
/* end of atcoder swift snippet */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment