Skip to content

Instantly share code, notes, and snippets.

#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))
inlines = []
with open("day3.txt") as f:
inlines = f.readlines() \
|> map$(-> _.strip()) \
|> list
data Wire(covering,):
def find(self, point) = self.covering.index(point)
#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 ",")))
#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)
inlines = []
with open("day5.txt") as f:
inlines = f.readline() \
|> .strip() \
|> .split(',') \
|> map$(-> int(_)) \
|> list
def run(intops, inn=None):
output = []
#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)
#lang racket
(require threading)
(define test-img '(((0 2)
(2 2))
((1 1)
(2 2))
((2 2)
(1 2))
((0 0)
#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))
#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")) ",")))
@sotolf2
sotolf2 / day12.rkt
Last active December 12, 2019 11:45
#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)