Question: Defines a function apply _ pattern _ to _ list ( ) , that takes three arguments. You can assume that the first argument is
Defines a function applypatterntolist that takes three arguments. You can assume that the first argument is a list L L of integers, the second argument is a nonempty string the pattern consisting of and only it is set to by default and the third argument is either True or False it is set to True by default If the third argument is True then is removed, again and again, the leftmost element in L L that prevents what is left of L L from the beginning up to that element, to be consistent with the pattern, read from left to right. If the third argument is False then is removed, again and again, the rightmost element in L L that prevents what is left of L L from that element up to the end, to be consistent with the pattern, read from right to left. A in the pattern is for two successive elements the second of which is strictly greater than the first one. A in the pattern is for two successive elements the second of which is strictly smaller than the first one. The pattern is to be thought of as circular as if wrapping around so there is no difference between a pattern and many concatenations of that pattern eg there is no difference between the patterns and there is no difference between the patterns The function returns a dictionary for everything that has been removed from L L: where in the created list an element has been removed the key, as a positive index when processing list and pattern from left to right, as a negative index when processing list and pattern from right to left and what that element is the value
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
