🦆 Everybody.Codes 2025 Quest 3 Solutions 🦆

https://programming.dev/post/40463625

Windows: we noticed that you kept the useless search bar disabled since 2015, so we sent an update that re-enabled it without your permission - programming.dev

For my “convenience” and because in this way they can show ads and clickbait Also: I SET A FUCKING GROUP POLICY THAT DISABLES THE SEARCH BAR; WHY THEY FUCKING IGNORE IT???

Scheme/Guile

Guile doesn’t seem to come with a bag implementation :(. Not a big deal, a linear scan works about as well.

(use-modules (ice-9 rdelim)) (use-modules (srfi srfi-1)) (define (parse-file file-name) (let* ((p (open-input-file file-name)) (comma-split (string-split (read-line p) #\,)) (number-list (map string->number comma-split))) number-list)) (let* ((crates (parse-file "notes/everybody_codes_e2025_q03_p1.txt")) (dedup-crates (delete-duplicates crates))) (format #t "P1 Answer: ~a\n\n" (apply + dedup-crates))) (let* ((crates (parse-file "notes/everybody_codes_e2025_q03_p2.txt")) (dedup-crates (delete-duplicates crates)) (sorted-crates (sort dedup-crates <))) (format #t "P2 Answer: ~a\n\n" (apply + (take sorted-crates 20)))) (let* ((crates (parse-file "notes/everybody_codes_e2025_q03_p3.txt")) (sorted-crates (sort crates <)) (largest-set-size (let loop ((count 0) (l sorted-crates) (c #f) (max-count 0)) (if (nil? l) max-count (let* ((new-c (car l)) (new-count (if (eq? new-c c) (+ count 1) 1))) (loop new-count (cdr l) new-c (max new-count max-count))))))) (format #t "P3 Answer: ~a\n\n" largest-set-size))
I’m so far behind on these, but it’s rare that I see a lanugage I’ve never heard before. I’ve heard of scheme. How did you come to using this language for the challenges?
I wanted to learn scheme and perhaps work through SICP. Guille seemed like a reasonable scheme to choose because I’ve also been considering learning Guix. Guix is a package manager similar to Nix, and it uses Guille as its configuration language.