aboutsummaryrefslogtreecommitdiff
path: root/2015/day-02/day-02.rkt
diff options
context:
space:
mode:
authorHunky Jimpjorps <thechairman@thechairman.info>2022-11-26 01:43:33 -0500
committerHunky Jimpjorps <thechairman@thechairman.info>2022-11-26 01:43:33 -0500
commitfeccf3f6f0a806b3317d1f399e3e8b42945c4f09 (patch)
treebf15ce045d1106c1b7f7de30c27540f40d0bf947 /2015/day-02/day-02.rkt
parent8b624fe7d2751337b1f16830cc9c041df73e99e7 (diff)
downloadgleam_aoc-feccf3f6f0a806b3317d1f399e3e8b42945c4f09.tar.gz
gleam_aoc-feccf3f6f0a806b3317d1f399e3e8b42945c4f09.zip
using raco fmt, replacing missing dependency
Diffstat (limited to '2015/day-02/day-02.rkt')
-rw-r--r--2015/day-02/day-02.rkt34
1 files changed, 6 insertions, 28 deletions
diff --git a/2015/day-02/day-02.rkt b/2015/day-02/day-02.rkt
index 870e380..579fd00 100644
--- a/2015/day-02/day-02.rkt
+++ b/2015/day-02/day-02.rkt
@@ -7,42 +7,20 @@
(define presents
(for/list ([size-string (in-lines (open-day 2 2015))])
- (~> size-string
- (string-split "x")
- (map string->number _)
- (apply present _))))
+ (~> size-string (string-split "x") (map string->number _) (apply present _))))
;; part 1
(define (paper-area p)
- (define main-area
- (~> p
- struct->list
- (combinations 2)
- (map (λ~> (apply * 2 _)) _)
- (apply + _)))
- (define slack-area
- (~> p
- struct->list
- (sort <)
- (take 2)
- (apply * _)))
+ (define main-area (~> p struct->list (combinations 2) (map (λ~> (apply * 2 _)) _) (apply + _)))
+ (define slack-area (~> p struct->list (sort <) (take 2) (apply * _)))
(+ main-area slack-area))
(for/sum ([p (in-list presents)]) (paper-area p))
;; part 2
(define (ribbon-length p)
- (define ribbon-around-box
- (~> p
- struct->list
- (sort <)
- (take 2)
- (map (λ~> (* 2)) _)
- (apply + _)))
- (define ribbon-for-bow
- (~> p
- struct->list
- (apply * _)))
+ (define ribbon-around-box (~> p struct->list (sort <) (take 2) (map (λ~> (* 2)) _) (apply + _)))
+ (define ribbon-for-bow (~> p struct->list (apply * _)))
(+ ribbon-around-box ribbon-for-bow))
-(for/sum ([p (in-list presents)]) (ribbon-length p)) \ No newline at end of file
+(for/sum ([p (in-list presents)]) (ribbon-length p))