This commit is contained in:
xenia 2022-12-02 00:06:21 -05:00
parent 0b5ff3eab5
commit dc612a29a4
2 changed files with 2556 additions and 0 deletions

56
2.rkt Normal file
View File

@ -0,0 +1,56 @@
#lang curly-fn racket
(require "scripts/aoc.rkt")
;; solution for day 2
(define (part1 input)
(for/sum ([x (in-list input)])
(match-define (list x1 x2) x)
(+ (match x2
["X" 1]
["Y" 2]
["Z" 3])
(match* (x1 x2)
[("A" "X") 3]
[("A" "Y") 6]
[("A" "Z") 0]
[("B" "X") 0]
[("B" "Y") 3]
[("B" "Z") 6]
[("C" "X") 6]
[("C" "Y") 0]
[("C" "Z") 3]))))
(define (part2 input)
(for/sum ([x (in-list input)])
(match-define (list x1 x2) x)
(+ (match x2
["X" 0]
["Y" 3]
["Z" 6])
(match* (x1 x2)
[("A" "X") 3]
[("A" "Y") 1]
[("A" "Z") 2]
[("B" "X") 1]
[("B" "Y") 2]
[("B" "Z") 3]
[("C" "X") 2]
[("C" "Y") 3]
[("C" "Z") 1]))))
(define (parse fname)
(for/list ([x (in-list (file->lines fname))])
(string-split x " ")))
(module+ test
(require rackunit)
(displayln "no tests :("))
(module+ main
(define input (parse "inputs/2"))
(answer 2 1 (time (part1 input)))
(answer 2 2 (time (part2 input)))
(displayln "meow"))

2500
inputs/2 Normal file

File diff suppressed because it is too large Load Diff