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.
20 lines
553 B
Racket
20 lines
553 B
Racket
#lang br
|
|
(require racket/file rackunit)
|
|
|
|
(define depths (map string->number (file->lines "01.rktd")))
|
|
|
|
(define (positive-deltas depths)
|
|
(filter positive?
|
|
(for/list ([d1 (in-list depths)]
|
|
[d2 (in-list (cdr depths))])
|
|
(- d2 d1))))
|
|
|
|
(check-equal? (length (positive-deltas depths)) 1167)
|
|
|
|
(define (trios depths)
|
|
(for/list ([d1 (in-list depths)]
|
|
[d2 (in-list (cdr depths))]
|
|
[d3 (in-list (cddr depths))])
|
|
(+ d1 d2 d3)))
|
|
|
|
(check-equal? (length (positive-deltas (trios depths))) 1130) |