blob: 36aab05d89b7b82ee9fbb828f78676361399ada4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
(defun solver (marker-size)
(with-open-file (in "input" :element-type 'unsigned-byte)
(loop with acc = (make-array marker-size :element-type 'unsigned-byte)
for char = (ash 1 (- (read-byte in) 96)) ;; all lowercase letters thus subtract ascii start
and idx from 1
do (setf (aref acc (mod idx marker-size)) char)
when (<= marker-size (logcount (reduce (lambda (set v) (logxor set v)) acc)))
return idx)))
(ql:quickload :fiveam)
(fiveam:test results
(fiveam:is (= 1655 (solver 4)))
(fiveam:is (= 2665 (solver 14))))
(fiveam:run-all-tests)
|