Created
December 3, 2020 01:37
-
-
Save dvanhorn/4329656c291b41ce2372f719f652a931 to your computer and use it in GitHub Desktop.
Advent of Code, Day 2, Part II
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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