Skip to content

Instantly share code, notes, and snippets.

View DeLaGuardo's full-sized avatar
🎯
Focusing

Kirill Chernyshov DeLaGuardo

🎯
Focusing
View GitHub Profile
(ns user
(:require [clojure.core.async :as async]))
(defn now-millis []
(System/currentTimeMillis))
(defn throttled-chan
"Returns a channel that will throttle attempts to take items according to the rate-limits.
rate-limits should be a sequence of pairs of integers. The first item in each pair
is describing how many items is possible to take, at most, from the input for the interval
(ns omnitech.shims)
(defn- closest [selector]
(this-as node
(let [node-list (.querySelectorAll js/document selector)
all (mapv #(aget node-list %) (range 0 (.-length node-list)))]
(loop [node node]
(let [parent (.-parentNode node)]
(if (some #(= parent %) all)
parent
@DeLaGuardo
DeLaGuardo / d11.clj
Created December 11, 2024 13:14
aoc24_d11
(require '[clojure.string :as string])
(def blink
(memoize
(fn [times n]
(if (zero? times)
1
(let [l (count n)
l-half (bit-shift-right l 1)
even? (= (+ l-half l-half) l)]