Practice30Create account

An arrangement machine works on an input line of words and numbers in steps. In each step it lifts out the element standing at the extreme right end of the line and puts it back immediately to the left of whichever word then stands furthest to the left. Every other element keeps its relative position, and the step is then repeated on the new line.
Step 2 of a certain run of this machine reads: 39 47 scarf shirt 82.
Which of the following was the input line?

Competition practiceInput-Output
  • A39 shirt 47 scarf 82
  • B39 shirt 82 scarf 47
  • C47 shirt 82 scarf 39
  • D39 scarf 82 shirt 47

Step-by-Step Solution

Test each line forwards. From 39 shirt 82 scarf 47: Step 1 lifts 47 and sets it just left of shirt, the leftmost word, giving 39 47 shirt 82 scarf; Step 2 lifts scarf and sets it just left of shirt, giving 39 47 scarf shirt 82, which matches. From 39 shirt 47 scarf 82 the run gives 39 82 shirt 47 scarf and then 39 82 scarf shirt 47 — the numbers 47 and 82 stand the wrong way round. From 47 shirt 82 scarf 39 the run gives 47 39 shirt 82 scarf and then 47 39 scarf shirt 82, wrong at the left end. From 39 scarf 82 shirt 47 the run gives 39 47 scarf 82 shirt and then 39 47 shirt scarf 82, with the two words interchanged.
Answer: B) 39 shirt 82 scarf 47

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