Practice30Create account

A word-and-number arrangement machine works on an input line of words and two-digit numbers in steps. In each step it finds the leftmost number whose tens digit is greater than its units digit and writes that number backwards in the place where it stands. Nothing changes position — only the digits of that one number are turned round — and the machine stops as soon as every number in the line has its tens digit smaller than its units digit.
Input: 63 anvil 29 birch 85 cedar 47 dune 91.
How many steps are needed to complete the rearrangement of the above input?

Competition practiceInput-Output
  • A3
  • B5
  • C2
  • D4

Step-by-Step Solution

Three of the five numbers have a tens digit larger than their units digit: 63, 85 and 91. The other two, 29 and 47, already run upward and are never touched. Step 1: 36 anvil 29 birch 85 cedar 47 dune 91. Step 2: 36 anvil 29 birch 58 cedar 47 dune 91. Step 3: 36 anvil 29 birch 58 cedar 47 dune 19, and the machine halts. Three steps. Turning every number round gives five; overlooking 91 at the far end gives two; and treating 47 as an offender — it is not, since 4 is less than 7 — gives four.
Answer: A) 3

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 works on an input line of words and two-digit…A word-and-number arrangement machine works on an input line of words and two-digit…A word-and-number arrangement machine works on an input line of words and two-digit…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,…