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: 26 orchid 53 pebble 44 tundra 31 willow.
Which of the following is Step 2 of the above arrangement?

Competition practiceInput-Output
  • A31 26 orchid 53 pebble 44 tundra willow
  • B31 53 26 orchid pebble 44 tundra willow
  • C53 31 26 orchid pebble 44 tundra willow
  • D53 31 orchid 26 pebble 44 tundra willow

Step-by-Step Solution

The primes in the line are 31 and 53; 26 and 44 are not prime. Primes go first, smallest before largest, so the order of shifting is 31, 53, then 26, then 44. Step 1: 31 26 orchid 53 pebble 44 tundra willow. Step 2: 53 31 26 orchid pebble 44 tundra willow. Two traps sit close by: ignoring primeness altogether and simply sorting the numbers upwards would make 26 the first to move, and dropping the second prime just to the right of the first instead of at the extreme left gives 31 53 26 rather than 53 31 26.
Answer: C) 53 31 26 orchid pebble 44 tundra willow

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