Practice30Create account

A word-and-number arrangement machine, when given an input line of words and numbers, rearranges it in steps. In each step two shifts happen together: the smallest odd number not already shifted is taken out and placed at the extreme left end of the line, and at the same time the largest even number not already shifted is taken out and placed at the extreme right end. If only one of the two kinds is still left, that step makes only that one shift. Every other element keeps its relative position, and the machine stops once every number has been shifted.
Input: 57 dahlia 28 fennel 93 gorse 46 holly 71.
Which of the following is Step 2 of the above arrangement?

Competition practiceInput-Output
  • A71 57 dahlia fennel 93 gorse holly 46 28
  • B71 93 57 dahlia fennel gorse holly 46 28
  • C57 71 dahlia fennel 93 gorse holly 28 46
  • D57 dahlia 28 fennel 93 gorse holly 71 46

Step-by-Step Solution

Odd numbers: 57, 93, 71. Even numbers: 28, 46. Step 1 sends the smallest odd number 57 left and the largest even number 46 right: 57 dahlia 28 fennel 93 gorse holly 71 46. Step 2 sends the next smallest odd number, 71, left and the remaining even number, 28, right: 71 57 dahlia fennel 93 gorse holly 46 28. Working from the largest odd number downwards instead would send 93 out first and leave 93 sitting second, which is the near-miss line here. Dropping each new number next to the one already placed, rather than at the extreme end, reverses both blocks.
Answer: A) 71 57 dahlia fennel 93 gorse holly 46 28

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