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
// https://adventofcode.com/2022/day/23 | |
import AOC | |
import Preamble | |
let input = readInput() | |
let xinput = """ | |
....#.. | |
..###.# | |
#...#.# |
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 AppKit | |
public extension NSBezierPath { | |
public var CGPath: CGPath { | |
let path = CGMutablePath() | |
var points = [CGPoint](repeating: .zero, count: 3) | |
for i in 0 ..< self.elementCount { | |
let type = self.element(at: i, associatedPoints: &points) | |
switch type { |
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 SwiftUI | |
import PlaygroundSupport | |
struct EqualWidthKey: PreferenceKey { | |
static var defaultValue: CGFloat? { nil } | |
static func reduce(value: inout CGFloat?, nextValue: () -> CGFloat?) { | |
switch (value, nextValue()) { | |
case (_, nil): break | |
case (nil, let next): value = next |
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
static CGPathRef createClosedPathWithPoints(const CGPoint *points, size_t count) { | |
CGMutablePathRef path = CGPathCreateMutable(); | |
CGPathAddLines(path, NULL, points, count); | |
CGPathCloseSubpath(path); | |
return path; | |
} | |
static CGRect integralFrameForPath(CGPathRef path) { | |
CGRect frame = CGPathGetBoundingBox(path); | |
return CGRectIntegral(frame); |
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
// Swift 2.2 syntax / API | |
import UIKit | |
extension UIBezierPath { | |
class func arrow(from start: CGPoint, to end: CGPoint, tailWidth: CGFloat, headWidth: CGFloat, headLength: CGFloat) -> Self { | |
let length = hypot(end.x - start.x, end.y - start.y) | |
let tailLength = length - headLength |
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 SwiftUI | |
fileprivate struct IconWidthKey: PreferenceKey { | |
static var defaultValue: CGFloat? { nil } | |
static func reduce(value: inout CGFloat?, nextValue: () -> CGFloat?) { | |
switch (value, nextValue()) { | |
case (nil, let next): value = next | |
case (_, nil): break | |
case (.some(let current), .some(let next)): value = max(current, next) |
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
#if canImport(Combine) | |
import Combine | |
import CasePaths | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public typealias Effect<Output> = AnyPublisher<Output, Never> | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Effect { |
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
# https://twitter.com/hillelogram/status/1461103115260805123/photo/1 | |
# https://pikchr.org/home/pikchrshow | |
linerad = 5px | |
B1: box "1" | |
B8: box "8" | |
B9: box "9" | |
B1_2: [ box; "1" color blue at last box ] | |
B2_2: [ box; "2" color blue at last box ] |
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 SwiftUI | |
fileprivate struct WidthPreferenceKey: PreferenceKey { | |
static var defaultValue: [AnyHashable: CGFloat] { [:] } | |
static func reduce(value: inout [AnyHashable : CGFloat], nextValue: () -> [AnyHashable : CGFloat]) { | |
value.merge(nextValue(), uniquingKeysWith: { max($0, $1) }) | |
} | |
} |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>com.dqd.stop-simulator-spotlight</string> | |
<key>ProcessType</key> | |
<string>Background</string> | |
<key>ProgramArguments</key> | |
<array> |