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 smallest number that has not already been shifted is taken out and placed at the extreme right end of the line, every other element keeping its relative position. The machine does not always shift every number: it stops as soon as a step produces a line whose leftmost element is a word, and if that never happens it stops when the last number has been shifted.
Input: cedar 82 fennel 37 gorse 19 hazel 54.
Which of the following is the last step of the above arrangement?

Competition practiceInput-Output
  • Acedar 82 fennel gorse hazel 54 19 37
  • Bcedar fennel gorse hazel 19 37 54 82
  • Ccedar 82 fennel 37 gorse hazel 54 19
  • Dcedar 82 fennel gorse hazel 19 37 54

Step-by-Step Solution

The smallest number is 19, so Step 1 gives cedar 82 fennel 37 gorse hazel 54 19. The leftmost element of that line is cedar, a word, so the machine stops immediately — after a single step. The trap is that the input already begins with a word, which tempts a solver either to halt before making any move at all or to ignore the condition and keep going. The rule tests the line a step produces, so Step 1 is made and then the machine halts. Had it run on, Step 2 would have been cedar 82 fennel gorse hazel 54 19 37, Step 3 cedar 82 fennel gorse hazel 19 37 54, and Step 4 cedar fennel gorse hazel 19 37 54 82 — the three other lines offered.
Answer: C) cedar 82 fennel 37 gorse hazel 54 19

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 works on an input line of words and two-digit…A word-and-number arrangement machine works on an input line of words and two-digit…