Compare commits

..

No commits in common. "cd1fd7f9c63afec57a568b77f373bef88883f248" and "f8735258a4ffc7f558fbd10bad91f194871ecff7" have entirely different histories.

4 changed files with 18 additions and 31 deletions

View file

@ -12,6 +12,7 @@
#:cl-cookie #:cl-cookie
#:plump #:plump
#:lquery #:lquery
#:fiveam
#:array-operations #:array-operations
#:lla) #:lla)
:components ((:module "src" :components ((:module "src"
@ -26,7 +27,7 @@
:author "Peter Tillemans" :author "Peter Tillemans"
:license "MIT" :license "MIT"
:depends-on ("aoc" :depends-on ("aoc"
#:parachute) "rove")
:components ((:module "tests" :components ((:module "tests"
:components :components
((:file "main")))) ((:file "main"))))

View file

@ -1,9 +1,10 @@
(defpackage :aoc/2018/06 (defpackage :aoc/2018/06
(:use :cl :aoc)) (:use :cl :aoc :fiveam))
(in-package :aoc/2018/06) (in-package :aoc/2018/06)
(defvar input-data (test-input 2018 6)) (defvar test-data (test-input 2018 6))
(defstruct point-2d (defstruct point-2d
(x 0 :type fixnum) (x 0 :type fixnum)
@ -31,3 +32,13 @@
(y-max (apply #'max (map 'list #'point-2d-y points) ))) (y-max (apply #'max (map 'list #'point-2d-y points) )))
(make-point-2d :x x-max :y y-max))) (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))))

View file

@ -37,20 +37,11 @@
(defun fetch-input-data (year day) (defun test-input (year day)
(let ((url (format nil "~A/~D/day/~D/input" *aoc-url* year day))) (let ((url (format nil "~A/~D/day/~D/input" *aoc-url* year day)))
(multiple-value-bind (multiple-value-bind
(body) (body)
(dex:get url :cookie-jar *cookie-jar* :verbose t) (dex:get url :cookie-jar *cookie-jar* :verbose t)
body))) 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)))))

View file

@ -1,16 +0,0 @@
(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))))