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 machine compares the last letters of the words that have not already been shifted, takes the word whose last letter comes earliest in the alphabet, and places it at the extreme left end of the line; if two words end in the same letter, the shorter one is taken first. Every other element keeps its relative position, and the machine stops once every word has been shifted.
Input: 45 tundra 68 basil 27 walrus 39 hymn.
Which of the following is the last step of the above arrangement?

Competition practiceInput-Output
  • Atundra basil hymn walrus 45 68 27 39
  • Bwalrus tundra hymn basil 45 68 27 39
  • Cwalrus hymn basil tundra 27 39 45 68
  • Dwalrus hymn basil tundra 45 68 27 39

Step-by-Step Solution

Last letters: tundra ends in a, basil in l, hymn in n, walrus in s, so the words go out in that order. Step 1: tundra 45 68 basil 27 walrus 39 hymn. Step 2: basil tundra 45 68 27 walrus 39 hymn. Step 3: hymn basil tundra 45 68 27 walrus 39. Step 4: walrus hymn basil tundra 45 68 27 39. Since each word lands at the extreme left, the finished block reads in the reverse of the shifting order — writing tundra basil hymn walrus records the moves rather than the line. A first-letter machine would have finished with walrus tundra hymn basil. The numbers are never shifted, so they hold the order 45, 68, 27, 39 and do not sort themselves.
Answer: D) walrus hymn basil tundra 45 68 27 39

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,…