From 7a0053a986d5e691a0432291b8e077c212bbfc24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A6=C3=BE=27n=20Lasseter?= Date: Thu, 17 Dec 2015 20:10:35 +0000 Subject: Day 9, nogo so far --- day9/Makefile | 1 + day9/day9.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ day9/day9.input | 28 ++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 120000 day9/Makefile create mode 100644 day9/day9.c create mode 100644 day9/day9.input 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 +#include + +#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 -- cgit v1.2.1