wer2

joined 2 years ago
[–] [email protected] 3 points 2 months ago

So use cheap Chinese AI models then?

[–] [email protected] 4 points 3 months ago (3 children)

If you hate the taste of scrum give SAFe a try! (but really, please don't)

[–] [email protected] 17 points 3 months ago (1 children)

My main complaint with how Gnome does stuff is in environments where it is the only option (e.g. RHEL).

[–] [email protected] 50 points 3 months ago (2 children)

The backend dev has seen into the depths of COBOL and JCL that keep the world from imploding.

And the code looked back.

[–] [email protected] 7 points 3 months ago (2 children)

Do people actually do the spoon thing? I always hit them on the edge of the counter.

[–] [email protected] 2 points 3 months ago

Sundered. I would love to see the equivalent of Rogue Legacy 2 for that game, where the sequel completely supplants the original while expanding upon the storytelling and lore.

[–] [email protected] 4 points 3 months ago

I'm working on it. Just waiting till Christmas.

[–] [email protected] 2 points 3 months ago

Marketplace on NPR. I like the more economic view of the news.

[–] [email protected] 6 points 3 months ago

Here are some cool/memorable games:

  • Brothers: A Tale of Two Sons
  • Return of the Obra Dinn
  • Braid
[–] [email protected] 9 points 4 months ago (1 children)

Also the director of "Canadian Bacon".

[–] [email protected] 10 points 4 months ago

Didn't you hear? It's now a crime to have your kids walk by themselves. Just ask the bastions of freedom that are Georgia and Texas.

(That those events happened is obviously dumb.)

[–] [email protected] 2 points 4 months ago* (last edited 4 months ago)

Lisp

Could probably just write points right to the results instead of to an intermediate list, but it runs instantly, so my motivation to do so was low.

Code

(defun p1-process-line (line)
   (to-symbols line 'advt2024-d8))
  
(defun count-results (results)
  (loop for i from 0 below (array-total-size results)
        count (row-major-aref results i)))

(defun place-annode (pos results)
  (let ((x (first pos)) (y (second pos)))
    (when (in-map results x y) 
      (setf (aref results y x) t))))

(defun create-annodes-p1 (x1 y1 x2 y2)
  (let ((delta-x (- x2 x1)) (delta-y (- y2 y1)))
    (list (list (- x1 delta-x) (- y1 delta-y)) (list (+ x2 delta-x) (+ y2 delta-y)))))

(defun place-annodes (positions results create-annodes)
  (when positions
     (loop with a = (car positions)
           with x1 = (first a)
           with y1 = (second a)
           for b in (cdr positions)
           for ans = (funcall create-annodes x1 y1 (first b) (second b))
           do (dolist (a ans) (place-annode a results)))
     (place-annodes (cdr positions) results create-annodes)))

(defun place-all-annodes (xmits map &optional (create-annodes #'create-annodes-p1))
  (let ((results (make-array (array-dimensions map) :element-type 'boolean :initial-element nil)))
    (loop for k being the hash-key of xmits
          do (place-annodes (gethash k xmits) results create-annodes))
    results))

(defun find-transmitters (map)
  "look throught the map and record where the transmitters are in a hash map"
  (let ((h (make-hash-table)))
    (destructuring-bind (rows cols) (array-dimensions map)
      (loop for j from 0 below rows
            do (loop for i from 0 below cols
                     for v = (aref map j i)
                     unless (eql v '|.|)
                       do (push (list i j) (gethash v h))
                     )))
    h))

(defun run-p1 (file) 
  (let* ((map (list-to-2d-array (read-file file #'p1-process-line))))
    (count-results (place-all-annodes (find-transmitters map) map))
    ))

(defun create-annodes-2 (x1 y1 x2 y2 map)
  (destructuring-bind (rows cols) (array-dimensions map)
    (let* ((m (/ (- y2 y1) (- x2 x1) ))
           (b (- y2 (* m x2))))
      (loop for x from 0 below cols
            for y = (+ b (* x m))
            for r = (nth-value 1 (floor y))
            when (and (= r 0) (>= y 0) (< y rows))
              collect (list x y)))))

(defun run-p2 (file) 
  (let* ((map (list-to-2d-array (read-file file #'p1-process-line))))
    (count-results (place-all-annodes (find-transmitters map) map
                                      (lambda (x1 y1 x2 y2)
                                        (create-annodes-2 x1 y1 x2 y2 map))))))

view more: ‹ prev next ›