This file contains hidden or 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/hash) | |
(define in (open-input-file "day14.in")) | |
(define (amount s) | |
(match-let ([(list a b) (string-split s)]) | |
(cons (string->number a) b))) |
This file contains hidden or 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 moons-pos (vector '(17 5 1) '(-2 -8 8) '(7 -6 14) '(1 -10 4))) | |
(define moons-pos (vector '(-8 -10 0) '(5 5 10) '(2 -7 3) '(9 -8 -3))) | |
;(define moons-pos (vector '(-1 0 2) '(2 -10 -7) '(4 -8 8) '(3 5 -1))) | |
(define moons-vel (vector '(0 0 0) '(0 0 0) '(0 0 0) '(0 0 0))) | |
; update velocities | |
(define (gravity a-pos b-pos a-vel b-vel) | |
(values (map (lambda (aa bb v) (if (< aa bb) (add1 v) (if (> aa bb) (sub1 v) v))) a-pos b-pos a-vel) |
This file contains hidden or 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 data/heap) | |
(define in (open-input-file "day23.in")) | |
(define line-pattern #px"pos=<([-[:digit:]]+),([-[:digit:]]+),([-[:digit:]]+)>, r=([-[:digit:]]+)") | |
(define bots | |
(for/list ([line (in-lines in)]) | |
(let ([match (map string->number |
This file contains hidden or 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/vector) | |
(define in (file->string "day5.in")) | |
(define initial-memory (list->vector (map string->number (string-split in ",")))) | |
(define mem (vector-copy initial-memory)) | |
; indirect addressing (with optional offset) | |
(define (ind pos [off 0]) |
This file contains hidden or 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
program day4 | |
implicit none | |
character(len=13) :: input = "137683-596253" | |
integer, dimension(6) :: arr | |
integer, dimension(2) :: res | |
integer :: i, lb, ub | |
real :: start_time, end_time |
This file contains hidden or 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
program day3 | |
implicit none | |
character(len=2048) :: line | |
character(len=4), dimension(:), allocatable :: insn1, insn2 | |
integer, dimension(:,:), allocatable :: points1, points2, collisions | |
integer :: n, i, j, closest, x, y, t | |
open(1, file="day3.in") |
This file contains hidden or 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 in (file->lines "day3.in")) | |
(define instructions-1 (string-split (first in) ",")) | |
(define instructions-2 (string-split (second in) ",")) | |
(define (get-delta dir) | |
(match dir | |
['#\R '(1 . 0)] | |
['#\L '(-1 . 0)] |
This file contains hidden or 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
program day2 | |
implicit none | |
character(len=1024) :: line | |
integer, dimension(:), allocatable :: ops | |
integer :: n, noun, verb | |
open(1, file="day2.in") | |
read(1, "(A)") line | |
close(1) |
This file contains hidden or 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
program day1 | |
implicit none | |
integer :: stat, m, s, s2 | |
s = 0 | |
s2 = 0 | |
open(1, file="day1.in", iostat=stat) | |
do | |
read(1, *, iostat=stat) m |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.