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 not yet fixed is taken out of the line and put back immediately to the right of the largest number not yet fixed; both of those two numbers then count as fixed. Words are never moved, every other element keeps its relative position, and the machine stops when fewer than two unfixed numbers are left.
Input: 38 pancake 72 rice 19 noodles 55.
Which of the following is the last step of the above arrangement?

Competition practiceInput-Output
  • A38 pancake 72 19 rice noodles 55
  • Bpancake 19 72 rice noodles 38 55
  • Cpancake 72 19 rice noodles 38 55
  • Dpancake 72 19 rice noodles 55 38

Step-by-Step Solution

Step 1 pairs the smallest number, 19, with the largest, 72, and sets 19 immediately to the right of 72: 38 pancake 72 19 rice noodles 55. Those two are now fixed. Of the numbers left, 38 is the smallest and 55 the largest, so Step 2, the last, sets 38 immediately to the right of 55: pancake 72 19 rice noodles 55 38. "38 pancake 72 19 rice noodles 55" is Step 1, one step short. "pancake 19 72 rice noodles 38 55" places each small number to the LEFT of its large partner instead of to the right. "pancake 72 19 rice noodles 38 55" gets the first pair right but sets 38 to the left of 55 in the second.
Answer: D) pancake 72 19 rice noodles 55 38

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-rearranging machine, given an input line of words, produces one step per pass.…A word-and-number machine rearranges an input line in steps. Worked example — Input: gap…A word-and-number machine rearranges an input line in steps. Worked example — Input: gap…A word-and-number machine rearranges an input line in steps. Worked example — Input: gap…A word-and-number arrangement machine rearranges an input line one element per step.…