Get the input first, then process. I would write a separate function for getting the input and processing the test cases. This makes it easy to dummy in data while testing the processing.
def input_testcases():
"""Input testcase data
Input
The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
The first line of each test case contains a single integer N.
The second line contains N space-seperated integers X1,X2,…,XN.
"""
return [[3, 6], [1, 3, 5], [1, 2, 5, 6, 7]] # For initial testing
test_cases = []
for _ in range(int(input())):
n=int(input())
test_cases.append(list(map(int,input().split())))
return test_cases
def infection_range(test_case, min_space):
"""Assuming one random individual is infected, determine the
minimum and maximum number of people to be infected given
the spacing information in the test case and the infection
envelope minspace.
"""
return [1, 1] # Replace with real code
test_cases = input_testcases()
print(test_cases) # Only use when verifying input_testcases
for test_case in test_cases:
print(*infection_range(test_case, 2))
The processing for each test case is to find the minimum infection group and the maximum infection group. I would start by finding the size of each infection group.
What is the logic for finding the size of an infection group?