Created
April 27, 2017 10:10
-
-
Save danielctull/d1eba4c14fdfe18535247e1831e16746 to your computer and use it in GitHub Desktop.
A random generator for private building tiles in Great Western Trail.
This file contains hidden or 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 | |
| extension String { | |
| func pad(to length: Int) -> String { | |
| guard self.characters.count < length else { | |
| return self | |
| } | |
| let padded = "0" + self | |
| return padded.pad(to: length) | |
| } | |
| } | |
| let random = arc4random_uniform(1024) | |
| let string = String(random, radix: 2, uppercase: true).pad(to: 10) | |
| print(random) | |
| for (index, character) in string.characters.enumerated() { | |
| let value = Int(String(character))! | |
| let side = value == 0 ? "A" : "B" | |
| print(index+1, side) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Will print out the number of the combination, along with what the tiles should be, such as: