2016
Matthew Butterick 8 years ago
parent 3ba5818afd
commit 5924352c7a

@ -1,7 +1,6 @@
#lang br/quicklang
(module+ reader
(provide read-syntax)
(define (read-syntax path port)
(define (read-syntax path port)
(define turn-strings (string-split (port->string port) ","))
(define turn-pattern #px"^([LR])(\\d+)$")
(define turn-datums
@ -10,7 +9,8 @@
`(turn ,@(cdr (or match-result empty)))))
(strip-bindings
#`(module day01-mod "day01.rkt"
#,@turn-datums))))
#,@turn-datums)))
(module+ reader (provide read-syntax))
(define-macro (mb . TURNS)
#'(#%module-begin

@ -1,14 +1,14 @@
#lang br/quicklang
(module+ reader
(provide read-syntax)
(define (read-syntax path port)
(define (read-syntax path port)
(define moveset-strs (string-split (port->string port)))
(define moveset-datums
(for*/list ([msstr (in-list moveset-strs)])
`(moveset ,@(regexp-match* #rx"." msstr))))
(strip-bindings
#`(module day01-mod "day02.rkt"
#,@moveset-datums))))
#,@moveset-datums)))
(module+ reader (provide read-syntax))
(define-macro moveset #'list)
(provide moveset)

@ -1,14 +1,14 @@
#lang br/quicklang
(module+ reader
(provide read-syntax)
(define (read-syntax path port)
(define (read-syntax path port)
(define moveset-strs (string-split (port->string port)))
(define moveset-datums
(for*/list ([msstr (in-list moveset-strs)])
`(moveset ,@(regexp-match* #rx"." msstr))))
(strip-bindings
#`(module day01-mod "day02b.rkt"
#,@moveset-datums))))
#,@moveset-datums)))
(module+ reader (provide read-syntax))
(define-macro moveset #'list)
(provide moveset)

@ -13,9 +13,7 @@
(provide (rename-out [mb #%module-begin]))
(define-macro (triangle A B C)
#'(list (string->number A)
(string->number B)
(string->number C)))
#'(map string->number (list A B C)))
(provide triangle)
(define (valid-triangle? triangle)

@ -1,9 +1,7 @@
#lang br/quicklang
(require sugar/list)
(module+ reader
(provide read-syntax)
(define (read-syntax path port)
(define (read-syntax path port)
(define triads (slice-at (map string-split (string-split (port->string port) "\n")) 3))
(define new-triples
(slice-at (flatten (for/list ([triad (in-list triads)])
@ -11,7 +9,8 @@
(strip-bindings
#`(module mod "day03b.rkt"
#,@(for*/list ([triple (in-list new-triples)])
`(triangle ,@triple))))))
`(triangle ,@triple)))))
(module+ reader (provide read-syntax))
(define-macro (mb . TRIANGLES)
#'(#%module-begin
@ -19,9 +18,7 @@
(provide (rename-out [mb #%module-begin]))
(define-macro (triangle A B C)
#'(list (string->number A)
(string->number B)
(string->number C)))
#'(map string->number (list A B C)))
(provide triangle)
(define (valid-triangle? triangle)

@ -1,12 +1,12 @@
#lang br/quicklang
(module+ reader
(provide read-syntax)
(define (read-syntax path port)
(define (read-syntax path port)
(strip-bindings
#`(module mod "day04.rkt"
#,@(for*/list ([room-str (in-lines port)]
#:when (not (equal? "" room-str)))
`(room ,@(cdr (regexp-match #px"^(.*)-(\\d+)\\[(\\w+)\\]$" room-str))))))))
`(room ,@(cdr (regexp-match #px"^(.*)-(\\d+)\\[(\\w+)\\]$" room-str)))))))
(module+ reader (provide read-syntax))
#|
Each room consists of an encrypted name (lowercase letters separated by dashes)