Skip to content

Instantly share code, notes, and snippets.

View buntine's full-sized avatar
💭
Gringo Starr

Andrew Buntine buntine

💭
Gringo Starr
View GitHub Profile
@buntine
buntine / advent-of-code-2023-day8-cleaner.clj
Last active December 8, 2023 23:45
advent-of-code-2023-day8.clj
(defn path-follower [[dir & rest-dirs] graph edge]
(let [next-edge ((edge graph) ({:L 0 :R 1} dir))]
(->> (path-follower rest-dirs graph next-edge)
(cons edge)
lazy-seq)))
(defn steps [path graph start-edge goal]
(->> (path-follower (cycle path) graph start-edge)
(take-while #(not= % goal))
count))
@buntine
buntine / advent-of-code-2023-day6.clj
Last active December 6, 2023 12:40
advent-of-code-2023-day6.clj
;golfed it
(apply * (map (comp count (fn [[t d]] (filter #(> (* (- t %) %) d) (range 1 t)))) {7 9 15 40 30 200}))
@buntine
buntine / advent-of-code-2023-day3.clj
Last active December 3, 2023 10:58
advent-of-code-2023-day3.clj
(ns advent-of-code-2023.day3)
(defn numbers [s]
(loop [m (re-matcher #"(?m)\d+" s)
res {}]
(if (.find m)
(recur m (assoc res [(.start m) (.end m)] (Integer. (.group m))))
res)))
(defn is-part?
(ns advent-of-code-2023.core
(:require [clojure.string :refer [split split-lines]]))
(defn parse-line [game]
(let [[game-number plays] (split game #":\s")
play-seq (split plays #"[;,]\s")]
[(Integer. (re-find #"\d+" game-number))
(map #(let [[n color] (split % #"\s")]
[(Integer. n)
(keyword color)])
@buntine
buntine / infix.clj
Created August 27, 2018 01:06
Clojure for the Brave and True - Chapter 7 infix to prefix notation function
(defn expr-arrange [op]
(fn arrange [expr]
(cond
(<= (count expr) 2) expr
(= (second expr) op)
(conj (arrange (drop 3 expr))
(list (second expr) (first expr) (nth expr 2)))
:else (conj (arrange (rest expr)) (first expr)))))
(def multiply (expr-arrange '*))
Aardia - Embraced by Fear
Aardia - Fairy Tales From Beyond
Ablibitum - In a Strange Land
Absu - Mythological Occult Metal (2CD box)
Absurd - Asgardsrei
[GONE] Absurd - Facta Luquuntur (orig! No Colours, #142/500)
Absurd - Tribute to the Tyrants of German Black Metal
Absurd - Werewolfthron
Abysmal - The Pillorian Age
Acid Bath - When the Kite String Pops
# Please take the time to finish this file as described in
# https://sourceforge.net/p/lirc-remotes/wiki/Checklist/
# and make it available to others by sending it to
# <lirc@bartelmus.de>
#
# This config file was automatically generated
# using lirc-0.9.4d(uirt2_raw) on Mon Jul 24 17:43:09 2017
# Command line used: -f -d /dev/ttyUSB0 -H uirt2_raw /tmp/carrera_tower
# Kernel version (uname -r): 4.9.38-1-MANJARO
#
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCwd7CvS2cMaqII2apLlUweBPWM+ExTklNfLpA+Jr672u0fUgvuRfr4ZEMa0YT1rasXpWRTE1TGnJ+T4k20zpFtmNLFGlXWkJVo0j0NagFndLuN/fSPXRQS1u6chd5hVNTocsnRCLvQYQ7R7XBIv1rSa02M3zKj1LOKlGLIzAPiPstpfFgdOksgA3lddcdP25YnHNGbd4KM7otymACnHqamWyz/DKpnBm6J0R1CZq2J4imjE44qDV636Ol7OI95D0TTns0j29vOqP2flz/vig1Ue0EMTBm87Rk0GQYN5ZCiru2gCEpXjZMFx23FfJLv2kpw5nVNNVv6ALLmog2ifCktbh9caUgf86uUhEDoyyIsdNF48EzedLVzXdhXLXO2W3sLGI+7oVh/aQuEIzv2AqvVlKwWGXkqCBIt3hdXzqwTIrrMZIqpdDyH8wZWy8wrU8j+oB1mp+pOeguwN8KFx4ldtE4I0BRBMShltGduzwTnJTIq5n09AsxI4l5MYHpr7v0cACXexQMHqSg+MOmG33qfHFEPdwBgjO36bLRrAhK2VMytK4CDjfbWf2jTyerSzla2YhnR60PMNUTW1nBUALsFdnjpShPoMJMlU7OCXa/86Y0Xcchm7JdAq7Posv4Jwz2Q5XcHBoP+gsfOtYMbht37LaRayOX78f8b6Sm/Ya4Ezw== perunwit@perunwit
function chunks(lst, size, step=1) {
function generate(from, to) {
if (from.length < step) {
return to.concat(from)
}
return generate(from.slice(step, from.length),
to.concat([from.slice(0, size)]))
}
interface Lengthwise {
length: number;
}
function logger<T extends Lengthwise>(arg: T): void {
console.log(arg.length);
}
logger([1,2,3]);
logger({length: 20});