src/2016/days/day-06.lisp @ ff7c8ed35992

2021/01 (and add uncommitted stuff from 2020)
author Steve Losh <steve@stevelosh.com>
date Wed, 01 Dec 2021 20:54:23 -0500
parents 182bdd87fd9e
children (none)
(advent:defpackage* :advent/2016/06)
(in-package :advent/2016/06)

(defun freqs (lines)
  (iterate
    (for i :from 0 :below (length (first lines)))
    (collect (frequencies lines :key (rcurry #'elt i)))))

(defun freq-extrema (predicate freqs)
  (_ freqs
     alexandria:hash-table-alist
     (extrema predicate _ :key #'cdr)
     car))

(define-problem (2016 6) (data read-lines) ("nabgqlcw" "ovtrjcjh")
  (values
    (map 'string (curry #'freq-extrema #'>) (freqs data))
    (map 'string (curry #'freq-extrema #'<) (freqs data))))



#; Scratch --------------------------------------------------------------------