#input draws from cities. produce table in format
# ritardo, times occurred, times appeared next draw, ratio, z-value

$p=1/18;
$q=17/18;
$var=$p*$q;

while ($file=shift) {
    open CITY, $file;

    for (1..90) {
        $delay[$_]=0;
        }

    while (<CITY>) {
        ($date, @nums) = split;
        #print "@nums:  ";
        #for (@nums) {
        #print $delay[$_]." ";
        #}
        #print "\n";
        %seen=();
        for $i (@nums) {
        $seen{$i}=1;
        }
        for (1..90) {
            $count[$delay[$_]]++;
            if (defined $seen{$_}) {
                $success[$delay[$_]]++;
                $delay[$_]=0;
                } else {
                $delay[$_]++;
                }
            }
        }

    close CITY;
    }

for $r (0..$#count) {
    print $r." ".$count[$r]." ".$success[$r]." ";
    $f=$success[$r]/$count[$r];
    print $f." ";
    $z=($f-$p)/sqrt($var/$count[$r]);
    print $z."\n";
    }