This file contains hidden or 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
; wavetables | |
(def andW (make-wt 8000 | |
(fn [x] (if (> x 0.5) 1 -1)))) | |
(def xorW (make-wt 8000 | |
(fn [x] (if (< (abs x) 0.5) 1 -1)))) | |
(def bufferW (make-wt 8000 | |
(fn [x] (if (> x 0.01) 1 -1)))) | |
(def notW (hardsat -10)) | |
; waveshapers |
This file contains hidden or 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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
int main() { | |
int acc = 0; | |
int buf = 0; | |
char *data = NULL; | |
char *start; | |
struct { |
This file contains hidden or 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
(define (slurp f . args) | |
(let loop () | |
(define head (apply f args)) | |
(if (eof-object? head) | |
'() | |
(cons head (loop))))) | |
(define (classify ch) | |
(case ch | |
[(#\#) #t] |
This file contains hidden or 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
from __future__ import annotations | |
from dataclasses import dataclass | |
def prod(args): | |
out = 1 | |
for i in args: | |
out *= i | |
return out |
This file contains hidden or 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
pipe_types = { | |
"-": [(-1, 0), (1, 0)], | |
"|": [(0, -1), (0, 1)], | |
"7": [(-1, 0), (0, 1)], | |
"F": [(-1, 0), (0, -1)], | |
"J": [(1, 0), (0, 1)], | |
"L": [(1, 0), (0, -1)], | |
} | |
def nbrs(pos): |
This file contains hidden or 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 Control.Arrow ((&&&)) | |
trapolate :: ([Integer] -> Integer -> Integer) -> [Integer] -> Integer | |
trapolate f ls | all (== 0) ls = 0 | |
| otherwise = f ls $ trapolate f (zipWith (-) (tail ls) ls) | |
main :: IO () | |
main = ((sum . map (trapolate ((+) . last)) &&& sum . map (trapolate ((-) . head))) . map (map read . words) . lines <$> getContents) >>= print |
This file contains hidden or 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
#include <stdio.h> | |
#include <stdlib.h> | |
typedef enum { | |
C_ACE, C_KING, C_QUEEN, C_JACK, | |
C_TEN, C_NINE, C_EIGHT, C_SEVEN, | |
C_SIX, C_FIVE, C_FOUR, C_THREE, | |
C_TWO | |
} card_t; |
This file contains hidden or 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
#include <iostream> | |
#include <sstream> | |
#include <string> | |
#include <vector> | |
#include <limits> | |
#include <map> | |
#include <algorithm> | |
struct Range { | |
int64_t start, end; |
This file contains hidden or 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
(set! *warn-on-reflection* true) | |
(def data | |
(with-open [rdr (clojure.java.io/reader "day03.in")] | |
(reduce conj [] (line-seq rdr)))) | |
(defn access [data [x y]] | |
(when (< -1 x (count data)) | |
(let [row (nth data x)] | |
(when (< -1 y (count row)) |
This file contains hidden or 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 Control.Applicative ((<|>), Alternative) | |
import Control.Arrow ((&&&)) | |
import Control.Monad (guard) | |
import Data.Bifunctor (bimap) | |
import Data.Char (digitToInt, isDigit) | |
import Data.List (findIndex, tails, isPrefixOf) | |
import Data.Maybe (catMaybes, listToMaybe) | |
parse :: Alternative f => Char -> f Int | |
parse s = guard (isDigit s) *> pure (digitToInt s) |