Created
December 3, 2020 18:55
-
-
Save dvanhorn/103f539194fea6d0bf58ff3a46014200 to your computer and use it in GitHub Desktop.
Advent of Code, Day 3, Part II
This file contains hidden or 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 "...") | |
(define (string-ref-mod xs i) | |
(string-ref xs (modulo i (string-length xs)))) | |
(define lines (call-with-input-string in port->lines)) | |
(define (c δx δy) | |
(for/sum ([x (in-range 0 +inf.0 δx)] | |
[y (in-range 0 +inf.0 δy)] | |
#:break (>= y (length lines))) | |
(if (char=? #\# (string-ref-mod (list-ref lines y) x)) | |
1 | |
0))) | |
(* (c 1 1) | |
(c 3 1) | |
(c 5 1) | |
(c 7 1) | |
(c 1 2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment