From 78be8a52124f44f09cb3582cefdf736301a78a50 Mon Sep 17 00:00:00 2001 From: Matias Linares Date: Wed, 4 Dec 2024 08:54:24 -0300 Subject: Add day04 --- 2024/day04/main.scm | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100755 2024/day04/main.scm (limited to '2024/day04/main.scm') 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) -- cgit v1.2.3-70-g09d2