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
// credit to @eirnym, adapted this from their OBJC code: https://gist.github.com/eirnym/c9526a045556e4d8464b41a367843e3c | |
// generates a random date and time in the past, limited by daysBack (a number of days before today) | |
// also generates a random time to go with that date. | |
// original request: http://stackoverflow.com/questions/10092468/how-do-you-generate-a-random-date-in-objective-c | |
func generateRandomDate(daysBack: Int)-> Date?{ | |
let day = arc4random_uniform(UInt32(daysBack))+1 |
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
func multiLineInputSetup() { | |
//Use this for multiple line inputs. The problem for which I generated this had the first term in its sequence as the number of lines of input. If this isn't available, you could just build a while loop that switches on whether a string can be instantiated with readLine() | |
let fileName = ProcessInfo.processInfo.environment["OUTPUT_PATH"]! | |
FileManager.default.createFile(atPath: fileName, contents: nil, attributes: nil) | |
let fileHandle = FileHandle(forWritingAtPath: fileName)! | |
guard let s = readLine(), let count = Int(s) else { fatalError("Bad input") } | |
var output = "" | |
for _ in 1...count { | |
guard let s = readLine() else {continue} |