moved everything into folders

This commit is contained in:
2021-12-05 13:19:40 +01:00
parent 8d8c1ae4a4
commit 3e26af5ae5
12 changed files with 9 additions and 9 deletions

View File

@@ -6,7 +6,7 @@
(count-increase text-port number (count-increase text-port number
(+ count (if (> number previous) 1 0))))))) (+ count (if (> number previous) 1 0)))))))
(let [(file (open-input-file "day-1.input"))] (let [(file (open-input-file "input"))]
(display "part 1: ") (display "part 1: ")
(display (count-increase file 100000 0)) (display (count-increase file 100000 0))
(newline) (newline)
@@ -25,7 +25,7 @@
(define (read-number text-port) (define (read-number text-port)
(string->number (get-line text-port))) (string->number (get-line text-port)))
(let* [(file (open-input-file "day-1.input")) (let* [(file (open-input-file "input"))
(triplet (list (read-number file) (read-number file) (read-number file))) (triplet (list (read-number file) (read-number file) (read-number file)))
(sum (+ (car triplet) (cadr triplet) (caddr triplet)))] (sum (+ (car triplet) (cadr triplet) (caddr triplet)))]
(display "part 2: ") (display "part 2: ")

View File

@@ -6,7 +6,7 @@
(loop (cons c w)))))) (loop (cons c w))))))
(call-with-input-file (call-with-input-file
"day-2.input" "input"
(lambda (file) (lambda (file)
(let loop [(x 0) (y 0)] (let loop [(x 0) (y 0)]
(let [(amount (string->number (get-word file))) (let [(amount (string->number (get-word file)))
@@ -24,7 +24,7 @@
(newline))))))) (newline)))))))
(call-with-input-file (call-with-input-file
"day-2.input" "input"
(lambda (file) (lambda (file)
(let loop [(x 0) (y 0) (aim 0)] (let loop [(x 0) (y 0) (aim 0)]
(let [(amount (string->number (get-word file))) (let [(amount (string->number (get-word file)))

View File

@@ -61,7 +61,7 @@
oxygen-gen co2-scrub (* oxygen-gen co2-scrub)))) oxygen-gen co2-scrub (* oxygen-gen co2-scrub))))
(call-with-input-file (call-with-input-file
"day-3.input" "input"
(lambda (file) (lambda (file)
(let [(numbers '#())] (let [(numbers '#())]
(let read-loop () (let read-loop ()

View File

@@ -138,7 +138,7 @@
[cadr index+score])]))) [cadr index+score])])))
(call-with-input-file (call-with-input-file
"day-4.input" "input"
(lambda (file) (lambda (file)
(let* [(draws (parse-draws file)) (let* [(draws (parse-draws file))
(boards (read-boards file))] (boards (read-boards file))]

View File

@@ -129,14 +129,14 @@
(get-pixels image))))) (get-pixels image)))))
(call-with-input-file (call-with-input-file
"day-5.input" "input"
(lambda (file) (lambda (file)
(let [(lines (read-lines file))] (let [(lines (read-lines file))]
(let [(image (additively-rasterize lines #f))] (let [(image (additively-rasterize lines #f))]
(output-pgm image "day-5-p1.pgm") (output-pgm image "part1.pgm")
(printf "part 1:~% dangerous areas = ~a~%" (printf "part 1:~% dangerous areas = ~a~%"
(count-crossings image))) (count-crossings image)))
(let [(image (additively-rasterize lines #t))] (let [(image (additively-rasterize lines #t))]
(output-pgm image "day-5-p2.pgm") (output-pgm image "part2.pgm")
(printf "part 2:~% dangerous areas = ~a~%" (printf "part 2:~% dangerous areas = ~a~%"
(count-crossings image)))))) (count-crossings image))))))