Commit Diff


commit - dfca954de59ae6453cfc4e6aa21316dbe790a432
commit + 1af7fd644bbac6ad0c08078a59d37b095fbeca10
blob - 022893dd0baa944b9960b3546e89aa61caf49a9f
blob + 214325d6484af1cf963892cff6cbbaff5c01e284
--- src/day-7.lisp
+++ src/day-7.lisp
@@ -3,24 +3,31 @@
   (:export #:day-7))
 (in-package #:aoc/day-7)
 
+(declaim (inline number-digits combine)
+         (ftype (function (fixnum) fixnum) number-digits)
+         (ftype (function (fixnum fixnum) fixnum) combine))
+
 (defun number-digits (number)
   (if (zerop number)
       1
       (1+ (floor (log number 10)))))
 
 (defun combine (num-1 num-2)
-  (+ (* num-1 (expt 10 (number-digits num-2))) num-2))
+  (+ (the fixnum (* num-1
+                    (the fixnum (expt 10 (number-digits num-2)))))
+     num-2))
 
 (defun test-value-valid-p (test-value numbers &optional combine-op)
   (labels ((%solve (test-value numbers combine-op current)
+             (declare (type fixnum current test-value))
              (if (null numbers)
                  (= current test-value)
                  (if (> current test-value)
                      nil
                      (or (%solve test-value (cdr numbers) combine-op
-                                 (+ current (car numbers)))
+                                 (+ current (the fixnum (car numbers))))
                          (%solve test-value (cdr numbers) combine-op
-                                 (* current (car numbers)))
+                                 (* current (the fixnum (car numbers))))
                          (and combine-op
                               (%solve test-value (cdr numbers) combine-op
                                       (combine current (car numbers)))))))))