advent-of-code-2024

My solutions to AoC 2024
Log | Files | Refs

commit 2cc3e65b914e81bec626e22ef002ec8bce285259
parent a38ec5924d6dae7738f1b1d04333a40a23c1829a
Author: Lukas Henkel <lh@entf.net>
Date:   Sat,  7 Dec 2024 07:42:22 +0100

Inline some math

Diffstat:
Msrc/day-7.lisp | 9++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/day-7.lisp b/src/day-7.lisp @@ -3,16 +3,23 @@ (: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)