This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
∇out←dir lines;l;path;size;ls | |
path←⊂'' | |
ls←⍬ | |
size←0 | |
:For l :In lines | |
:If 1=⍴('\$ cd'⎕S'$1')l | |
ls,←⊂(⊃{⍺,'/',⍵}/path)size | |
:If '..'≢5↓l | |
path,←⊂5↓l | |
:Else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
⎕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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
⎕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 | |
∇ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
⎕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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;-*- 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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 4 2 | |
6 1 2 | |
3 2 1 | |
2 1 | |
2 2 | |
3 | |
3 | |
3 | |
2 4 1 | |
4 4 2 |