diff options
author | J.J <thechairman@thechairman.info> | 2023-11-30 17:10:00 -0500 |
---|---|---|
committer | J.J <thechairman@thechairman.info> | 2023-11-30 17:10:00 -0500 |
commit | 8ab65dc2da1742eb86ec636c50c7018385b68167 (patch) | |
tree | c4fd556aca9b867cfa1f2f174128c30857353884 /2015/day-02/day-02.rkt | |
parent | fafbeaf9e3c09ba7a5bea7e47d5736001f8a5aa1 (diff) | |
download | gleam_aoc-8ab65dc2da1742eb86ec636c50c7018385b68167.tar.gz gleam_aoc-8ab65dc2da1742eb86ec636c50c7018385b68167.zip |
prep for 2023, renaming for consistency
Diffstat (limited to '2015/day-02/day-02.rkt')
-rw-r--r-- | 2015/day-02/day-02.rkt | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/2015/day-02/day-02.rkt b/2015/day-02/day-02.rkt deleted file mode 100644 index 579fd00..0000000 --- a/2015/day-02/day-02.rkt +++ /dev/null @@ -1,26 +0,0 @@ -#lang racket -(require "../../jj-aoc.rkt" - threading - racket/struct) - -(struct present (l w h) #:transparent) - -(define presents - (for/list ([size-string (in-lines (open-day 2 2015))]) - (~> 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 * _))) - (+ 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 * _))) - (+ ribbon-around-box ribbon-for-bow)) - -(for/sum ([p (in-list presents)]) (ribbon-length p)) |