Input-Output (Machine Input): Rearrangement Rules Solved

In input-output questions a machine takes a line of words or numbers and rearranges it one step at a time according to a fixed rule. You either apply a stated rule or work out the rule from an illustration, then answer questions about a particular step. The topic is a regular in bank exams and rewards neat, step-by-step writing over speed reading.

Asked in: IBPS PO, SBI PO, IBPS Clerk, RRB PO, SBI Clerk, NTS, GAT

How a machine question is built

Each step changes the line a little: usually one or two elements move, and the rest keep their relative order. The final step is the fully arranged line.

Questions then ask for a particular step, the step number of a given line, the position of an element in some step, or the total number of steps.

Shifting rules

The most common rule picks the next element in some order (smallest number, word first in the dictionary, shortest word) and moves it to the end of the block already arranged. Everything else slides along without changing order.

Because only one element moves per step, each step can be written from the previous one by deleting one element and inserting it at the right place.

Swapping rules

In a swap rule, the next element in order trades places with whatever is standing where it needs to go. Only two positions change in each step, so the elements in between do not shift.

Read the rule carefully: a shift and a swap give different lines after step 1 even with the same order of choice.

Two-end rules and mixed lines

Many bank-exam machines work from both ends: odd steps build a block on the left and even steps build a block on the right. Mixed lines often place words on one side and numbers on the other.

Keep two pointers in your head: the next free place on the left and the next free place on the right. Each new element goes just inside the block already built on its side.

Finding the rule from an illustration

Compare the input with step 1 and ask which element moved and where it went. Then check step 2 to see whether the same type of element moved again or the machine alternates.

Test your guess on every step of the illustration before applying it. The number of steps is usually one less than the number of elements, but it can be fewer if the last elements are already in order.

Solved examples

  1. Rule: in each step the smallest number not yet arranged moves to just right of those already arranged (step 1 uses the left end), and the machine stops when the line is in order. Input: 82 39 57 14 26. Write all the steps.
    1. Order of picking: 14, 26, 39, 57, 82.
    2. Step 1: 14 moves to the left end: 14 82 39 57 26.
    3. Step 2: 26 moves after 14: 14 26 82 39 57.
    4. Step 3: 39 moves after 26: 14 26 39 82 57.
    5. Step 4: 57 moves after 39: 14 26 39 57 82. The last number is now automatically in place, so the machine stops.
    Answer: 4 steps; final line 14 26 39 57 82
  2. Rule: words are arranged in dictionary order from the left, one per step. Input: moon apple zebra kite dove. What is step 2?
    1. Dictionary order: apple, dove, kite, moon, zebra.
    2. Step 1: apple moves to the left end: apple moon zebra kite dove.
    3. Step 2: dove moves after apple: apple dove moon zebra kite.
    Answer: apple dove moon zebra kite
  3. Rule: in each step the largest number not yet arranged moves to just left of those already arranged (step 1 uses the right end). Input: 85 64 21 40 72 13. What is step 3?
    1. Step 1: 85 to the right end: 64 21 40 72 13 85.
    2. Step 2: 72 before 85: 64 21 40 13 72 85.
    3. Step 3: 64 before 72: 21 40 13 64 72 85.
    Answer: 21 40 13 64 72 85
  4. Rule: odd steps move the next word in dictionary order to the left block; even steps move the smallest number not yet arranged to the right block (step 2 uses the right end). Input: 37 52 18 fig lime pear. Write all the steps.
    1. Step 1: fig 37 52 18 lime pear.
    2. Step 2: fig 37 52 lime pear 18.
    3. Step 3: fig lime 37 52 pear 18.
    4. Step 4: fig lime 52 pear 37 18.
    5. Step 5: fig lime pear 52 37 18.
    6. The words end up on the left in dictionary order and the numbers on the right, smallest at the far right.
    Answer: fig lime pear 52 37 18
  5. A machine gives these steps. Input: 33 71 18 46 95 60. Step 1: 95 33 71 18 46 60. Step 2: 95 33 71 46 60 18. Step 3: 95 71 33 46 60 18. Step 4: 95 71 46 60 33 18. Step 5: 95 71 60 46 33 18. What is the rule?
    1. From input to step 1, only 95, the largest number, moved, and it went to the left end.
    2. In step 2, 18, the smallest number, moved to the right end.
    3. Step 3 moved 71 (the next largest) after 95, and step 4 moved 33 (the next smallest) before 18. Step 5 placed 60 after 71 and completed the line.
    4. So odd steps take the largest remaining number to the left block and even steps take the smallest remaining number to the right block.
    Answer: Largest to the left in odd steps, smallest to the right in even steps
  6. A machine replaces every number by the sum of the squares of its digits in each step. Input: 29 48 63. What is step 2?
    1. Step 1: 2² + 9² = 85, 4² + 8² = 80, 6² + 3² = 45.
    2. Step 2: 8² + 5² = 89, 8² + 0² = 64, 4² + 5² = 41.
    Answer: 89 64 41

