Skip to content

Instantly share code, notes, and snippets.

@dvanhorn
Created December 3, 2020 01:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dvanhorn/4329656c291b41ce2372f719f652a931 to your computer and use it in GitHub Desktop.
Save dvanhorn/4329656c291b41ce2372f719f652a931 to your computer and use it in GitHub Desktop.
Advent of Code, Day 2, Part II
#lang racket
(define in "...")
(count (λ (x)
(match (regexp-match #rx"([0-9]*)-([0-9]*) ([a-z]): (.*)" x)
[(list _
(app string->number low)
(app string->number high)
(app string->list (list a))
(app string->list cs))
(xor (char=? a (list-ref cs (sub1 low)))
(char=? a (list-ref cs (sub1 high))))]))
(with-input-from-string in port->lines))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment