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
(defun aoc-day3-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)) |
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
;; The captcha requires you to review a sequence of digits (your puzzle input) and find the sum of | |
;; all digits that match the next digit in the list. The list is circular, so the digit after the | |
;; last digit is the first digit in the list. | |
(defun aoc-string-to-numbers (input) | |
(mapcar (lambda (c) (- c ?0)) | |
(string-to-list input))) | |
(defun aoc-day1-1 (input) | |
(let* ((in-list (aoc-string-to-numbers input)) |
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
(defun ca-vectorize () | |
(let* ((line (thing-at-point 'line t)) | |
(ll (string-to-list line)) | |
(result (make-vector (1- (length ll)) 0))) ; skip newline | |
(loop for c in ll | |
for i below (length ll) | |
do (unless (equal c ?\n) | |
(if (equal c ?\s) | |
(setf (elt result i) 0) | |
(setf (elt result i) 1)))) |
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
(defun ca-vectorize () | |
(let* ((line (thing-at-point 'line t)) | |
(ll (string-to-list line)) | |
(result (make-vector (1- (length ll)) 0))) ; skip newline | |
(loop for c in ll | |
for i below (length ll) | |
do (unless (equal c ?\n) | |
(if (equal c ?\s) | |
(setf (elt result i) 0) | |
(setf (elt result i) 1)))) |
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
(defun ca-vectorize () | |
(let* ((line (thing-at-point 'line t)) | |
(ll (string-to-list line)) | |
(result (make-vector (1- (length ll)) 0))) ; skip newline | |
(loop for c in ll | |
for i below (length ll) | |
do (unless (equal c ?\n) | |
(if (equal c ?\s) | |
(setf (elt result i) 0) | |
(setf (elt result i) 1)))) |
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
(defun catalan-next-row (v) | |
(if (or (null v) | |
(= (length v) 0)) | |
[1] | |
(let ((r (make-vector (1+ (length v)) 1))) | |
(dotimes (x (length v)) | |
(unless (= x 0) | |
(setf (aref r x) | |
(+ (aref v x) | |
(aref r (1- x)))))) |
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
(defun my/move-to-middle () | |
(interactive) | |
(let* ((begin (line-beginning-position)) | |
(end (line-end-position)) | |
(middle (+ begin (/ (- end begin) 2)))) | |
(goto-char middle))) | |
(global-set-key (kbd "C-c m") 'my/move-to-middle) |
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
;; -*- mode: emacs-lisp -*- | |
;; This file is loaded by Spacemacs at startup. | |
;; It must be stored in your home directory. | |
(defun dotspacemacs/layers () | |
"Configuration Layers declaration. | |
You should not put any user code in this function besides modifying the variable | |
values." | |
(setq-default | |
;; Base distribution to use. This is a layer contained in the directory |
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
(defun filter (&rest args) ; args = list of all arguments | |
(let ((factors (list -1 -1 -1 | |
-1 8 -1 | |
-1 -1 -1))) | |
(reduce '+ (mapcar* '* factors args)))) | |
(filter 10 20 30 40 50 60 70 80 90) | |
;; => 0 |
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
(defun filter (&rest args) ; args = list of all arguments | |
(let ((factors (list -1 -1 -1 | |
-1 8 -1 | |
-1 -1 -1))) | |
(reduce '+ (map '* factors args)))) |