summaryrefslogtreecommitdiffstats
path: root/2021/03/code.tl
diff options
context:
space:
mode:
Diffstat (limited to '2021/03/code.tl')
-rw-r--r--2021/03/code.tl26
1 files changed, 26 insertions, 0 deletions
diff --git a/2021/03/code.tl b/2021/03/code.tl
new file mode 100644
index 0000000..4ffd1f4
--- /dev/null
+++ b/2021/03/code.tl
@@ -0,0 +1,26 @@
+(defun funny-less (left right)
+ (let ((ll (len left))
+ (lr (len right)))
+ (or (< ll lr)
+ (if (eql ll lr)
+ (< (car left) (car right))))))
+
+(defun funny-greater (left right)
+ (let ((ll (len left))
+ (lr (len right)))
+ (or (> ll lr)
+ (if (eql ll lr)
+ (> (car left) (car right))))))
+
+(defun maj-pare-down (list pos)
+ (cdr [find-max [group-by (op ref @1 pos) list] funny-greater]))
+
+(defun min-pare-down (list pos)
+ (cdr [find-min [group-by (op ref @1 pos) list] funny-less]))
+
+(let ((list *2))
+ (each ((i 0..12))
+ (upd list (min-pare-down @1 i)))
+ list)
+
+[apply * (mapcar (op toint @1 2) (flatten results))] ;; results contains two numbers in text form