This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(define (get-input) | |
(map string->number (string-split (car (file->lines "day2.txt")) ","))) | |
(define (add code ip) | |
(let ([a (vector-ref code (vector-ref code (+ ip 1)))] | |
[b (vector-ref code (vector-ref code (+ ip 2)))]) | |
(vector-set! code (vector-ref code (+ ip 3)) (+ a b)) | |
code)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inlines = [] | |
with open("day3.txt") as f: | |
inlines = f.readlines() \ | |
|> map$(-> _.strip()) \ | |
|> list | |
data Wire(covering,): | |
def find(self, point) = self.covering.index(point) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require racket/set) | |
(require threading) | |
(struct point (x y) #:transparent) | |
(struct instruction (direction distance) #:transparent) | |
(define (parse-line line) | |
(map (λ (instr) (instruction (substring instr 0 1) (string->number (substring instr 1)) ))(string-split line ","))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require threading) | |
(define low 171309) | |
(define high 643603) | |
(define (gen-passwords from to) | |
(map number->string (range from (+ 1 to)))) | |
(define (increasing? instr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inlines = [] | |
with open("day5.txt") as f: | |
inlines = f.readline() \ | |
|> .strip() \ | |
|> .split(',') \ | |
|> map$(-> int(_)) \ | |
|> list | |
def run(intops, inn=None): | |
output = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(define (get-input) | |
(map string->number (string-split (car (file->lines "day5.txt")) ","))) | |
(struct parameter (value immediate) #:transparent) | |
(struct opcode (op a b c) #:transparent) | |
(define (run-code code input) | |
(define (decode-op code ip) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require threading) | |
(define test-img '(((0 2) | |
(2 2)) | |
((1 1) | |
(2 2)) | |
((2 2) | |
(1 2)) | |
((0 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(define (get-input) | |
(map string->number (string-split (car (file->lines "day9.txt")) ","))) | |
(define test-code '(109 1 204 -1 1001 100 1 100 1008 100 16 101 1006 101 0 99)) | |
(define test-code2 '(1102 34915192 34915192 7 4 7 99 0)) | |
(define test-code3 '(104 1125899906842624 99)) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require threading) | |
(define (get-input) | |
(map string->number (string-split (car (file->lines "day11.txt")) ","))) | |
(define (get-test-input) | |
(map string->number (string-split (car (file->lines "day9.txt")) ","))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require threading) | |
(require racket/set) | |
(struct point (x y z) #:transparent) | |
(struct velocity (x y z) #:transparent) | |
(struct moon (position velocity) #:transparent) | |
(define (get-input) |
OlderNewer