diff options
author | Christian Neukirchen <chneukirchen@gmail.com> | 2015-12-09 14:17:12 +0100 |
---|---|---|
committer | Christian Neukirchen <chneukirchen@gmail.com> | 2015-12-09 14:17:12 +0100 |
commit | 4af2965c747210abb8ca2a405b45bcd1e513074e (patch) | |
tree | 269fd7dabac2bae716adc193e684292a01f07c93 /day9.k | |
parent | 3f63cb8a2d53fd33ce800ca6944a92af0c6b1b24 (diff) | |
download | adventofcode2015-4af2965c747210abb8ca2a405b45bcd1e513074e.tar.gz adventofcode2015-4af2965c747210abb8ca2a405b45bcd1e513074e.tar.xz adventofcode2015-4af2965c747210abb8ca2a405b45bcd1e513074e.zip |
day9
Diffstat (limited to 'day9.k')
-rw-r--r-- | day9.k | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/day9.k b/day9.k new file mode 100644 index 0000000..4ae90d1 --- /dev/null +++ b/day9.k @@ -0,0 +1,18 @@ +d:0:"day9"; + +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]}; + +dist:[]; +{.[`dist;`$x[0 2];:; 0$x[4]] + .[`dist;`$x[2 0];:; 0$x[4]] +}'l; + +places: !dist; + +ds:{+/dist':x}'places@perm@#places; + +&/ds / shortest route +|/ds / longest route |