Exam shortcuts

Common mistakes

Practice MCQs

  1. A machine rearranges a line of numbers. In step 1 the smallest number moves to the left end; in each later step the smallest of the numbers not yet arranged moves to just right of those already arranged, and the others keep their order. The machine stops as soon as the line is in order. Input: 48 27 63 15 92 36. What is step 2?
    A) 15 48 27 63 92 36
    B) 15 27 48 63 92 36
    C) 15 27 36 48 63 92
    D) 27 15 48 63 92 36
    Answer: B) 15 27 48 63 92 36 — Step 1 moves 15 to the left end: 15 48 27 63 92 36. Step 2 moves the next smallest, 27, to just right of 15: 15 27 48 63 92 36. '15 48 27 63 92 36' is only step 1, '15 27 36 48 63 92' is step 3, and '27 15 48 63 92 36' puts the numbers in the wrong order at the left.
  2. A machine rearranges a line of words. In step 1 the word that comes first in dictionary order moves to the left end; in each later step the next word in dictionary order moves to just right of those already arranged, and the others keep their order. The machine stops as soon as the line is in order. Input: mango apple grape cherry banana. How many steps are needed to complete the arrangement?
    A) 4
    B) 5
    C) 3
    D) 6
    Answer: A) 4 — Step 1: apple mango grape cherry banana. Step 2: apple banana mango grape cherry. Step 3: apple banana cherry mango grape. Step 4: apple banana cherry grape mango, which is in order. With five words the last word falls into place automatically, so 5 and 6 overcount, and after 3 steps grape and mango are still reversed.
  3. A machine arranges words by length. In each step the shortest word not yet arranged moves to just right of the words already arranged (step 1 uses the left end); words of equal length are taken in dictionary order, and the others keep their order. Input: river sun to forest go be cloud. In step 3, which word is fourth from the left end?
    A) sun
    B) to
    C) forest
    D) river
    Answer: D) river — Step 1 moves 'be', step 2 moves 'go' and step 3 moves 'to' (all two letters, in dictionary order): be go to river sun forest cloud. The fourth word from the left is 'river'. 'to' is third, 'sun' is fifth and 'forest' is sixth in that step.
  4. A machine rearranges a line of numbers. In step 1 the smallest number moves to the left end; in each later step the smallest of the numbers not yet arranged moves to just right of those already arranged, and the others keep their order. The machine stops as soon as the line is in order. Input: 71 38 94 15 62 27 50. Which step reads '15 27 38 71 94 62 50'?
    A) Step 2
    B) Step 4
    C) Step 3
    D) Step 5
    Answer: C) Step 3 — Step 1 places 15, step 2 places 27 and step 3 places 38, giving 15 27 38 71 94 62 50. Step 2 still has 71 before 38, step 4 has already placed 50 at the fourth position, and step 5 is the final ordered line.
  5. A machine rearranges numbers. In step 1 the largest number moves to the right end; in each later step the largest of the numbers not yet arranged moves to just left of those already arranged, and the others keep their order. The machine stops when the line is in increasing order. Input: 44 91 17 58 73 30. What is step 3?
    A) 44 17 30 58 73 91
    B) 44 17 58 30 73 91
    C) 17 30 44 58 73 91
    D) 17 44 30 58 73 91
    Answer: A) 44 17 30 58 73 91 — Step 1 moves 91 to the right end: 44 17 58 73 30 91. Step 2 places 73 before 91: 44 17 58 30 73 91. Step 3 places 58 before 73: 44 17 30 58 73 91. '44 17 58 30 73 91' is step 2, '17 30 44 58 73 91' is the final step 4, and '17 44 30 58 73 91' moves the wrong numbers.
  6. A machine works by swapping. In step 1 the smallest number swaps places with the number at the left end. In step 2 the second smallest swaps places with the number in the second position, and so on, until the line is in increasing order. Input: 26 81 12 35 49 67. What is step 3?
    A) 12 26 81 35 49 67
    B) 12 26 35 81 49 67
    C) 12 26 35 49 81 67
    D) 12 35 26 81 49 67
    Answer: B) 12 26 35 81 49 67 — Step 1 swaps 12 and 26: 12 81 26 35 49 67. Step 2 swaps 26 with 81 in the second place: 12 26 81 35 49 67. Step 3 swaps 35 with 81 in the third place: 12 26 35 81 49 67. '12 26 81 35 49 67' is step 2, '12 26 35 49 81 67' is step 4, and '12 35 26 81 49 67' does not follow the swap rule.
  7. A machine arranges words in reverse dictionary order. In step 1 the word that comes last in dictionary order moves to the left end; in each later step the next word (going backwards through the dictionary) moves to just right of the words already arranged, and the others keep their order. Input: book slate ink chalk ruler pen. In step 4, which word is second to the right of 'pen'?
    A) book
    B) ink
    C) chalk
    D) ruler
    Answer: A) book — Steps 1 to 4 place slate, ruler, pen and ink in turn, giving step 4: slate ruler pen ink book chalk. To the right of 'pen' come 'ink' (first) and then 'book' (second). 'chalk' is third to the right, and 'ruler' is on the left of 'pen'.
  8. A machine arranges words. In step 1 the word that comes first in dictionary order moves to the right end; in each later step the next word in dictionary order moves to just left of the words already arranged, and the others keep their order. Input: lamp house desk chair bed table. What is the last step?
    A) lamp table house desk chair bed
    B) bed chair desk house lamp table
    C) table lamp house chair desk bed
    D) table lamp house desk chair bed
    Answer: D) table lamp house desk chair bed — The words are placed from the right in the order bed, chair, desk, house, lamp, leaving table at the left: table lamp house desk chair bed. 'lamp table house desk chair bed' is step 4, 'bed chair desk house lamp table' is ordinary dictionary order from the left, and 'table lamp house chair desk bed' swaps desk and chair.
  9. A machine arranges numbers in decreasing order. In step 1 the largest number moves to the left end; in each later step the largest of the numbers not yet arranged moves to just right of those already arranged, and the others keep their order. Input: 12 55 64 76 29 83 47. In step 4, which number is third from the right end?
    A) 29
    B) 55
    C) 12
    D) 47
    Answer: C) 12 — Steps 1 to 4 place 83, 76, 64 and 55, giving 83 76 64 55 12 29 47. Counting from the right: 47 is first, 29 second and 12 third. 55 is fourth from the right, and 29 and 47 are closer to the end.
  10. A machine changes numbers. In each step, every number is replaced by the product of its digits. Input: 86 47 93 58 75. What is the sum of the numbers in step 2?
    A) 75
    B) 77
    C) 81
    D) 79
    Answer: B) 77 — Step 1: 8×6 = 48, 4×7 = 28, 9×3 = 27, 5×8 = 40, 7×5 = 35. Step 2: 4×8 = 32, 2×8 = 16, 2×7 = 14, 4×0 = 0, 3×5 = 15. Sum = 32 + 16 + 14 + 0 + 15 = 77. 81 comes from treating 4×0 as 4, 75 from writing 2×7 as 12, and 79 from writing 3×5 as 17.
  11. A machine arranges a line of words and numbers. In odd steps (1, 3, 5, ...) the next word in dictionary order moves to the left, just right of words already arranged (step 1 uses the left end). In even steps the smallest number not yet arranged moves to the right, just left of numbers already arranged (step 2 uses the right end). Others keep their order. Input: 29 63 17 42 fish lamp boat tree. What is step 4?
    A) boat fish 63 42 lamp tree 29 17
    B) boat fish 29 63 42 lamp tree 17
    C) boat fish lamp 63 42 tree 29 17
    D) boat fish 63 42 lamp tree 17 29
    Answer: A) boat fish 63 42 lamp tree 29 17 — Step 1: boat to the left end. Step 2: 17 to the right end: boat 29 63 42 fish lamp tree 17. Step 3: fish after boat: boat fish 29 63 42 lamp tree 17. Step 4: 29 just left of 17: boat fish 63 42 lamp tree 29 17. 'boat fish 29 63 42 lamp tree 17' is step 3, 'boat fish lamp 63 42 tree 29 17' is step 5, and ending with '17 29' places the numbers on the wrong side of each other.
  12. A machine arranges numbers. In odd steps the smallest even number not yet arranged moves to the left, just right of even numbers already arranged (step 1 uses the left end). In even steps the largest odd number not yet arranged moves to the right, just left of odd numbers already arranged (step 2 uses the right end). Others keep their order. Input: 15 81 49 67 54 38 26 72. In step 5, which number is fourth from the right end?
    A) 72
    B) 15
    C) 67
    D) 49
    Answer: D) 49 — Step 1 places 26, step 2 places 81 at the right end, step 3 places 38, step 4 places 67 before 81, and step 5 places 54: 26 38 54 15 49 72 67 81. From the right: 81, 67, 72, then 49 fourth. 72 is third, 67 is second, and 15 is fifth from the right.
  13. A machine rearranges a line of numbers. In step 1 the smallest number moves to the left end; in each later step the smallest of the numbers not yet arranged moves to just right of those already arranged, and the others keep their order. The machine stops as soon as the line is in order. Input: 57 73 46 31 88 24. How many steps does the machine take?
    A) 5
    B) 3
    C) 6
    D) 4
    Answer: B) 3 — Step 1: 24 57 73 46 31 88. Step 2: 24 31 57 73 46 88. Step 3: 24 31 46 57 73 88. After step 3 the whole line is already in increasing order, because 57, 73 and 88 were left in the right order, so the machine stops. 5 assumes one step for every number but the last, 6 counts every number, and 4 adds a step that changes nothing.
  14. Study how a machine treats this input. Input: 17 41 28 52 63 95. Step 1: 95 17 41 28 52 63. Step 2: 95 41 28 52 63 17. Step 3: 95 63 41 28 52 17. Step 4: 95 63 41 52 28 17. Step 5: 95 63 52 41 28 17. Using the same rule, what is step 4 for the input 45 34 58 11 89 23 62 76?
    A) 89 76 45 34 58 23 62 11
    B) 89 76 62 45 34 58 23 11
    C) 89 45 34 58 23 62 76 11
    D) 89 76 45 34 58 62 23 11
    Answer: D) 89 76 45 34 58 62 23 11 — In the illustration, odd steps move the largest remaining number to the left (95, then 63, then 52) and even steps move the smallest remaining number to the right (17, then 28). For the new input: step 1 89 to the left end, step 2 11 to the right end, step 3 76 after 89, step 4 23 before 11: 89 76 45 34 58 62 23 11. '89 76 45 34 58 23 62 11' is step 3, '89 76 62 45 34 58 23 11' is step 5, and '89 45 34 58 23 62 76 11' is step 2.
  15. Study how a machine treats this input. Input: pencil ink library at important desk notebook chair. Step 1: at pencil ink library important desk notebook chair. Step 2: at pencil ink library desk notebook chair important. Step 3: at ink pencil library desk notebook chair important. Step 4: at ink pencil library desk chair notebook important. Step 5: at ink desk pencil library chair notebook important. Step 6: at ink desk pencil chair library notebook important. Step 7: at ink desk chair pencil library notebook important. Using the same rule, what is step 5 for the input garden umbrella waterfall go monsoon the rain cloud?
    A) go the rain garden cloud monsoon umbrella waterfall
    B) go the garden monsoon rain cloud umbrella waterfall
    C) go the rain garden monsoon cloud umbrella waterfall
    D) go the rain cloud garden monsoon umbrella waterfall
    Answer: C) go the rain garden monsoon cloud umbrella waterfall — In the illustration, odd steps move the shortest remaining word to the left (at, ink, desk) and even steps move the longest remaining word to the right (important, then notebook, then library). New input: step 1 go, step 2 waterfall, step 3 the, step 4 umbrella, step 5 rain: go the rain garden monsoon cloud umbrella waterfall. '...garden cloud monsoon...' is step 6, '...garden monsoon rain cloud...' is step 4, and '...cloud garden monsoon...' is the final step 7.

Questions

How do I find the rule when only an illustration is given?

Compare the input with step 1 and note exactly which element moved and to where. Check that step 2 and step 3 follow the same pattern, and test your rule on every step of the illustration before using it.

Why can the machine finish in fewer steps than expected?

The machine stops when the whole line is arranged. If the elements left over happen to be in the correct order already, no more steps are needed.

Do I need to write out every step in the exam?

Usually yes, but only once per input. Write the steps in a column; the same column answers all the questions asked about that input.