PY-13
Take a Bounded Window around a Position
Task
Write bounded_window(values, position, radius). position is a valid index
in values, and radius is a non-negative integer. Build a window containing
the selected value, up to radius values before it, and up to radius values
after it.
Return a five-item tuple:
(window, start, stop, truncated_left, truncated_right)
windowis a new list containingvalues[start:stop].startis the included window's zero-based start index.stopis its half-open stop index: the value atstopis not included.truncated_leftisTruewhen the requested left boundary would be before index0, andFalseotherwise.truncated_rightisTruewhen the requested right boundary would be after the list, andFalseotherwise.
Clip the boundaries to the list. The input list must not change.
Example
At an edge, the window is shorter and records which side was clipped:
Your implementation
Edit solution.py and keep this function name and signature:
Return the required tuple; do not print it or ask for input. You may assume
that values is non-empty, position is valid, and radius is non-negative.