Last active
January 5, 2023 08:14
-
-
Save acevif/00915d2f44f6bc890558de61b5e714a2 to your computer and use it in GitHub Desktop.
atcoder swift snippet
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
/* 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