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

runtillbetter.sh (385B)


      1 #!/bin/bash
      2 
      3 trap 'kill $(jobs -p)' EXIT
      4 
      5 touch output$2
      6 (./a.out "$1" <(sed 1d input) output$2 < final_round.in >&2) &
      7 PID=$!
      8 head -1 output$2 > head1$2
      9 while true;
     10 do
     11   inotifywait -e MODIFY output$2 >/dev/null 2>/dev/null
     12   head -1 output$2 > head1b$2
     13   if diff head1$2 head1b$2 > /dev/null
     14   then
     15     echo nop >&2
     16   else
     17     echo OK >&2
     18     break
     19   fi
     20 done
     21 kill $PID
     22 cat output$2
     23