aboutsummaryrefslogtreecommitdiff
path: root/day16.k
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2015-12-16 14:07:47 +0100
committerChristian Neukirchen <chneukirchen@gmail.com>2015-12-16 14:07:47 +0100
commit24182ea87ccea37d00ffa4c15583ac1b97e613e5 (patch)
tree9029d90bc4af2216d8202cfcc59ff8141c420b4e /day16.k
parent2c7509233aebb59f2168b27e3d704dc0d6ad725f (diff)
downloadadventofcode2015-24182ea87ccea37d00ffa4c15583ac1b97e613e5.tar.gz
adventofcode2015-24182ea87ccea37d00ffa4c15583ac1b97e613e5.tar.xz
adventofcode2015-24182ea87ccea37d00ffa4c15583ac1b97e613e5.zip
day16
Diffstat (limited to 'day16.k')
-rw-r--r--day16.k25
1 files changed, 25 insertions, 0 deletions
diff --git a/day16.k b/day16.k
new file mode 100644
index 0000000..334f07b
--- /dev/null
+++ b/day16.k
@@ -0,0 +1,25 @@
+k:[];
+k[`children]: 3;
+k[`cats]: 7;
+k[`samoyeds]: 2;
+k[`pomeranians]: 3;
+k[`akitas]: 0;
+k[`vizslas]: 0;
+k[`goldfish]: 5;
+k[`trees]: 3;
+k[`cars]: 2;
+k[`perfumes]: 1;
+
+d:0:"day16";
+ss:{1 _' (&y=y,x) _ y,x}; / split x at y
+l:{ss[x,",";" "]}' d;
+
+s:{. {(`$-1_ x[0]), 0$-1_ x[1]}' -1 2 # 2_ x}' l; / parse
+1+*&{&/(k@!x)=x@!x}'s
+
+i:{x@&x _in\: y}; / set intersection
+
+1+*&{f:i[!x;`cats`trees]
+ l:i[!x;`pomeranians`goldfish]
+ e:i[!x;`children`samoyeds`akitas`cars`perfumes`vizslas]
+ &/(k[f]<x[f]),(k[l]>x[l]),(k[e]=x[e])}'s