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
let field = [0,0,0,0,1,0,0,0,1,0,1,1,0,0,0,1,1,0,0,0,0,1,1,0,0,1,1] | |
var memo:[Int:[Int:Bool]] = [0:[:]] | |
func bounce(startingSpeed:Int, startingIndex:Int, field:[Int]) -> Bool { | |
// Many base cases. We must still be on the runway. | |
// We must land on a place with 0 (no spikes) | |
// Use a double dictionary as the memo. Store true/false. 1 dimension for each changing intput!!!! |
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
enum Result<T> { | |
case success(T) | |
case error(Error) | |
} | |
struct ToDo : Codable { | |
var id: Int | |
var userId: Int | |
var title:String | |
var completed:Bool |
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
extension UIImageView { | |
func setImage(from url: URL, withPlaceholder placeholder: UIImage? = .none, withCache cache:NSCache<NSURL,UIImage>? = .none) -> URLSessionDataTask? { | |
if let cached = cache?.object(forKey: url as NSURL) { | |
self.image = cached | |
return .none | |
} | |
self.image = placeholder | |
let task = URLSession.shared.dataTask(with: url) { (data, _, _) in |
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
/* Usage | |
let log = OSLog(subsystem: "deep-secrets", category: "cookie-recipes") | |
let signpostID = log.beginSignpost(withName: "signpost name") | |
... Do work ... | |
log.endSignpost(withName: "signpost name" , signpostId: signpostId) | |
Signposts can also be started w objects instead of SignpostIDs when scope is an issue |
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 UIKit | |
struct FrontScreenViewmodel { | |
var hello = "there" | |
} | |
// Builds the ViewControllers, and injects the ViewModels | |
class Factory { | |
let viewModelFactory = ViewModelFactory() |
OlderNewer