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
struct CubeCoordinate: Hashable { | |
let x: Int | |
let y: Int | |
let z: Int | |
func neighbors() -> [CubeCoordinate] { | |
Direction.allCases.map(neighbor(for:)) | |
} | |
func neighbor(for direction: Direction) -> CubeCoordinate { |
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
indirect enum Element { | |
case number(Int) | |
case operation(Character) | |
case subexpression([Element]) | |
} | |
func parse(_ remainder: String.SubSequence, _ accumulator: [Element] = []) -> [Element] { | |
guard let head = remainder.first else { return accumulator } | |
switch head { | |
case " ": |
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
open System.IO | |
[<AutoOpen>] | |
module ControlFreak = | |
type Timer = { | |
hours: int; | |
minutes: int; | |
seconds: int | |
} |