aboutsummaryrefslogtreecommitdiff
path: root/aoc2015
diff options
context:
space:
mode:
authorH.J <thechairman@thechairman.info>2024-10-09 11:36:55 -0400
committerH.J <thechairman@thechairman.info>2024-10-09 11:36:55 -0400
commit8777ff071f7bb37631baa7b6717ad29961e50911 (patch)
tree6d59c4ed58e454b960339c3d1151f0a879e8d7cb /aoc2015
parent6156a9ef7be4012063a042aafb4e9b0d7eadde8e (diff)
downloadgleam_aoc-8777ff071f7bb37631baa7b6717ad29961e50911.tar.gz
gleam_aoc-8777ff071f7bb37631baa7b6717ad29961e50911.zip
sorting by language
Diffstat (limited to 'aoc2015')
-rw-r--r--aoc2015/day-01/day-01.rkt16
-rw-r--r--aoc2015/day-02/day-02.rkt26
-rw-r--r--aoc2015/day-03/day-03.rkt28
-rw-r--r--aoc2015/day-04/day-04.rkt18
-rw-r--r--aoc2015/day-05/day-05.rkt32
-rw-r--r--aoc2015/day-06/day-06.rkt49
-rw-r--r--aoc2015/day-25/day-25.rkt8
7 files changed, 0 insertions, 177 deletions
diff --git a/aoc2015/day-01/day-01.rkt b/aoc2015/day-01/day-01.rkt
deleted file mode 100644
index efbd02a..0000000
--- a/aoc2015/day-01/day-01.rkt
+++ /dev/null
@@ -1,16 +0,0 @@
-#lang racket
-(require "../../jj-aoc.rkt")
-
-;; part 1
-(for/fold ([current-floor 0]) ([l (in-input-port-chars (open-day 1 2015))] [i (in-naturals)])
- (match l
- [#\( (add1 current-floor)]
- [#\) (sub1 current-floor)]))
-
-;; part 2
-(for/fold ([current-floor 0] [last-index 0] #:result (add1 last-index))
- ([l (in-input-port-chars (open-day 1 2015))] [i (in-naturals)])
- #:break (= current-floor -1)
- (match l
- [#\( (values (add1 current-floor) i)]
- [#\) (values (sub1 current-floor) i)]))
diff --git a/aoc2015/day-02/day-02.rkt b/aoc2015/day-02/day-02.rkt
deleted file mode 100644
index 579fd00..0000000
--- a/aoc2015/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))
diff --git a/aoc2015/day-03/day-03.rkt b/aoc2015/day-03/day-03.rkt
deleted file mode 100644
index 1d44955..0000000
--- a/aoc2015/day-03/day-03.rkt
+++ /dev/null
@@ -1,28 +0,0 @@
-#lang racket
-(require "../../jj-aoc.rkt"
- threading
- (only-in algorithms chunks-of)
- racket/hash)
-
-(define directions
- (for/list ([l (in-input-port-chars (open-day 3 2015))])
- (string->symbol (string l))))
-
-(define (trace-santa dirs)
- (define visits (make-hash))
- (for/fold ([x 0] [y 0] #:result visits) ([dir (in-list dirs)])
- (hash-set! visits `(,x ,y) #true)
- (match dir
- ['^ (values x (add1 y))]
- ['v (values x (sub1 y))]
- ['< (values (add1 x) y)]
- ['> (values (sub1 x) y)])))
-
-;; part 1
-(~> directions trace-santa hash-values length)
-
-;; part 2
-(~> directions (chunks-of 2) (apply map list _) (map trace-santa _) (match-define (list real robo) _))
-
-(hash-union! real robo #:combine (λ _ #true))
-(~> real hash-values length)
diff --git a/aoc2015/day-04/day-04.rkt b/aoc2015/day-04/day-04.rkt
deleted file mode 100644
index 2c16043..0000000
--- a/aoc2015/day-04/day-04.rkt
+++ /dev/null
@@ -1,18 +0,0 @@
-#lang racket
-(require "../../jj-aoc.rkt"
- threading
- file/md5)
-
-(define secret-key (~> (open-day 4 2015) port->string string-trim))
-
-(define (find-n-zeroes n)
- (for/first ([i (in-naturals)]
- #:when
- (~>> i (~a secret-key) md5 bytes->string/utf-8 (string-prefix? _ (make-string n #\0))))
- i))
-
-;; part 1
-(time (find-n-zeroes 5))
-
-;; part 2
-(time (find-n-zeroes 6))
diff --git a/aoc2015/day-05/day-05.rkt b/aoc2015/day-05/day-05.rkt
deleted file mode 100644
index 3449adc..0000000
--- a/aoc2015/day-05/day-05.rkt
+++ /dev/null
@@ -1,32 +0,0 @@
-#lang racket
-(require "../../jj-aoc.rkt"
- threading)
-
-(define strs (port->lines (open-day 5 2015)))
-
-;; part 1
-(define (at-least-three-vowels? str)
- (~>> str (regexp-replace* #px"[^aeiou]" _ "") string-length (<= 3)))
-
-(define (at-least-one-pair? str)
- (regexp-match? #px"(.)\\1{1,}" str))
-
-(define (no-forbidden-pairs? str)
- (~>> (list "ab" "cd" "pq" "xy") (ormap (λ~>> (string-contains? str))) not))
-
-(define (nice? str)
- (~>> (list at-least-three-vowels? at-least-one-pair? no-forbidden-pairs?) (andmap (λ (f) (f str)))))
-
-(count nice? strs)
-
-;; part 2
-(define (repeating-pair? str)
- (regexp-match? #px"(..).*\\1" str))
-
-(define (symmetry? str)
- (regexp-match? #px"(.).\\1" str))
-
-(define (new-nice? str)
- (~>> (list repeating-pair? symmetry?) (andmap (λ (f) (f str)))))
-
-(count new-nice? strs)
diff --git a/aoc2015/day-06/day-06.rkt b/aoc2015/day-06/day-06.rkt
deleted file mode 100644
index d2eed08..0000000
--- a/aoc2015/day-06/day-06.rkt
+++ /dev/null
@@ -1,49 +0,0 @@
-#lang racket
-(require "../../jj-aoc.rkt"
- threading)
-
-(struct instruction (todo x1 y1 x2 y2) #:transparent)
-
-(define (make-instruction lst)
- (apply instruction (string->symbol (first lst)) (map string->number (rest lst))))
-
-(define instructions
- (for/list ([l (in-lines (open-day 6 2015))])
- (~>> l
- (regexp-match
- #px"(turn on|toggle|turn off) (\\d{1,3}),(\\d{1,3}) through (\\d{1,3}),(\\d{1,3})")
- rest
- make-instruction)))
-
-(define (vector2d-modify! vec x y f)
- (define pos (+ x (* 1000 y)))
- (vector-set! vec pos (f (vector-ref vec pos))))
-
-;; part 1
-(define (todo inst)
- (match (instruction-todo inst)
- ['|turn on| (λ _ #true)]
- ['|turn off| (λ _ #false)]
- ['|toggle| not]))
-
-(define (modify-light-grid inst light-grid using)
- (for ([x (inclusive-range (instruction-x1 inst) (instruction-x2 inst))])
- (for ([y (inclusive-range (instruction-y1 inst) (instruction-y2 inst))])
- (vector2d-modify! light-grid x y (using inst)))))
-
-(define light-grid (make-vector (* 1000 1000) #false))
-(for ([i (in-list instructions)])
- (modify-light-grid i light-grid todo))
-(vector-count identity light-grid)
-
-;; part 2
-(define (todo-dimmer inst)
- (match (instruction-todo inst)
- ['|turn on| add1]
- ['|turn off| (λ (x) (max 0 (sub1 x)))]
- ['|toggle| (curry + 2)]))
-
-(define dimmable-grid (make-vector (* 1000 1000) 0))
-(for ([i (in-list instructions)])
- (modify-light-grid i dimmable-grid todo-dimmer))
-(apply + (vector->list dimmable-grid))
diff --git a/aoc2015/day-25/day-25.rkt b/aoc2015/day-25/day-25.rkt
deleted file mode 100644
index 975f4c3..0000000
--- a/aoc2015/day-25/day-25.rkt
+++ /dev/null
@@ -1,8 +0,0 @@
-#lang racket
-
-(define max-r 2978)
-(define max-c 3083)
-
-(for/fold ([code 20151125] [r 1] [c 1]) ([i (in-naturals)] #:break (and (= max-r r) (= max-c c)))
- (define new-code (modulo (* code 252533) 33554393))
- (if (= r 1) (values new-code (add1 c) 1) (values new-code (sub1 r) (add1 c))))