This file contains 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
(ns bike-bingo | |
(:require | |
;; We'll use cl-format to draw the board. | |
[clojure.contrib.pprint :as pp])) | |
;; Here's our 5x5 bingo board. We're counting horizontal, vertical, | |
;; diagonal, four corners, and blackout. The numbers in each square | |
;; represent how many bingos that square is involved in (excluding | |
;; blackout). | |
;; |
This file contains 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 Common Lisp library for Emacs Lisp gives us keyword arguments | |
;; for defun* | |
(require 'cl) | |
(defvar projects (list) "This keeps track of all available projects.") | |
(defvar project (list) "And here's our current project.") | |
(defvar project-index (list) "This will store the project index of files.") | |
(defvar project-default-filetypes | |
'("*.el" "*.rb" "*.py" "*.rb" "*.clj" "*.php" "*.js" "*.html") | |
"Files for indexing.") |
This file contains 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 color-theme-ps-warm () | |
"A color theme based on Vim's PS Warm 2." | |
(interactive) | |
(color-theme-install | |
'(color-theme-ps-warm | |
((background-color . "#111111") | |
(background-mode . dark) | |
(border-color . "#888a85") | |
(cursor-color . "#fce94f") | |
(foreground-color . "#eeeeec") |
This file contains 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
(ns advent.a1 | |
(:require [clojure.string :as str])) | |
(let [a1 (slurp "a1.txt")] | |
(- (count (re-seq #"\(" a1)) | |
(count (re-seq #"\)" a1)))) | |
(loop [chars (str/trim (slurp "a1.txt")) v 0 p 0] | |
(if (= -1 v) p | |
(let [c (first chars)] |
This file contains 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
(ns advent.a2 | |
(:require [clojure.string :as str])) | |
(defn parse-int [s] | |
(Integer/parseInt s)) | |
(let [text (slurp "a2.txt")] | |
(reduce + (for [line (str/split-lines text)] | |
(let [[l w h] (str/split line #"x") | |
[l w h] (map #(Integer/parseInt %) [l w h]) |
This file contains 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
(ns advent.a3 | |
(:require [clojure.string :as str])) | |
(let [a3 (str//trim (slurp "a3.txt"))] | |
(count | |
(loop [cs (seq a3) p [0 0] ps #{[0 0]}] | |
(if-not (seq cs) ps | |
(let [c (first cs) | |
[x y] p | |
next (condp = c |
This file contains 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 qualified Data.Hash.MD5 as MD5 | |
main = do | |
print $ head $ [ n | n <- [0..] , (==) "000000" $ take 6 $ (MD5.md5s . MD5.Str) ("bgvyzdsv" ++ (show n)) ] |
This file contains 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
(let [a5 (slurp "a5.txt") | |
lines (str/split-lines a5)] | |
(count (filter (fn [s] (and | |
(not (re-find #"ab|cd|pq|xy" s)) | |
(re-find #"(.)\1" s) | |
(>= (count (re-seq #"[aeiou]" s)) 3))) | |
lines))) |
This file contains 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
#lang racket | |
(require racket/match) | |
(define (get-coords sx sy ex ey) | |
(for*/list ([x (in-range sx (+ 1 ex))] | |
[y (in-range sy (+ 1 ey))]) | |
(list x y))) | |
(define (parse s) | |
(match-let ([(list _ cmd sx sy ex ey) |
This file contains 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 Prelude | |
import Text.Regex | |
import qualified Data.HashMap.Strict as HashMap | |
type Board = HashMap.HashMap Int (HashMap.HashMap Int Bool) | |
type Coord = (Int,Int) | |
getCoords :: Coord -> Coord -> [Coord] | |
getCoords (sx,sy) (ex,ey) = [ (x,y) | x <- [sx..ex], y <- [sy..ey] ] |
OlderNewer