commit 5ade9b08107717f9ddd2222eadf5ff5393113d1b
parent d2f25f66d712a2d3cfdfa79a23a4df06dc2d8922
Author: Lukas Henkel <lh@entf.net>
Date: Wed, 6 Dec 2023 20:35:22 +0100
Range is symmetrical
Diffstat:
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/src/day-6.lisp b/src/day-6.lisp
@@ -14,11 +14,8 @@
(defun possible-ways-to-beat (time distance)
(let ((start (loop for speed from 1 below time
when (beats-distance-p speed time distance)
- do (return speed)))
- (end (loop for speed from (1- time) downto 1
- when (beats-distance-p speed time distance)
- do (return speed))))
- (- end start -1)))
+ do (return speed))))
+ (- time (* start 2) -1)))
(defun join-numbers (numbers)
(parse-integer (apply 'concatenate 'string