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 leftmost number greater than 50 that has not already been shifted is taken out and placed at the extreme right end of the line. Numbers of 50 or less, and all the words, are never shifted; every other element keeps its relative position, and the machine stops once every number greater than 50 has been shifted.
Input: 64 pancake 37 rice 82 noodles 45 fritter 59.
Which of the following is the last step of the above arrangement?

Competition practiceInput-Output
  • Apancake 37 rice noodles 45 fritter 64 82 59
  • Bpancake 37 rice noodles 45 fritter 59 64 82
  • Cpancake 37 rice noodles 45 fritter 82 64 59
  • D64 82 59 pancake 37 rice noodles 45 fritter

Step-by-Step Solution

The numbers above 50 are 64, 82 and 59, taken in that left-to-right order. Step 1: pancake 37 rice 82 noodles 45 fritter 59 64. Step 2: pancake 37 rice noodles 45 fritter 59 64 82. Step 3 (last) moves 59, which although it already lay near the end must now go past 64 and 82: pancake 37 rice noodles 45 fritter 64 82 59. "pancake 37 rice noodles 45 fritter 59 64 82" is Step 2, stopping early because 59 is wrongly thought to need no move. "pancake 37 rice noodles 45 fritter 82 64 59" takes the numbers largest first instead of leftmost first. "64 82 59 pancake 37 rice noodles 45 fritter" sends them to the left end rather than the right.
Answer: A) pancake 37 rice noodles 45 fritter 64 82 59

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

An arrangement machine reorders an input line of words and numbers one step at a time.…An arrangement machine reorders an input line of words and numbers one step at a time.…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 works on an input line having an odd number of elements. In each…