aboutsummaryrefslogtreecommitdiff
path: root/advent-of-code/2023/09/1.rkt
diff options
context:
space:
mode:
Diffstat (limited to 'advent-of-code/2023/09/1.rkt')
-rw-r--r--advent-of-code/2023/09/1.rkt27
1 files changed, 0 insertions, 27 deletions
diff --git a/advent-of-code/2023/09/1.rkt b/advent-of-code/2023/09/1.rkt
deleted file mode 100644
index 531c5dd..0000000
--- a/advent-of-code/2023/09/1.rkt
+++ /dev/null
@@ -1,27 +0,0 @@
-#lang racket
-
-(require "../../lib/utils.rkt")
-
-(define lines
- (call-with-input-file "input"
- (λ (fp)
- (get-lines fp))))
-
-(define (parse-data line)
- (map string->number (string-split line)))
-
-(define data (map parse-data lines))
-
-(define (diff lst)
- (let loop ((cur lst) (ret '()))
- (if (or (null? cur) (null? (cdr cur)))
- (reverse ret)
- (loop (cdr cur) (cons (- (cadr cur) (car cur)) ret)))))
-
-(define (predict lst)
- (if (andmap (λ (x) (= x (car lst))) lst)
- (car lst)
- (+ (last lst) (predict (diff lst)))))
-
-(apply + (map predict data))
-