aboutsummaryrefslogtreecommitdiff
path: root/2024/day04/main.scm
diff options
context:
space:
mode:
Diffstat (limited to '2024/day04/main.scm')
-rwxr-xr-x2024/day04/main.scm65
1 files changed, 65 insertions, 0 deletions
diff --git a/2024/day04/main.scm b/2024/day04/main.scm
new file mode 100755
index 0000000..026e795
--- /dev/null
+++ b/2024/day04/main.scm
@@ -0,0 +1,65 @@
+#!/usr/bin/guile -s
+!#
+
+(add-to-load-path (format #f "~a/2024" (getcwd)))
+(add-to-load-path (format #f "~a/.." (dirname (current-filename))))
+
+(use-modules
+ (aoc-utils)
+ (srfi srfi-1)
+ (srfi srfi-9)
+ (srfi srfi-64)
+ (ice-9 regex)
+ (ice-9 getopt-long))
+
+(define (xmas? lst)
+ (or (equal? lst '(#\X #\M #\A #\S))
+ (equal? lst '(#\S #\A #\M #\X))))
+
+(define (get-posibilities input x y)
+ (let ((retval '()))
+ (if (> x (- (length input) 3))
+ (set! retval ()))))
+
+(define (part1 input)
+ (display input)
+ 0)
+
+(define (part2 input)
+ 0)
+
+(define (run-tests)
+ (test-begin "day03" 1)
+ (test-equal 18 (part1 (file->matrix "test.txt")))
+ (test-end "day03"))
+
+(define option-spec
+ '((help (single-char #\h) (value #f))
+ (test (single-char #\t) (value #f))))
+
+(define (help)
+ (display "main.scm [options] [FILE]
+-h, --help Display this help.
+-t, --test Run test suite
+"))
+
+(define (run-parts filename)
+ (let ((input (file->matrix filename)))
+ (display "Part1: ")
+ (display (part1 input))
+ (newline)
+ (display "Part2: ")
+ (display (part2 input))
+ (newline)))
+
+(define (main)
+ (let* ((options (getopt-long (command-line) option-spec))
+ (help-wanted? (option-ref options 'help #f))
+ (test-wanted? (option-ref options 'test #f))
+ (files (option-ref options '() '())))
+ (cond (help-wanted? (help))
+ (test-wanted? (run-tests))
+ ((= (length files) 1) (run-parts (car files)))
+ (else (help)))))
+
+(main)