Implement the find_zigzag_intervals function in Python that processes a list of test cases to determine the intervals in which a sequence of (height, measurement) pairs forms a zigzag pattern.
Functionality Requirements
Input Handling:
The function takes a single argument named test_cases, which is a list of lists. Each inner list represents a sequence of pairs (height, measurement).
Each pair (height, measurement) consists of two integers.
Processing Logic:
For each sequence in test_cases, the function should analyze the (height, measurement) pairs:
Determine intervals where the height-measurement pairs exhibit a zigzag pattern (alternate between increasing and decreasing).
Return the intervals as results with specific handling for infinite values.
Output Specification:
The function should return a list of tuples. Each tuple contains:
An integer indicating the number of zigzag intervals found.
A list of intervals, where each interval is represented as a tuple in the form (start, end). The end can be either an integer or the string 'Inf' to indicate an infinite interval.
Input/Output Requirements
Input:
test_cases (List[List[Tuple[int, int]]]): A list of test cases, where each test case is a list of tuples, and each tuple contains two integers representing (height, measurement).
Output:
List[Tuple[int, List[Tuple[int, Union[int, str]]]]]: A list of tuples for each test case. Each tuple consists of:
An integer (0 if no intervals found, 1 if one interval found, or 2 if two intervals found).
A list of intervals where each interval is a tuple containing a start integer and an end integer or a string 'Inf'.
Example
Given test_cases = [[(1, 2), (3, 4), (2, 5)], [(3, 2), (1, 3), (4, 1)]],
the output of the function might look like:
text
[(1, [(0, 'Inf')]), (2, [(1, 3), (4, 'Inf')])]
Implementation Location
The solution must be written in a file named /app/solution.py. Ensure the function is correctly defined and adheres to the input/output specifications provided.