about summary refs log tree commit diff
path: root/day8.k
diff options
context:
space:
mode:
Diffstat (limited to 'day8.k')
-rw-r--r--day8.k19
1 files changed, 19 insertions, 0 deletions
diff --git a/day8.k b/day8.k
new file mode 100644
index 0000000..cf89ef4
--- /dev/null
+++ b/day8.k
@@ -0,0 +1,19 @@
+/ use k-3.2
+
+d:0:"day8"
+
+ll: +/#:'d / literal length
+
+ue:{
+ s:_ssr[x;"\\\\";"z"]
+ s:_ssr[s;"\\\"";"z"]
+ :(#s)-2+3*+/"\\"=s
+}
+
+ml: +/ue'd / unencoded length
+
+ll-ml
+
+el: {2+(#x)+#&("\""=x)|("\\"=x)} / encoded length
+
+(+/el' d)-ll