Operation on string
Source: STEMS 2021 CS Cat A Q5
January 23, 2021
combinatorics
Problem Statement
Given a string of length , we perform the following operation: [*]Place all the even indexed positions together, and then all the odd indexed positions next. Indexing is done starting from .[/*] For example, say our string is ``abcdef''. Performing our operation yields ``abcdef'' ``acebdf''. Performing the operation again yields ``acebdf'' ``aedcbf''. Doing this repeatedly, we have:\\
``abcdef'' ``acebdf'' ``aedcbf'' ``adbecf'' ``abcdef''.\\\\
You can assume that the characters in the string will be unique. It can be shown that, by performing the above operation a finite number of times we can get back our original string.\\\\
Given , you have to determine the minimum number of times the operation must be performed to get our original string of length back.\\\\
In the example given above, . The minimum steps required is .