Skip to content

Instantly share code, notes, and snippets.

;; -*- lexical-binding: t -*-
(defstruct scanner
(depth 0)
(range 0))
(defun score (scanner &optional delay)
(unless delay (setf delay 0))
(if (= 0 (mod (+ (scanner-depth scanner) delay)
(* 2 (1- (scanner-range scanner)))))
(setf day10-input "189,1,111,246,254,2,0,120,215,93,255,50,84,15,94,62")
(defun reverse-sublist (list beg end)
(let ((rotated-list (-rotate (- beg)
list))
(nend (- end beg)))
(setf (subseq rotated-list 0 nend) (reverse (subseq rotated-list 0 nend)))
(-rotate beg rotated-list)))
(defun make-hash-list (size)
(setf day10-input '(189 1 111 246 254 2 0 120 215 93 255 50 84 15 94 62))
(defun reverse-sublist (list beg end)
(let ((rotated-list (-rotate (- beg) list))
(nend (- end beg)))
(setf (subseq rotated-list 0 nend) (reverse (subseq rotated-list 0 nend)))
(-rotate beg rotated-list)))
(defun make-hash-list (size)
(let ((result '()))
(defstruct state (sum 0) (garbage-sum 0) (group-depth 0) in-garbage after-!)
(defun process-character (s character)
(if (state-in-garbage s)
(if (state-after-! s)
(setf (state-after-! s) nil)
;; Process stuff inside garbage
(case character
(?! (setf (state-after-! s) t))
(?> (setf (state-in-garbage s) nil))
(setq registers (make-hash-table :test 'equal))
(setq highest-value-throughout-program 0)
(defun get-lines-from-input (buffername)
(with-current-buffer buffername
(split-string (buffer-substring (point-min) (point-max)) "\n" t)))
(defun process-single-line (line)
(multiple-value-bind (destination operation amount _ source comparator threshold)
(split-string line " ")
/**
* Usage
*/
Test t = Test.create()
.withMember(42)
.withString("hello")
.withString("world")
.build();
(defun create-grid ()
(let ((grid (make-vector aoc-size 0)))
(dotimes (i aoc-size)
(setf (aref grid i) (make-vector aoc-size 0)))
(setf (aref (aref grid center)
center) 1)
grid))
(defun get-cell (x y)
(cond
(defun create-grid ()
(let ((grid (make-vector aoc-size 0)))
(dotimes (i aoc-size)
(setf (aref grid i) (make-vector aoc-size 0)))
(setf (aref (aref grid center)
center) 1)
grid))
(defun get-cell (x y)
(cond
(defun aoc-day4-1 (input)
(let ((num-correct-passphrases 0))
(dolist (passphrase input)
(let ((words (split-string passphrase " ")))
(when (= (length words)
(length (delete-dups words)))
(incf num-correct-passphrases))))
num-correct-passphrases))
(defun aoc-sort-string (str)
(defvar day4input '("nyot babgr babgr kqtu kqtu kzshonp ylyk psqk"
"iix ewj rojvbkk phrij iix zuajnk tadv givslju ewj bda"
"isjur jppvano vctnpjp ngwzdq pxqfrk mnxxes zqwgnd giqh"
"ojufqke gpd olzirc jfao cjfh rcivvw pqqpudp"
"ilgomox extiffg ylbd nqxhk lsi isl nrho yom"
"feauv scstmie qgbod enpltx jrhlxet qps lejrtxh"
"wlrxtdo tlwdxor ezg ztp uze xtmw neuga aojrixu zpt"
"wchrl pzibt nvcae wceb"
"rdwytj kxuyet bqnzlv nyntjan dyrpsn zhi kbxlj ivo"
"dab mwiz bapjpz jbzppa"