about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2015-12-09 14:17:12 +0100
committerChristian Neukirchen <chneukirchen@gmail.com>2015-12-09 14:17:12 +0100
commit4af2965c747210abb8ca2a405b45bcd1e513074e (patch)
tree269fd7dabac2bae716adc193e684292a01f07c93
parent3f63cb8a2d53fd33ce800ca6944a92af0c6b1b24 (diff)
downloadadventofcode2015-4af2965c747210abb8ca2a405b45bcd1e513074e.tar.gz
adventofcode2015-4af2965c747210abb8ca2a405b45bcd1e513074e.tar.xz
adventofcode2015-4af2965c747210abb8ca2a405b45bcd1e513074e.zip
day9
-rw-r--r--day928
-rw-r--r--day9.k18
2 files changed, 46 insertions, 0 deletions
diff --git a/day9 b/day9
new file mode 100644
index 0000000..97a6b63
--- /dev/null
+++ b/day9
@@ -0,0 +1,28 @@
+Faerun to Tristram = 65
+Faerun to Tambi = 129
+Faerun to Norrath = 144
+Faerun to Snowdin = 71
+Faerun to Straylight = 137
+Faerun to AlphaCentauri = 3
+Faerun to Arbre = 149
+Tristram to Tambi = 63
+Tristram to Norrath = 4
+Tristram to Snowdin = 105
+Tristram to Straylight = 125
+Tristram to AlphaCentauri = 55
+Tristram to Arbre = 14
+Tambi to Norrath = 68
+Tambi to Snowdin = 52
+Tambi to Straylight = 65
+Tambi to AlphaCentauri = 22
+Tambi to Arbre = 143
+Norrath to Snowdin = 8
+Norrath to Straylight = 23
+Norrath to AlphaCentauri = 136
+Norrath to Arbre = 115
+Snowdin to Straylight = 101
+Snowdin to AlphaCentauri = 84
+Snowdin to Arbre = 96
+Straylight to AlphaCentauri = 107
+Straylight to Arbre = 14
+AlphaCentauri to Arbre = 46
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