reddit / emacs

Advent of code ... But in Elisp

a-concerned-mother · 2022-12-16 16:39
Primary-Wave2 · 2022-12-16 17:18
Impressive
deafpolygon · 2022-12-16 18:01
I’d like to see more of this. :)
kirankp89 · 2022-12-16 20:07
I actually solved this one with calc. Replace all new lines with space. Replace double space with new line. Rectangle select the buffer and do C-x * g, to grab selection into calc vectors. In calc, do V M _ +, to sum the rows. Sort using V S. Take the top entries.
[deleted] · 2022-12-16 20:38
[deleted]
Fearless_Process · 2022-12-17 02:50
I have also been doing some AoC in elisp! Emacs Lisp is actually not a terrible little language and works pretty well for the all of the AoC challenges I've done so far! So far some of the features that have been useful: * edebug for stepping through functions a single expression at a time * rx for generating readable regexps for parsing the puzzle input * seq which is a built in dash like library for working with lists * cl-lib for things like structs and the loop macro * cl-generic for dynamic dispatch * eieio for some other method related stuff like the with-slots macro * ert for writing test cases That's about all I can think of right now. I was considering writing an elisp interface to the AoC API, for downloading puzzle input and submitting answers and whatnot, but so far I haven't gotten around to it and am not sure whether it's worth it!
arthurno1 · 2022-12-17 06:46
For those interested, there is a [Reddit for Advent of Code](https://www.reddit.com/r/adventofcode/), and there are few more days over there solved with Emacs Lisp, check under each day for the solutions. By the way, if anyone is interested, I am using this little yasnippet to generate a little generic form when doing this: # -*- mode: snippet -*- # name: aoc-puzzle # key: aoc # -- (defun day$1 () (interactive) (let ((p1 0) (p2 0)) (with-temp-buffer (insert-file-contents "input") $0 (message "Part I: %s\nPart II: %s" p1 p2))))
casted · 2022-12-31 14:56
> I was considering writing an elisp interface to the AoC API, for downloading puzzle input and submitting answers and whatnot. https://github.com/keegancsmith/advent/blob/master/advent.el