aboutsummaryrefslogtreecommitdiff
path: root/day9/day9.c
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 /day9/day9.c
parentd79e5901299d277fab0d04d3f6b2b09cf1527da4 (diff)
Day 9, nogo so far
Diffstat (limited to 'day9/day9.c')
-rw-r--r--day9/day9.c44
1 files changed, 44 insertions, 0 deletions
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;
+}