this post was submitted on 13 Nov 2025
1 points (54.5% liked)

Advent Of Code

1122 readers
2 users here now

An unofficial home for the advent of code community on programming.dev! Other challenges are also welcome!

Advent of Code is an annual Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like.

Everybody Codes is another collection of programming puzzles with seasonal events.

EC 2025

AoC 2024

Solution Threads

M T W T F S S
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

Rules/Guidelines

Relevant Communities

Relevant Links

Credits

Icon base by Lorc under CC BY 3.0 with modifications to add a gradient

console.log('Hello World')

founded 2 years ago
MODERATORS
 

Quest 6: Mentorship Matrix

  • Keep top level comments as only solutions, if you want to say something other than a solution put it in a new post. (replies to comments can be whatever)
  • You can send code in code blocks by using three backticks, the code, and then three backticks or use something such as https://topaz.github.io/paste/ if you prefer sending it through a URL

Link to participate: https://everybody.codes/

you are viewing a single comment's thread
view the rest of the comments
[โ€“] vole@lemmy.world 1 points 3 days ago

Scheme/Guile

Part 3 was a fun little challenge.

(import (rnrs io ports (6)))
#!curly-infix

(define (parse-file file-name) (string-trim-both (call-with-input-file file-name get-string-all)))

(let* ((line (parse-file "notes/everybody_codes_e2025_q06_p1.txt"))
       (line-length (string-length line)))
  (let loop ((i 0) (knight-count 0) (mentor-count 0))
    (if {i < line-length}
        (let ((letter (string-ref line i)))
          (loop (1+ i) (+ knight-count (if (eq? letter #\A) 1 0)) (+ mentor-count (if (eq? letter #\a) knight-count 0))))
        (format #t "P1 Answer: ~a\n\n" mentor-count))))

(let* ((line (parse-file "notes/everybody_codes_e2025_q06_p2.txt"))
       (line-length (string-length line)))
  (let loop ((i 0) (knight-counts '()) (mentor-count 0))
    (if {i < line-length}
        (let ((letter (string-ref line i)))
          (loop
            (1+ i)
            (if (char-upper-case? letter) (assq-set! knight-counts letter (1+ (or (assq-ref knight-counts letter) 0))) knight-counts)
            (+ mentor-count (if (char-lower-case? letter) (or (assq-ref knight-counts (char-upcase letter)) 0) 0))))
        (format #t "P2 Answer: ~a\n\n" mentor-count))))


(let* ((line (parse-file "notes/everybody_codes_e2025_q06_p3.txt"))
       (line-length (string-length line)))
  (let loop ((i 0) (mentor-count 0))
    (if {i < line-length}
        (let ((letter (string-ref line i)))
          (loop
            (1+ i)
            (+ mentor-count
               (if (char-lower-case? letter)
                   (let loop ((j (- i 1000)) (mentors-here 0))
                     (if {j <= (+ i 1000)}
                         (loop
                           (1+ j)
                           (+ mentors-here
                              (if {(string-ref line {j modulo line-length}) eq? (char-upcase letter)}
                                  (if (and {0 <= j} {j < line-length}) 1000 999)
                                  0)))
                         mentors-here))
                   0))))
        (format #t "P3 Answer: ~a\n\n" mentor-count))))