This repository was archived by the owner on Oct 12, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3131 " Syntax table for lbd-mode." )
3232
3333; ; Comment settings
34- (setq-local comment-start " -- " )
34+ (setq-local comment-start " --" )
3535(setq-local comment-end " " )
3636
3737; ; Font lock
3838(defconst lbd--keywords
39- '(" true" " false" " if_then" " pair" " first" " second" " use" )
39+ '(" true" " false" " if_then" " pair" " first" " second" " use"
40+ " print" " add" " sub" " mul" " cmp" " if_zero" " sort" " parse_float"
41+ " list" " list_size" " list_get" " list_remove" " list_append" " map" " transpose" " zip" " foldr"
42+ " slurp_file" " lines" " split" )
4043 " Language keywords for lbd-mode." )
4144
4245(defvar lbd-font-lock-keywords
Original file line number Diff line number Diff line change 1+ -- Problem Link: <https://adventofcode.com/2024/day/1>
2+
3+ -- TODO: This is super slow, optimize this
4+
5+ use "examples/std.lbd"
6+
7+ content: String = (slurp_file "examples/aoc-24/day-01/input.txt")
8+ entries: List = (lines content)
9+
10+ tmp: String -> Any = \x: String. (rot_2 split " " x)
11+ cols: List = (transpose (map tmp entries))
12+
13+ tmp2: List -> Any = \x: List. (map parse_float x)
14+ lists: List = (map tmp2 cols)
15+
16+ eq2: Float -> Float -> Float = \x: Float. \y: Float. (if_then (eq y x) 1 0)
17+ add2: Float -> Float -> Float = \x: Float. \y: Float. (add y x)
18+
19+ count: List -> Any -> Float = \xs: List. \x: Any. (foldr add2 0 (map (eq2 x) xs))
20+
21+ l0: List = (list_get lists 0)
22+ l1: List = (list_get lists 1)
23+
24+ tmp3: List -> Float = \xs: List. (mul (list_get xs 0) (list_get xs 1))
25+
26+ (print "Answer: " (foldr add2 0 (map tmp3 (zip (list l0 (map (count l1) l0))))) "\n")
You can’t perform that action at this time.
0 commit comments