Browse Source

upd readme

txlyre 4 months ago
parent
commit
dd087499b8
1 changed files with 22 additions and 0 deletions
  1. 22 0
      readme.md

+ 22 - 0
readme.md

@@ -91,6 +91,25 @@ l 3
 1 0 0 2 3 0 0 4
 ```
 
+## Some AoC 2024 solutions
+```
+    / day 1, part 1
+    ps:3 4,:4 3,:2 5,:1 3,:3 9,:3 3
+    +/(@{.-*)"(].(3t.*)"ps),"(].(3t.{.)"ps)
+11
+    / day 1, part 2
+    sr:(3t.{.)"ps
+    +/(:x*#x?sr)"(3t.*)"ps
+31
+    / day 2, part 1
+    data:7 6 4 2 1,:1 2 7 8 9,:9 7 6 2 1,:1 3 2 4 5,:8 6 4 4 1,:1 3 6 7 9
+    #1?(:(&/(:x@.(-3!.-1))"x)|(&/(:x@.(1!.3))"x))"-"."data
+2
+    / day 2, part 2
+    #1?|/"(:(&/(:x@.(-3!.-1))"x)|(&/(:x@.(1!.3))"x))""-".""(:x L.(!#x)d.x)"data
+4
+```
+
 # Quick reference (also available in the interpreter itself)
 
 ```
@@ -230,6 +249,7 @@ _: dyadic  base          10_:4242 is 4 2 4 2
 {  monadic head          first two elts of x, same as 2#
 {  dyadic  bin           bin search, e.g. 1 3 5 7 9{8 9 0 yields 3 4 -1
 {. monadic tail          last elt of x
+{. dyadic  cut           1 3{.!.5 yields 2 3,:4 5
 {: monadic prefixes      prefixes of x, same as |}.\.
 {: dyadic  shl           x << y
 }  monadic behead        all elts of x except first, same as 1_
@@ -260,6 +280,7 @@ $. dyadic  format        format y by template x, e.g. '{0}+{1}*{-1}+_'$.1 2 3 4
 $: monadic eye           identity matrix of size x
 $: dyadic  implode       join y inserting x between
 
+d. dyadic  delete        delete elt from y by index x
 p. monadic print         print x
 P. monadic println       print x and a \n
 c. monadic putch         print char x
@@ -304,6 +325,7 @@ f;g        bond          */;!.5 yields 120, +;1 5 yields 6, 5;- 1 yields 4
 f?.x       pick          >;5?.((2*),:<)"3 6 yields 6 5
 f?:F       while         <;5?:>0 yields 5
 n?:f       repeat        5?:*;2 1 yields 32
+a\:f       collect       same as while/repeat, but yields array of intermediate iterations
 f&:F       if            1+&:+2 yields 2
 f;:F       monaddyad     -;:+5 yields -5, 1-;:+5 yields 6