2021-12-09 19:06:53 +00:00
|
|
|
(import (chicken io))
|
|
|
|
(import (chicken string))
|
|
|
|
(import (chicken format))
|
2021-12-14 13:27:07 +00:00
|
|
|
(import srfi-113)
|
2021-12-09 19:06:53 +00:00
|
|
|
(import srfi-1)
|
2021-12-14 13:27:07 +00:00
|
|
|
(import srfi-128)
|
2021-12-09 19:06:53 +00:00
|
|
|
|
|
|
|
(define (summap a b) (foldl + 0 (map a b)))
|
|
|
|
|
|
|
|
(define (displayln x) (format #t "~s~%" x))
|
|
|
|
|
|
|
|
(define (split-line line)
|
|
|
|
(let ((halves (string-split line "|")))
|
|
|
|
(map string-split halves)))
|
|
|
|
|
2021-12-14 13:27:07 +00:00
|
|
|
;; PART 1
|
2021-12-09 19:06:53 +00:00
|
|
|
(define (is-1478 pattern)
|
|
|
|
(let ((len (string-length pattern)))
|
|
|
|
(not (or (eq? len 5) (eq? len 6)))))
|
|
|
|
|
|
|
|
(define (count-1478 parsed)
|
|
|
|
(let-values (((patterns output) (apply values parsed)))
|
|
|
|
(count is-1478 output)))
|
|
|
|
|
2021-12-14 13:27:07 +00:00
|
|
|
(define lines (read-lines))
|
|
|
|
(define parsed-lines (map split-line lines))
|
|
|
|
|
|
|
|
(let ((part1 (summap count-1478 parsed-lines)))
|
|
|
|
(display "part1: ")
|
|
|
|
(displayln part1))
|