Code:
;;; Advent of code 2024 - day1, part1, on BPI-F3 RISC-V;;; Chez Scheme code(load "../../utils.so")(define (day-1b file) (let-values ([(l r) (list-split (read-file file))]) (let ((sr (sort < r))) (apply + (map (lambda (x) (* x (length (filter (lambda (y) (= x y)) sr)))) (sort < l))))))
26593248
#<time-duration 0.052061206>
Both OCaml and Chez are brute force solutions for part 2, with filter.
And yes, here (sort < r) is unnecessary!
Statistics: Posted by hrvoje064 — Sun Dec 01, 2024 2:35 pm