Search for question
Question

Question 1: (file name: filter.py) (35 points): Sometimes we need to filter a signal by frequency, e.g., to reduce noise outside of the desired frequency range. Filters can be stacked, allowing only the frequencies within the range allowed by all filters to get through. For example, three filters with ranges of (10, 17), (13, 15) and (13, 17) will only allow signals between 13 and 15 through. The only range that all filters overlap is (13, 15). Given n signals' frequencies and a series of m filters that let through frequencies in the range x to y, inclusive, determine the number of signals that will get through the filters. There will be only one range where all the filters overlap. For example, for the frequencies [8, 15, 14, 16, 21] and given filter ranges [[10, 17], [13, 15], [13, 17]], the range all the filters allow through is from 13 to 15, inclusive. The 2 frequencies that will pass through all filters have frequencies of 15 and 14. Develop a function called count_signals that accepts two parameters, frequencies, which is a list of frequencies of the signals sent through the filters, and filter ranges, which is a list of ranges (each range is a list with exactly 2 elements) that have the lower and upper frequency bounds for each filter. This function should return the number of signals that pass through all filters. For example if the function is called as count_signals([8, 15, 14, 16, 21], [[10, 17], [13, 15], [13, 17]]), it should return 2. Demonstrate its use by printing the result of the example above.

Fig: 1