Question: Please help me to write this exercise in python. From standard input, read two lists in the standard way (one number per row, terminated by

Please help me to write this exercise in python.

Please help me to write this exercise in python. From standard input,

read two lists in the standard way (one number per row, terminated

by -1) and decide, if they are shift-equivalent - that is, if

From standard input, read two lists in the standard way (one number per row, terminated by -1) and decide, if they are shift-equivalent - that is, if the second list can be transformed to the first one by circular shifting its components. By circular shift we mean the transformation of a list to list [k:] + list [:k], for example: [1,2,3,4,5],k=2[4,5]+[1,2,3][4,5,1,2,3] If you find that the two lists are shift-equivalent, print on the standard output the required shift, defined for this exercise as the number of positions the second list has to be shifted to the right to become equal to the first list (an integer from 0 to len (list2) - 1. If the lists are not shift-equivalent, print 1. Example 1 Input: 1231 Output: 1 Example 2 Input: 0 1 2 3 4 5 6 7 8 9 1 3 4 5 6 7 8 9 0 1 Notes ReCodEx tests for this exercise are: - lists of Example 2 with shift 3 - the same, reversed order - a sequence of 1000 random integers from 1 to 100 , unspecified shift - similar sequence, but the lists are not shift-equal

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!