aoc2022/6.rkt

24 lines
586 B
Racket
Raw Normal View History

2022-12-06 05:28:04 +00:00
#lang curly-fn racket
(require "scripts/aoc.rkt")
;; solution for day 6
(define ((part marker-len) input)
(for*/first ([i (in-range marker-len (string-length input))]
[nxt (in-value (substring input (- i marker-len) i))]
#:when (= marker-len (set-count (list->set (string->list nxt)))))
i))
(define part1 (part 4))
(define part2 (part 14))
(define (parse fname)
(string-trim (file->string fname)))
(module+ main
(define input (parse "inputs/6"))
(answer 6 1 (time (part1 input)))
(answer 6 2 (time (part2 input)))
(displayln "meow"))