day 4 part 2 in elisp

day-9-common-lisp
cow 2022-12-08 02:25:31 -05:00
parent 825101c4bd
commit c8064b0c69
No known key found for this signature in database
4 changed files with 12 additions and 12 deletions

View File

@ -0,0 +1 @@
../advent-of-code.el

1
elisp/day-4/example.txt Symbolic link
View File

@ -0,0 +1 @@
../../input/day-4-example.txt

1
elisp/day-4/input.txt Symbolic link
View File

@ -0,0 +1 @@
../../input/day-4.txt

View File

@ -17,18 +17,11 @@
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
(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: