ens-ulm-1-2015

google hashcode 2015 source for team ens-ulm-1
git clone https://a3nm.net/git/ens-ulm-1-2015/
Log | Files | Refs

master.sh (579B)


      1 #!/bin/bash
      2 
      3 trap './cleanup.sh && kill $(jobs -p)' EXIT
      4 
      5 I="1"
      6 cat targets | while read l; do
      7   I=$(($I+1))
      8   echo "spawn $l"
      9   (./run.sh $l > runout$I) &
     10 done
     11 
     12 inotifywait -e MODIFY runout* >/dev/null 2>/dev/null
     13 
     14 pkill run.sh
     15 ps aux | grep runtillbetter |awk '{print $2}' | xargs kill
     16 ps aux | grep run |awk '{print $2}' | xargs kill
     17 
     18 BEST=0
     19 for a in runout*
     20 do
     21   NEW=$(head -1 $a | cut -d ' ' -f2)
     22   if [ "x$NEW" = "x" ]
     23   then
     24     echo nop > /dev/null
     25   else
     26     if [ $NEW -gt $BEST ]
     27     then
     28       head -1 $a
     29       cp $a input
     30     fi
     31   fi
     32 done
     33 
     34 ./cleanup.sh
     35 pkill run.sh
     36