You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
|
|
|
#lang br/quicklang
|
|
|
|
|
|
|
|
(define (read-syntax path port)
|
|
|
|
(strip-bindings
|
|
|
|
#`(module mod "day03.rkt"
|
|
|
|
#,@(for*/list ([triangle-str (in-list (string-split (port->string port) "\n"))])
|
|
|
|
`(triangle ,@(string-split triangle-str))))))
|
|
|
|
(module+ reader (provide read-syntax))
|
|
|
|
|
|
|
|
(define-macro (mb . TRIANGLES)
|
|
|
|
#'(#%module-begin
|
|
|
|
(length (filter valid-triangle? (list . TRIANGLES)))))
|
|
|
|
(provide (rename-out [mb #%module-begin]))
|
|
|
|
|
|
|
|
(define-macro (triangle A B C)
|
|
|
|
#'(map string->number (list A B C)))
|
|
|
|
(provide triangle)
|
|
|
|
|
|
|
|
(define (valid-triangle? triangle)
|
|
|
|
(match-define (list a b c) triangle)
|
|
|
|
(and (> (+ a b) c)
|
|
|
|
(> (+ b c) a)
|
|
|
|
(> (+ a c) b)))
|