def counts_in_out_packets(packets):
    """
    Counts the number of packets in & out in the array packets

    @param packets is a list of packets, structured as follows: `[(time, direction)]`

    @return tuple `(num_packets_in, num_packets_out)`
    """
    packets_in, packets_out = [], []

    for val in packets:
        if val[1] < 0:
            packets_in.append(val)
        elif val[1] > 0:
            packets_out.append(val)

    return (len(packets_in), len(packets_out))