Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (4 votes)
3K views

E2 String

John and Michael take turns modifying a string by removing letters from the end and adding them to the beginning based on chosen indices P and Q. The document describes an algorithm where they continue this process of modifying the string until the original string is returned, and asks the reader to write a program that takes the original string, P, and Q as input and outputs the number of turns it takes to return to the original string.

Uploaded by

Parwaz Rahman
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (4 votes)
3K views

E2 String

John and Michael take turns modifying a string by removing letters from the end and adding them to the beginning based on chosen indices P and Q. The document describes an algorithm where they continue this process of modifying the string until the original string is returned, and asks the reader to write a program that takes the original string, P, and Q as input and outputs the number of turns it takes to return to the original string.

Uploaded by

Parwaz Rahman
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

CLP_Core Java_E2 - Hands-on 1


John and Micheal take a word string:

John chooses a number P (less than the length of the string), and Micheal chooses Q
(less than the length of the string).

John reduces P alphabets from the end of the string, adds it to the beginning, and
gives it to Micheal.

Micheal reduces Q alphabets from the end of the string, adds it to the beginning,
and gives it to John.

This process continues until they get the original word string.

For a given string, and the given values of P and Q, find the number of turns to
get the original word string.

Input Specification:
input1: Original word string
input2: Value of P
input3: Value of Q

Output Specification:
The number of turns to get the original word string.

Example

input: abcabc
input2: 1
input3: 1

Output: 3

Explanation:
turn 1: cabcab
turn 2: bcabca
turn 3: abcabc

All the three inputs are given as command line arguments.

Web IDE

Test Results
Help
Run Tests

You might also like