diff --git a/elisp/day-4/advent-of-code.el b/elisp/day-4/advent-of-code.el new file mode 120000 index 0000000..4a02002 --- /dev/null +++ b/elisp/day-4/advent-of-code.el @@ -0,0 +1 @@ +../advent-of-code.el \ No newline at end of file diff --git a/elisp/day-4/example.txt b/elisp/day-4/example.txt new file mode 120000 index 0000000..aaad177 --- /dev/null +++ b/elisp/day-4/example.txt @@ -0,0 +1 @@ +../../input/day-4-example.txt \ No newline at end of file diff --git a/elisp/day-4/input.txt b/elisp/day-4/input.txt new file mode 120000 index 0000000..a52d0a3 --- /dev/null +++ b/elisp/day-4/input.txt @@ -0,0 +1 @@ +../../input/day-4.txt \ No newline at end of file diff --git a/elisp/day-4/solution.el b/elisp/day-4/solution.el index 14aafa9..e1700a0 100755 --- a/elisp/day-4/solution.el +++ b/elisp/day-4/solution.el @@ -17,18 +17,11 @@ ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . -(add-to-list 'load-path "../") +(add-to-list 'load-path default-directory) (require 'ert) -(require 'cl-lib) (require 'advent-of-code) -(defvar solution-input - "../../input/day-4.txt") - -(defvar solution-example-input - "../../input/day-4-example.txt") - (defun solution-parse-pair (s) (let ((parts (string-split s "-"))) (cons (string-to-number (car parts)) @@ -64,16 +57,20 @@ pairs))) (ert-deftest solution-part-1-example () - (should (equal (solution-part-1 (aoc-read-file-lines solution-example-input)) 2))) + (should (equal (solution-part-1 (aoc-read-file-lines "example.txt")) 2))) (ert-deftest solution-part-1 () - (should (equal (solution-part-1 (aoc-read-file-lines solution-input)) 644))) + (should (equal (solution-part-1 (aoc-read-file-lines "input.txt")) 644))) + +(ert-deftest solution-part-2-example () + (should (equal (solution-part-2 (aoc-read-file-lines "example.txt")) 4))) + +(ert-deftest solution-part-2 () + (should (equal (solution-part-2 (aoc-read-file-lines "input.txt")) 926))) (when noninteractive (ert-run-tests-batch)) -;; Code - ;; Local Variables: ;; read-symbol-shorthands: (("solution-" . "advent-of-code-day-4-") ("aoc-" . "advent-of-code-")) ;; End: