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 attends to the prime numbers first: it takes the smallest prime that has not already been shifted and places it at the extreme left end of the line. Once no prime is left unshifted, it takes the smallest of the remaining numbers and places it at the extreme left end in the same way. Every other element keeps its relative position, and the machine stops once every number has been shifted.
Input: marlin 91 cobalt 38 fennel 57 gulley 43.
Which of the following is Step 2 of the above arrangement?

Competition practiceInput-Output
  • A91 43 marlin cobalt 38 fennel 57 gulley
  • B38 43 marlin 91 cobalt fennel 57 gulley
  • C57 43 marlin 91 cobalt 38 fennel gulley
  • D43 38 marlin 91 cobalt fennel 57 gulley

Step-by-Step Solution

Only one of these four numbers is prime. 91 is 7 times 13 and 57 is 3 times 19, and 38 is even, so 43 is the sole prime and it moves first; after that the remaining numbers go in plain ascending order, 38, then 57, then 91. Step 1: 43 marlin 91 cobalt 38 fennel 57 gulley. Step 2: 38 43 marlin 91 cobalt fennel 57 gulley. Both of the near-prime traps are offered: believing 57 prime makes Step 2 begin with 57, and believing 91 prime makes it begin with 91. The fourth line drops 38 to the right of 43 instead of at the extreme left.
Answer: B) 38 43 marlin 91 cobalt fennel 57 gulley

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