Skip to content

Instantly share code, notes, and snippets.

View LdBeth's full-sized avatar

LdBeth

View GitHub Profile
@LdBeth
LdBeth / build.org
Last active April 7, 2025 21:47
Build Emacs 31 for Windows

Build Emacs with MSYS2

This document is an up-to-date guide on compile Emacs 31 on windows with MSYS2, and make a installation with native compile that can work without MSYS2.

The idea is after get a working Emacs, you may delete MSYS2 environment to free some disk space, and forget about rebuilding Emacs

@LdBeth
LdBeth / input.txt
Last active July 22, 2024 05:21
Solve Hatsune Miku logic paint
1 4 2
6 1 2
3 2 1
2 1
2 2
3
3
3
2 4 1
4 4 2
@LdBeth
LdBeth / j.ixml
Last active October 8, 2023 04:35
IXML grammar for J
jsource : line++NL .
{ "https://johnlumley.github.io/jwiXML.xhtml" }
{ Number constant }
-number : integer; float; complex; extend; power; radian; radix .
-uptofloat : integer; float .
-uptocomplex : uptofloat; complex .
radix : (uptocomplex; power; radian), -"b", rdxstr .
@LdBeth
LdBeth / format-e.lisp
Created September 12, 2023 16:53
Tilde E ANSI test
;-*- Mode: Lisp -*-
;;;; Author: Marius Gerbershagen
;;;; Created: Wed Feb 6 19:35:53 2019
;;;; Contains: Tests of the ~e format directive
(defun round-ratio-to-n-digits (ratio n)
"Returns a string with the first n significant digits of the decimal
representation of ratio."
(check-type ratio rational)
(check-type n (integer 1 *))
(let* ((exp (floor (* (- (integer-length (numerator ratio))
@LdBeth
LdBeth / been.lisp
Created December 15, 2022 08:11
aoc2022d15
(ql:quickload :fset)
(ql:quickload :cl-interval)
(load "data.lisp")
(defparameter *map*
(reduce #'fset:with `(,(fset:empty-set) ,@*ff*)))
(defparameter *test1*
(fset:set '(2 18)
'(-2 15)
@LdBeth
LdBeth / aoc2022d14
Last active December 14, 2022 16:44
aoc2022d14
data←⊃⎕NGET 'input.txt' 1
)copy dfns iotag
interval←(iotag⍥⊃)(,⍤(∘.,))(iotag⍥(⊃∘⌽))
set←∪⊃,/{∪⊃,/2 interval/↓2↑⍤1⊢((⌈3÷⍨⍴s),3)⍴⊢s←⊃(//)',>-'⎕VFI ⍵}¨data
⍝ Part 1
∇n←sim map;sand;d;dl;dr;m
n←0
next:
sand←500 0
loop:
⎕CR 'part2'
res←part2 map;n;p;i;e;x;hist
p←path height map
e←1=height map
i←{'E'=⍵}map
hist←i
x←0
Loop:
x+←1
hist⌈←x×i
⎕VR 'foo'
∇ res←foo data;fn;d;st;i
[1] fn←{res←⊃(//)⎕VFI('-'⎕R'¯')⍵ ⋄ 0=≢res:1 0 ⋄ 2,⊃res}
[2] d←fn¨data
[3] st←(⊂0 1)
[4] :For i :In d
[5] st,←⊂i+⊃⌽st
[6] :EndFor
[7] res←st
@LdBeth
LdBeth / aoc2022d9
Last active December 9, 2022 05:35
⎕VR 'foo'
∇ hist←foo ins;head;end;m
[1] hist←⊂0 0
[2] head←0 0
[3] end←0 0
[4] :For m :In ins
[5] head+←m
[6] :If ∨/2≤|head-end
[7] end+←×head-end
[8] hist,←⊂end
data←⊃⎕NGET'input.txt'1
⎕io←0
test←⎕D⍳↑map
⍝ P1
+/{a←test[⊃⍵;] ⋄ b←test[;⊃⌽⍵] ⋄ i←⍵⌷test ⋄ ∨/∧/¨i>((⊃⍵)↑b)((1+⊃⍵)↓b)((⊃⌽⍵)↑a)((1+⊃⌽⍵)↓a)}¨,⍳⍴test
⍝ P2
⌈/{a←test[⊃⍵;] ⋄ b←test[;⊃⌽⍵] ⋄ i←⍵⌷test ⋄ ×/((1++/)⌊≢)¨∧\¨i>(⌽(⊃⍵)↑b)((1+⊃⍵)↓b)(⌽(⊃⌽⍵)↑a)((1+⊃⌽⍵)↓a)}¨,⍳⍴test