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 findRotationPoint(in words: [String]) -> Int { | |
let firstWord = words[0] | |
var floorIndex = 0 | |
var ceilingIndex = words.count - 1 | |
while floorIndex < ceilingIndex { | |
// guess a point halfway between floor and ceiling | |
let guessIndex = floorIndex + ((ceilingIndex - floorIndex) / 2) |
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
let presentedViewController: UIViewController? = UIViewController() | |
struct Route { | |
var animateTransition: Bool | |
} | |
let route = Route(animateTransition: true) | |
let animated = presentedViewController == nil && route.animateTransition == false ? false : true |
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
import Foundation | |
import UIKit | |
import PlaygroundSupport | |
extension String { | |
func toColorIncludingAlpha() -> UIColor? { | |
var cString: String = self | |
.trimmingCharacters(in: .whitespacesAndNewlines) | |
.replacingOccurrences(of: "#", with: "") |
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
extension Int { | |
var ordinal:String { | |
get { | |
if self == 0 { | |
return "0" | |
} | |