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 looks at the words that contain a double letter — the same letter twice in a row — and takes the one standing furthest to the left among those not already shifted, placing it at the extreme left end of the line. Words with no double letter, and all the numbers, are never shifted; every other element keeps its relative position, and the machine stops once every double-letter word has been shifted.
Input: 52 coffee tulip 18 hammer 47 basil summit 63.
How many steps are needed to complete the rearrangement of the above input?

Competition practiceInput-Output
  • A5
  • B4
  • C2
  • D3

Step-by-Step Solution

Of the five words, coffee (ff, and also ee), hammer (mm) and summit (mm) carry a double letter, while tulip and basil do not. Step 1: coffee 52 tulip 18 hammer 47 basil summit 63. Step 2: hammer coffee 52 tulip 18 47 basil summit 63. Step 3: summit hammer coffee 52 tulip 18 47 basil 63, after which nothing qualifies and the machine halts. Three steps. Counting one step per word gives five. Coffee holds two different doubled letters, but it is still one word and moves only once — counting it twice gives four. Overlooking the mm inside summit gives two.
Answer: D) 3

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,…An arrangement machine reshuffles an input line by reversing a block of elements at the…An arrangement machine reshuffles an input line by reversing a block of elements at the…An arrangement machine reshuffles an input line by reversing a block of elements at the…