aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNæþ'n Lasseter <Næþ'n Lasseter nathan@bytemark.co.uk>2015-12-17 20:10:35 +0000
committerNæþ'n Lasseter <Næþ'n Lasseter nathan@bytemark.co.uk>2015-12-17 20:10:35 +0000
commit7a0053a986d5e691a0432291b8e077c212bbfc24 (patch)
treed12858584b7e0364d1a5c6d98126eea0cf274717
parentd79e5901299d277fab0d04d3f6b2b09cf1527da4 (diff)
Day 9, nogo so far
l---------day9/Makefile1
-rw-r--r--day9/day9.c44
-rw-r--r--day9/day9.input28
3 files changed, 73 insertions, 0 deletions
diff --git a/day9/Makefile b/day9/Makefile
new file mode 120000
index 0000000..d0b0e8e
--- /dev/null
+++ b/day9/Makefile
@@ -0,0 +1 @@
+../Makefile \ No newline at end of file
diff --git a/day9/day9.c b/day9/day9.c
new file mode 100644
index 0000000..0a47ac0
--- /dev/null
+++ b/day9/day9.c
@@ -0,0 +1,44 @@
+#include <stdio.h>
+#include <string.h>
+
+#define MAXCITIES 8
+
+char* cities[MAXCITIES];
+int matrix[MAXCITIES][MAXCITIES];
+int seencity = 0;
+
+int cityindex(char* city) {
+ int i;
+ for(i = 0; i < seencity ; i++)
+ if(strcmp(city, cities[i]) == 0)
+ return i;
+ return -1;
+}
+
+int addcity(char* city) {
+ cities[seencity++] = city;
+ return seencity;
+}
+
+void input(char* from, char* to, int dist) {
+ int f, t;
+ f = cityindex(from);
+ t = cityindex(to);
+ if(f == -1) f = addcity(from);
+ if(t == -1) t = addcity(to);
+ matrix[f][t] = dist;
+ matrix[t][f] = dist;
+}
+
+int main() {
+ char from[20], to[20];
+ int dist, mindist, tourid;
+
+ while(scanf("%s to %s = %d", from, to, &dist) != EOF)
+ input(from, to, dist);
+
+ dist = 0; mindist = 0x7FFFFFFF;
+
+
+ return 0;
+}
diff --git a/day9/day9.input b/day9/day9.input
new file mode 100644
index 0000000..a56f5e2
--- /dev/null
+++ b/day9/day9.input
@@ -0,0 +1,28 @@
+AlphaCentauri to Snowdin = 66
+AlphaCentauri to Tambi = 28
+AlphaCentauri to Faerun = 60
+AlphaCentauri to Norrath = 34
+AlphaCentauri to Straylight = 34
+AlphaCentauri to Tristram = 3
+AlphaCentauri to Arbre = 108
+Snowdin to Tambi = 22
+Snowdin to Faerun = 12
+Snowdin to Norrath = 91
+Snowdin to Straylight = 121
+Snowdin to Tristram = 111
+Snowdin to Arbre = 71
+Tambi to Faerun = 39
+Tambi to Norrath = 113
+Tambi to Straylight = 130
+Tambi to Tristram = 35
+Tambi to Arbre = 40
+Faerun to Norrath = 63
+Faerun to Straylight = 21
+Faerun to Tristram = 57
+Faerun to Arbre = 83
+Norrath to Straylight = 9
+Norrath to Tristram = 50
+Norrath to Arbre = 60
+Straylight to Tristram = 27
+Straylight to Arbre = 81
+Tristram to Arbre = 90