Skip to content

Instantly share code, notes, and snippets.

@jackpal
jackpal / day24.py
Created December 24, 2023 06:51
Advent of Code 2023 Day 24 Solution
# Parse input
def parse_input(s):
out = []
for line in s.strip().split('\n'):
p,v = line.split(' @ ')
pp = [int(i) for i in p.split(',')]
vv = [int(i) for i in v.split(',')]
out.append((pp,vv))
return out
@jackpal
jackpal / ConvertBlogFromPublishToJekyll.swift
Created December 28, 2020 07:27
A Swift Command Line tool to translate the posts of a simple website from Publish to Jekyll
//
// ConvertBlogFromPublishToJekyll.swift
// Quick and dirty script to translate the posts of my personal website from the
// [Publish](https://github.com/JohnSundell/Publish) site generator to the
// [Jekyll](https://jekyllrb.com/) site generator.
//
// Created by Jack Palevich on 12/27/20.
//
import Foundation
@jackpal
jackpal / TVSlideshowView.swift
Created February 17, 2020 05:29
A SwiftUI slideshow view
struct TVSlideshowView : View {
let publisher : AnyPublisher<UIImage?, Never>
@State private var uiImageA: UIImage? = nil
@State private var uiImageB: UIImage? = nil
@State private var imageAHasPriority: Bool = true
var body: some View {
ZStack {
decorate(uiImage: uiImageA, isImageA: true)
@jackpal
jackpal / BotaniculaAnemonePuzzleSolver.swift
Last active November 22, 2018 18:53
Swift code to solve the iPad Botanicula anemone puzzle
// Solve the anemone Botanicula puzzle.
// Number the anenome 1 to 7, left-to-right.
// Encode a list of anemones into a single integer, where bit 0 is anemone 1, etc.
func encode(_ d:[Int])->Int {
return d.reduce(0, {x, y in x | (1 << (y-1)) })
}
// A list of which anemones are pulled down when a given anemone is tapped.
let moves = [