Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4104

Teaching and learning resources • Re: Advent of Code 2024

$
0
0

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))))))
> (time (lambda () (day-1b "input.txt")))
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



Viewing all articles
Browse latest Browse all 4104

Trending Articles