(import (chicken io)) (import (chicken format)) (import srfi-1) (define (parse inputs) (let ((line (read-line))) (if (not (eof-object? line)) (parse (cons (string->number line) inputs)) inputs))) (define (inc-if cond num) (if cond (+ num 1) num)) (define (part1 inputs previous counter) (if (not (null? inputs)) (let ((head (car inputs))) (part1 (cdr inputs) head (inc-if (<= head previous) counter))) counter)) (define (part2 inputs previous counter) (if (not (eq? inputs '())) (let ((sum (apply + (take-right! inputs 3)))) (part2 (cdr inputs) sum (inc-if (<= sum previous) counter))) counter)) (let ((inputs (parse '()))) (format #t "inputs = ~A~%" inputs) (format #t "part1 = ~A~%" (part1 inputs 0 0)) (format #t "part2 = ~A~%" (part2 inputs 0 0)))