aboutsummaryrefslogtreecommitdiff
path: root/2024/day04/main.scm
blob: 026e795e192c0b3cc9438457605c32104d987ec6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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)