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 SwiftUI | |
struct MonospacedText: View { | |
let content: String | |
let characterWidth: CGFloat | |
init(_ content: String, characterWidth: CGFloat) { | |
self.content = content | |
self.characterWidth = characterWidth | |
} |
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 | |
import PlaygroundSupport | |
// ----------------------------------------------------- | |
// Model | |
// | |
// Types having to do with the storing and processing of | |
// data should be a part of the "Model" layer. | |
// ----------------------------------------------------- |
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 | |
typealias Algorithm = (name: String, execute: ([Int],[Int]) -> [Int]) | |
let algorithms: [Algorithm] = [ | |
(name: "Drewag", { a, b in | |
return zip(a,b) | |
.map{( | |
$0 > $1 ? 1 : 0, | |
$1 > $0 ? 1 : 0 | |
)} |
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 | |
// ========================================================================== | |
// My Solution | |
// ========================================================================== | |
struct Position { | |
let row: Int | |
let column: Int | |
} |
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
struct TakeWhileGenerator<T: GeneratorType>: GeneratorType { | |
typealias Element = T.Element | |
var generator: T | |
let test: (element: T.Element) -> Bool | |
mutating func next() -> Element? { | |
if let next = generator.next() { | |
if test(element: next) { | |
return next |