Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed

image text in transcribed

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

New Trends In Databases And Information Systems Adbis 2019 Short Papers Workshops Bbigap Qauca Sembdm Simpda M2p Madeisd And Doctoral Consortium Bled Slovenia September 8 11 2019 Proceedings

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Robert Wrembel ,Mirjana Ivanovic ,Johann Gamper ,Mikolaj Morzy ,Theodoros Tzouramanis ,Jerome Darmont

1st Edition

3030302776, 978-3030302771

More Books

Students also viewed these Databases questions