Compare commits
2 commits
f8735258a4
...
cd1fd7f9c6
Author | SHA1 | Date | |
---|---|---|---|
cd1fd7f9c6 | |||
5540e02509 |
4 changed files with 31 additions and 18 deletions
3
aoc.asd
3
aoc.asd
|
@ -12,7 +12,6 @@
|
|||
#:cl-cookie
|
||||
#:plump
|
||||
#:lquery
|
||||
#:fiveam
|
||||
#:array-operations
|
||||
#:lla)
|
||||
:components ((:module "src"
|
||||
|
@ -27,7 +26,7 @@
|
|||
:author "Peter Tillemans"
|
||||
:license "MIT"
|
||||
:depends-on ("aoc"
|
||||
"rove")
|
||||
#:parachute)
|
||||
:components ((:module "tests"
|
||||
:components
|
||||
((:file "main"))))
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
(defpackage :aoc/2018/06
|
||||
(:use :cl :aoc :fiveam))
|
||||
(:use :cl :aoc))
|
||||
|
||||
(in-package :aoc/2018/06)
|
||||
|
||||
(defvar test-data (test-input 2018 6))
|
||||
|
||||
(defvar input-data (test-input 2018 6))
|
||||
|
||||
(defstruct point-2d
|
||||
(x 0 :type fixnum)
|
||||
|
@ -32,13 +31,3 @@
|
|||
(y-max (apply #'max (map 'list #'point-2d-y points) )))
|
||||
(make-point-2d :x x-max :y y-max)))
|
||||
|
||||
(def-suite 2018-day-6)
|
||||
(in-suite 2018-day-6)
|
||||
|
||||
(test find-top-left
|
||||
(let ((result (top-left sample-points)))
|
||||
(is (equalp (make-point-2d :x 1 :y 1) result))))
|
||||
|
||||
(test find-bottom-right
|
||||
(let ((result (bottom-right sample-points)))
|
||||
(is (equalp (make-point-2d :x 8 :y 9) result))))
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
|
||||
|
||||
(defun test-input (year day)
|
||||
(defun fetch-input-data (year day)
|
||||
(let ((url (format nil "~A/~D/day/~D/input" *aoc-url* year day)))
|
||||
(multiple-value-bind
|
||||
(body)
|
||||
|
@ -45,3 +45,12 @@
|
|||
body)))
|
||||
|
||||
|
||||
(defvar *input-data-cache* (make-hash-table))
|
||||
|
||||
(defun test-input (year day)
|
||||
"Return input data for the given challenge. Use a cached value if already fetched"
|
||||
(let* ((key (+ (* year 100) day))
|
||||
(val (gethash key *input-data-cache*)))
|
||||
(if val
|
||||
val
|
||||
(setf (gethash key *input-data-cache*) (fetch-input-data year day)))))
|
||||
|
|
16
test/2018/day06-test.lisp
Normal file
16
test/2018/day06-test.lisp
Normal file
|
@ -0,0 +1,16 @@
|
|||
(defpackage :aoc/2018/06
|
||||
(:use :cl :aoc :parachute))
|
||||
|
||||
(in-package :aoc/2018/06)
|
||||
|
||||
(define-test suite-2018-06)
|
||||
|
||||
(define-test+run find-top-left
|
||||
:parent suite-2018-06
|
||||
(let ((result (top-left sample-points)))
|
||||
(true (equalp (make-point-2d :x 1 :y 1) result))))
|
||||
|
||||
(define-test+run find-bottom-right
|
||||
:parent suite-2018-06
|
||||
(let ((result (bottom-right sample-points)))
|
||||
(true (equalp (make-point-2d :x 8 :y 9) result))))
|
Loading…
Add table
Reference in a new issue