blob: 60d165471ae15576957d3b7f7faa15d987fbe531 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
;;; solver.el --- Day 06 -*- lexical-binding: t; -*-
;;
;; Copyright (C) 2022 Óscar Nájera
;;
;; Author: Óscar Nájera <hi@oscarnajera.com>
;; Maintainer: Óscar Nájera <hi@oscarnajera.com>
;; Created: December 06, 2022
;; Modified: December 06, 2022
;;
;; This file is not part of GNU Emacs.
;;
;;; Commentary:
;;
;; Day 06
;;
;;; Code:
;;;
(require 'ert)
(defun solver (start-marker-len)
(with-temp-buffer
(insert-file-contents-literally "input")
(goto-char (point-min))
(cl-loop with acc = (make-ring start-marker-len)
for chr = (prog1 (char-after) (forward-char))
do (ring-insert acc chr)
count chr
while (< (length (seq-uniq (ring-elements acc) #'eq)) start-marker-len))))
(ert-deftest test-solver ()
(should (= 1655 (solver 4)))
(should (= 2665 (solver 14))))
|