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 /2019/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 '2019/day-02/day-02.rkt')
-rw-r--r-- | 2019/day-02/day-02.rkt | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/2019/day-02/day-02.rkt b/2019/day-02/day-02.rkt deleted file mode 100644 index 56019e8..0000000 --- a/2019/day-02/day-02.rkt +++ /dev/null @@ -1,32 +0,0 @@ -#lang racket - -(require advent-of-code - threading) - -(define initial-opcodes - (parameterize ([current-readtable (make-readtable #f #\, #\space #f)]) - (port->list read (open-aoc-input (find-session) 2019 2 #:cache #true)))) - -;; part 1 -(define (edit-opcode ocs oc-1 oc-2) - (~> ocs (list-set 1 oc-1) (list-set 2 oc-2))) - -(define (run-intcode ocs) - (for/fold ([ocs ocs] #:result (car ocs)) - ([pointer (in-range 0 (length initial-opcodes) 4)] #:break (= 99 (list-ref ocs pointer))) - (define op - (match (list-ref ocs pointer) - [1 +] - [2 *])) - (list-set ocs - (list-ref ocs (+ 3 pointer)) - (op (list-ref ocs (list-ref ocs (+ 1 pointer))) - (list-ref ocs (list-ref ocs (+ 2 pointer))))))) - -(~> initial-opcodes (edit-opcode 12 2) run-intcode) - -;; part 2 -(for*/first ([noun (inclusive-range 0 99)] - [verb (inclusive-range 0 99)] - #:when (~> initial-opcodes (edit-opcode noun verb) run-intcode (= 19690720))) - (+ (* 100 noun) verb)) |