a1c5d160d738
Cleanup
author | Steve Losh <steve@stevelosh.com> |
---|---|
date | Fri, 03 Dec 2021 12:43:45 -0500 |
parents | 08dd2b57f2c0 |
children | 77fa6a483e0e |
branches/tags | (none) |
files | src/2021/days/day-03.lisp |
Changes
--- a/src/2021/days/day-03.lisp Fri Dec 03 12:36:07 2021 -0500 +++ b/src/2021/days/day-03.lisp Fri Dec 03 12:43:45 2021 -0500 @@ -1,8 +1,8 @@ (advent:defpackage* :advent/2021/03) (in-package :advent/2021/03) -(defun bool->bit (b) (if b 1 0)) -(defun char->δ (ch) (ecase ch (#\0 -1) (#\1 1))) +(defun-inline bool->bit (b) (if b 1 0)) +(defun-inline char->δ (ch) (ecase ch (#\0 -1) (#\1 1))) (defun count-bits (data) (iterate @@ -23,7 +23,7 @@ (with lo = 0) (with hi = (1- (length sorted-data))) (when (= lo hi) - (return (digits->number (aref sorted-data lo) :radix 2 :key #'digit-char-p))) + (return (parse-integer (aref sorted-data lo) :radix 2))) (for i :from 0) (for count = (iterate (for candidate :in-vector sorted-data :from lo :to hi) (summing (char->δ (aref candidate i)))))