commit b8ec451cf52b116fca94d4fb72823445efc13031
parent f00e2c1fd652012bbccfcc83d647cd39cd825313
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Thu, 21 May 2015 11:25:59 +0200
tidy
Diffstat:
5 files changed, 91 insertions(+), 16 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -3,5 +3,9 @@ old/*
 routes.dat
 routesb.dat
 routesc.dat
+routesd.dat
 active.dat
 airlines.dat
+routes_active.dat
+routes_naive.dat
+routes_fix.dat
diff --git a/forbidden b/forbidden
@@ -0,0 +1,60 @@
+# greenland
+NAQ
+JAV
+THU
+SVR
+JUV
+QFG
+QOQ
+QFN
+QUV
+# panama
+SAX
+# borek air is supposed to have flights but no one sells them
+YGZ
+# seems no one flies there
+PIP
+# no flights
+STZ
+SXO
+GRP
+# apparently no flights
+BVI
+BEU
+BQL
+IRP
+BUX
+BNC
+GOM
+FKI
+# regional express flights
+XTG
+CMA
+SGO
+TWB
+YPC
+# aklak
+YPC
+YUB
+ZFM
+# compagnie africaine d'aviation
+FMI
+KOO
+BKY
+KND
+# brazil
+CDJ
+CMP
+RDC
+OIA
+SXX
+#
+KPR
+SYB
+KKB
+# wright
+ARC
+VEE
+#
+WWP
+NKI
diff --git a/number.sh b/number.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+# all unregistered airlines get the same code
+# we rely on the fact that all \N come last
+
+awk '{if ($1 == "\\N") {
+    print n, $2, $3;
+    # n++;
+  } else {
+    print $0;
+    n = n > $1?n:$1;
+  } }'
diff --git a/pairs_naive.out b/pairs_naive.out
@@ -0,0 +1,2 @@
+15: XEQ -> YPO: XEQ QUV QFN JNN JJU UAK GOH KEF YYZ YQT YTS YMO YFA ZKE YAT YPO 
+15: YPO -> QFN: YPO YAT ZKE YFA YMO YTS YTZ IAD KEF GOH UAK JJU JNN XEQ QUV QFN 
diff --git a/smallworld.sh b/smallworld.sh
@@ -16,22 +16,19 @@ echo "\\N Y" >> active.dat
 sort -k1,1 active.dat | sponge active.dat
 
 cut -d, -f2,3,5,7 routes.dat | grep -v 'Y$' | tr ',' ' ' |
-  cat - <(sed 's/#.*//' routes_add) | sort -k1,1 > routesb.dat
-
-# all unregistered airlines get the same code
-# we rely on the fact that all \N come last
-join routesb.dat active.dat |
-  grep -v 'N$' | cut -d ' ' -f1-3 |
-  awk '{if ($1 == "\\N") {
-    print n, $2, $3;
-    # n++;
-  } else {
-    print $0;
-    n = n > $1?n:$1;
-  } }' | grep -vE `cat forbidden | grep -v '#' | tr '\n' '|' | sed 's/|$//'` |
-  sed "`cat changes | sed 's/\(...\) \(...\)/s_\1_\2_g;/'`" > routesc.dat
+  sort -k1,1 | join - active.dat |
+  grep -v 'N$' | cut -d ' ' -f1-3 > routes_active.dat
+ 
+sort -k1,1 routes_active.dat |
+  ./number.sh > routes_naive.dat
+cat routes_active.dat <(sed 's/#.*//' routes_add) |
+  sed "`cat changes | sed 's/\(...\) \(...\)/s_\1_\2_g;/'`" |
+  grep -vE `cat forbidden | grep -v '#' | tr '\n' '|' | sed 's/|$//'` |
+  sort -k1,1 |
+  ./number.sh > routes_fix.dat
 
 g++ -Wall -o smallworld -O3 smallworld.cpp
-./smallworld < routesc.dat | tee pairs.out
-./smallworld close < routesc.dat | tee pairs_close.out
+./smallworld < routes_naive.dat | tee pairs_naive.out
+./smallworld close < routes_fix.dat | tee pairs_close.out
+./smallworld < routes_fix.dat | tee pairs.out