Question: PYTHON - Write a function named has_mirror_twice that accepts two lists of integers a1 and a2 as parameters and returns True if a1 contains all

PYTHON -

Write a function named has_mirror_twice that accepts two lists of integers a1 and a2 as parameters and returns True if a1 contains all the elements of a2 in reverse order at least twice (and False otherwise). For example, if a2 stores the elements [1, 2, 3] and a1 stores the elements [6, 3, 2, 1, 4, 1, 3, 2, 1, 5], your function would return True.

Assume that both lists passed to your function will have a length of at least 1. This means that the shortest possible mirror will be of length 1, representing a single element (which is its own mirror). A sequence that is a palindrome (the same forwards as backwards) is considered its own mirror and should be included in your computations. For example, if a1 is [6, 1, 2, 1, 4, 1, 2, 1, 5] and a2 is [1, 2, 1], your function should return True. The two occurrences of the mirror might overlap, as shown in the fourth sample call below.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!