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 unshifted word containing the letter r is taken out and placed at the extreme right end of the line. Words without an r, and all the numbers, are never shifted; every other element keeps its relative position, and the machine stops when no such word is left.
Input: 47 scarf 28 shirt 63 jacket mandir.
Which of the following is Step 2 of the above arrangement?

Competition practiceInput-Output
  • A47 28 shirt 63 jacket mandir scarf
  • B47 28 63 jacket scarf shirt mandir
  • C47 28 63 jacket mandir scarf shirt
  • D47 scarf 28 63 jacket mandir shirt

Step-by-Step Solution

The words containing an r are scarf, shirt and mandir; jacket has none. They are taken leftmost first. Step 1 moves scarf: 47 28 shirt 63 jacket mandir scarf. Step 2 moves shirt: 47 28 63 jacket mandir scarf shirt, the answer. "47 28 shirt 63 jacket mandir scarf" is Step 1 and "47 28 63 jacket scarf shirt mandir" is Step 3, the last step. "47 scarf 28 63 jacket mandir shirt" starts from the rightmost such word, so mandir (which already stood at the end) is counted as the first move and scarf is left in place.
Answer: C) 47 28 63 jacket mandir scarf shirt

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,…An input-output arrangement machine rearranges a line of words and numbers one step at a…An input-output arrangement machine rearranges a line of words and numbers one step at a…An arrangement machine works on an input line of words and numbers in steps. In each…