aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2015-12-07 15:44:45 +0100
committerChristian Neukirchen <chneukirchen@gmail.com>2015-12-07 15:44:45 +0100
commit1ba60f272d94629dfa1219b11464596f295e5d67 (patch)
tree67b022f15bfd840d089cdfc474c8891d8fa6c2e0
parentaaf16ff170dfceb12c816f01ec7870f5fc285885 (diff)
downloadadventofcode2015-1ba60f272d94629dfa1219b11464596f295e5d67.tar.gz
adventofcode2015-1ba60f272d94629dfa1219b11464596f295e5d67.tar.xz
adventofcode2015-1ba60f272d94629dfa1219b11464596f295e5d67.zip
day3/5: monadic ? is uniq already.
-rw-r--r--day3.k9
-rw-r--r--day5.k3
2 files changed, 5 insertions, 7 deletions
diff --git a/day3.k b/day3.k
index f4e8791..92812cc 100644
--- a/day3.k
+++ b/day3.k
@@ -1,10 +1,9 @@
d: *0:"day3";
/ with case z:{:[x=">";1 0;x="<";-1 0;x="^";0 1;x="v";0 -1; 0 0]}'d;
z: (1 0;-1 0;0 1;0 -1) @ "<>^v"?/:d;
-u: {x@*:'=x};
-r: u@ +\ (, 0 0) , z;
-#r
+r: +\ (, 0 0) , z;
+#?r
z2: + -1 2 # z; / alternating split
-r2: u@ ,/ +\' (,0 0) ,/: z2;
-#r2
+r2: ,/ +\' (,0 0) ,/: z2;
+#?r2
diff --git a/day5.k b/day5.k
index 938d43c..09fef93 100644
--- a/day5.k
+++ b/day5.k
@@ -7,9 +7,8 @@ r3: {~#,/x _ss ("ab";"cd";"pq";"xy")}; / no ab/cd/pq/xy
#&(r3'd)&(r2'd)&(r1'd)
bg: {[s]{x;2#(x-1) _ s}'1+!#s}; / bigrams
-u: {x@*:'=x}; / uniq
-r4: {0<#&1<#:' x _ss u@bg x}; / duplicate bigram
+r4: {0<#&1<#:' x _ss ?bg x}; / duplicate bigram
r5: {0<#&(-2_ x)=(2_ x)}; / matches (.).\1
#&(r4'd)&(r5'd)