diff options
author | Christian Neukirchen <chneukirchen@gmail.com> | 2015-12-14 13:55:24 +0100 |
---|---|---|
committer | Christian Neukirchen <chneukirchen@gmail.com> | 2015-12-14 13:55:24 +0100 |
commit | 6e1a90e46bf2ad22b0c10f27541b0f7413cc2a7a (patch) | |
tree | 418cfb0702f32a4fd39af554c5b56ff23634d8a1 /day13.k | |
parent | bfab0ac65ae9860285c66704e260dde434d5da1f (diff) | |
download | adventofcode2015-6e1a90e46bf2ad22b0c10f27541b0f7413cc2a7a.tar.gz adventofcode2015-6e1a90e46bf2ad22b0c10f27541b0f7413cc2a7a.tar.xz adventofcode2015-6e1a90e46bf2ad22b0c10f27541b0f7413cc2a7a.zip |
day13
Diffstat (limited to 'day13.k')
-rw-r--r-- | day13.k | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/day13.k b/day13.k new file mode 100644 index 0000000..fc3cde0 --- /dev/null +++ b/day13.k @@ -0,0 +1,24 @@ +d:0:"day13"; + +d:-1 _' d; + +ss:{1 _' (&y=y,x) _ y,x}; / split x at y +l:ss[;" "]' d; + +perm: {:[1<x;,/(>:'(x,x)#1,x#0)[;0,'1+_f x-1];,!x]}; + +happy:[]; +{ + .[`happy;`$x[0 10];:; :["gain"~x[2];1;-1]*0$x[3]] +}'l; + +ppl: !happy; +hs:{(+/happy':x,*x)+(+/happy':|x,*x)}'ppl@perm@#ppl; +|/hs / maximize happiness + +{.[`happy;`Me,x;:; 0]; + .[`happy;x,`Me;:; 0]}'ppl + +ppl: `Me,ppl; +hs:{(+/happy':x,*x)+(+/happy':|x,*x)}'ppl@perm@#ppl; +|/hs / maximize happiness |