tidy day1

master-blaster
Matthew Butterick 9 years ago
parent 213bf28eab
commit 08d30beb03

@ -1,9 +1,18 @@
#lang scribble/lp2
@(require scribble/manual "../helper.rkt")
@(require scribble/manual aoc-racket/helper)
@aoc-title[1]
Our @(input) is a string of parentheses that controls an elevator. A left parenthesis @litchar{(} means go up one floor, and a right parenthesis @litchar{)} means go down.
Our @link-rp["day1/input.txt"]{input} is a string of parentheses that controls an elevator. A left parenthesis @litchar{(} means go up one floor, and a right parenthesis @litchar{)} means go down.
@chunk[<day1>
<setup>
<q1>
<q1-alt>
<q2>
<q2-alt>
<test>]
@section{Where does the elevator land?}
@ -108,13 +117,4 @@ The two are similar. The choice comes down to readability and efficiency — me
(check-equal? (q2-for/first input-str) 1795)
(check-equal? (q2-for/or input-str) 1795))]
@section{Joining the parts}
@chunk[<*>
<setup>
<q1>
<q1-alt>
<q2>
<q2-alt>
<test>]

@ -1,10 +1,18 @@
#lang at-exp racket/base
(require scribble/manual)
(provide (all-defined-out))
(require (for-syntax racket/base racket/syntax) racket/runtime-path)
(provide (for-syntax #%datum))
(define (aoc-title which)
(define which-str (number->string which))
@title[#:style manual-doc-style]{@link[@string-append["http://adventofcode.com/day/" @which-str]]{Day @which-str}})
@title[#:style manual-doc-style]{@link[@string-append["http://adventofcode.com/day/" @which-str]]{Day @which-str}})
(define (input)
@link["input.txt"]{input})
(define-syntax (link-rp stx)
(syntax-case stx ()
[(_ where text-args ...)
(with-syntax ([rp-name (generate-temporary)])
#'(begin
(require racket/runtime-path)
(define-runtime-path rp-name (expand-user-path where))
@(link (path->string rp-name) text-args ...)))]))