Practice30Create account

A word-and-number arrangement machine, when given an input line of words and numbers, rearranges it in steps. In each step the word having the most letters, among the words not already shifted in an earlier step, is taken out and placed at the extreme right end of the line; if two words are equally long, the one that comes earlier in alphabetical order is taken first. Every other element keeps its relative position, and the machine stops once every word has been shifted.
Input: 53 grapefruit 28 ivy 76 palace 34 nest.
Which of the following is the last step of the above arrangement?

Competition practiceInput-Output
  • A53 28 76 34 ivy nest palace grapefruit
  • B53 28 76 34 grapefruit palace nest ivy
  • Cgrapefruit palace nest ivy 53 28 76 34
  • D53 28 76 34 grapefruit palace ivy nest

Step-by-Step Solution

Letter counts: grapefruit 10, palace 6, nest 4, ivy 3. Step 1: 53 28 ivy 76 palace 34 nest grapefruit. Step 2: 53 28 ivy 76 34 nest grapefruit palace. Step 3: 53 28 ivy 76 34 grapefruit palace nest. Step 4: 53 28 76 34 grapefruit palace nest ivy. Because each word is dropped at the extreme right, the word shifted first ends up furthest left of the four, so the block runs longest to shortest. Reading it shortest to longest reverses the whole block, and sending the words to the left instead of the right puts them in front of the numbers.
Answer: B) 53 28 76 34 grapefruit palace nest ivy

Master this topic in 30 minutes a day.

Don't just memorise the answer — build a daily practice habit.

Practice 5 Similar Questions Free →

All Input-Output practice questions

More Input-Output practice

A word-and-number arrangement machine, when given an input line of words and numbers,…A word-and-number arrangement machine, when given an input line of words and numbers,…A word-and-number arrangement machine, when given an input line of words and numbers,…A word-and-number arrangement machine, when given an input line of words and numbers,…A word-and-number arrangement machine, when given an input line of words and numbers,…