aboutsummaryrefslogtreecommitdiff
path: root/advent-of-code/2023/05
diff options
context:
space:
mode:
Diffstat (limited to 'advent-of-code/2023/05')
-rwxr-xr-xadvent-of-code/2023/05/part1.rkt (renamed from advent-of-code/2023/05/part1.scm)16
-rwxr-xr-xadvent-of-code/2023/05/part2.rkt (renamed from advent-of-code/2023/05/part2.scm)13
2 files changed, 11 insertions, 18 deletions
diff --git a/advent-of-code/2023/05/part1.scm b/advent-of-code/2023/05/part1.rkt
index 5413bf0..64b8f84 100755
--- a/advent-of-code/2023/05/part1.scm
+++ b/advent-of-code/2023/05/part1.rkt
@@ -1,7 +1,4 @@
-#!/usr/bin/env guile
-!#
-
-(use-modules (ice-9 rdelim))
+#lang racket
(define port (open-input-file "input"))
@@ -9,10 +6,10 @@
(let ()
(define nums-str
(string-trim
- (list-ref (string-split (read-line port) #\:) 1)))
- (map string->number (string-split nums-str #\space))))
+ (list-ref (string-split (read-line port) ":") 1)))
+ (map string->number (string-split nums-str " "))))
-(read-line port)
+(define _ (read-line port))
(define (read-line-convert-eof port)
(define line (read-line port))
@@ -23,7 +20,7 @@
(define line (string-trim (read-line-convert-eof port)))
(if (= 0 (string-length line))
(reverse ret)
- (loop (cons (map string->number (string-split line #\space))
+ (loop (cons (map string->number (string-split line " "))
ret))))
(read-line port)
(loop '()))
@@ -37,11 +34,10 @@
(define h2l (read-map))
(define maps (list s2s s2f f2w w2l l2t t2h h2l))
-
(define (gen-mapper the-map)
(define (mapper x)
(define (loop the-map)
- (if (nil? the-map)
+ (if (null? the-map)
x
(let ()
(define cur-map (car the-map))
diff --git a/advent-of-code/2023/05/part2.scm b/advent-of-code/2023/05/part2.rkt
index 87ad5e9..97d07e1 100755
--- a/advent-of-code/2023/05/part2.scm
+++ b/advent-of-code/2023/05/part2.rkt
@@ -1,7 +1,4 @@
-#!/usr/bin/env guile
-!#
-
-(use-modules (ice-9 rdelim))
+#lang racket
(define port (open-input-file "input"))
@@ -9,7 +6,7 @@
(let ()
(define nums-str
(string-trim
- (list-ref (string-split (read-line port) #\:) 1)))
+ (list-ref (string-split (read-line port) ":") 1)))
(define (pairing l)
(define (loop ret l)
(if (null? l)
@@ -22,9 +19,9 @@
(cddr l))))
(loop '() l))
(reverse
- (pairing (map string->number (string-split nums-str #\space))))))
+ (pairing (map string->number (string-split nums-str " "))))))
-(read-line port)
+(define _ (read-line port))
(define (read-line-convert-eof port)
(define line (read-line port))
@@ -35,7 +32,7 @@
(define line (string-trim (read-line-convert-eof port)))
(if (= 0 (string-length line))
(sort (reverse ret) (lambda (x y) (< (cadr x) (cadr y))))
- (loop (cons (map string->number (string-split line #\space))
+ (loop (cons (map string->number (string-split line " "))
ret))))
(read-line port)
(loop '()))