Skip to content
Tutorials Center
My learning

Topics

Lesson 72 of 86 ยท Puzzles and Arrangements

Input-Output, Matrices and Pattern Puzzles

Learn to crack machine input-output questions, missing-number grids and triangle patterns by finding the rule, with a machine simulator and rule checker.

Some reasoning questions do not describe people at all. A machine takes a list of numbers or words and rearranges them step by step; a grid hides a number that follows a rule; a triangle or circle hides a number that follows a rule connecting its corners. In every case you are shown several examples of the rule at work and must discover it, then apply it once more.

These are pattern-finding skills, so the lesson is built around one habit: write down what changed, then test your guess on every example, not just the first. A rule that fits one row of a grid is a hunch; a rule that fits all of them is an answer. Small programs below let you step a machine and test rules against grids, so you can see this habit in action. If you want more practice with number patterns first, the lessons on speed maths and number puzzles in this course are a good warm-up (Speed Maths and Mental Calculation).

Machine input-output: what is being asked

A typical question gives an input (a line of numbers or words) and then shows the machine's output after step 1, step 2, and so on. You are asked for the output of a step that is not shown, for the number of steps needed to finish, or for the input that produced a given arrangement.

The questions are easier if you notice three things.

  1. Something is fixed after every step. The machine usually places one item permanently (smallest to the left end, largest to the right end, the longest word first, and so on). The rest are untouched, or shifted but in the same relative order.
  2. There are two rule families. Arrangement machines only reorder items. Operation machines change the items themselves (add, multiply, reverse digits, sum of digits).
  3. The number of steps is small. If a machine fixes one item per step, it needs at most n - 1 steps for n items, because the last item has nowhere else to go.
flowchart TB
    I["Input line"] --> S1["Step 1<br/>fix one item"] --> S2["Step 2<br/>fix another"] --> S3["Step 3<br/>..."] --> O["Final arrangement<br/>after at most n - 1 steps"]

An arrangement machine settles one item at a time, so the picture gets more ordered with every step.

An arrangement machine

Here is a machine rule written out in full:

  • Odd steps: the smallest of the items not yet fixed moves to the leftmost free place.
  • Even steps: the largest of the items not yet fixed moves to the rightmost free place.
  • All other items keep their relative order.

Worked example (numbers). Input: 34 12 57 8 41 26.

  • Step 1: the smallest is 8, which moves to the front: 8 34 12 57 41 26.
  • Step 2: the largest of the rest is 57, which moves to the back: 8 34 12 41 26 57.
  • Step 3: the smallest of 34 12 41 26 is 12, which goes next to 8: 8 12 34 41 26 57.
  • Step 4: the largest of 34 41 26 is 41, which goes just before 57: 8 12 34 26 41 57.
  • Step 5: the smallest of 34 26 is 26: 8 12 26 34 41 57.

The line is fully sorted after 5 steps, which is n - 1 for six items. Notice that step 3 did not swap 12 with the number in its place. It moved 12 to the left and the other numbers shifted right, keeping their order. That is the kind of detail that decides the answer.

The same machine on words uses alphabetical order. Input: mango kiwi apple plum fig banana. Step 1 fixes apple, step 2 fixes plum, step 3 fixes banana, and so on. The simulator below applies the machine to numbers or words and prints every step.

JS Machine simulator: smallest left, largest right

Press Run (or Ctrl + Enter) to see the console output here.

No output.

An operation machine

Other machines apply a different transformation in every step. The easiest way to handle these is a small table: write the line, apply the step, write the new line, and label the step so that you can check it later.

Worked example. Input: 15 22 9 40. Step 1: add 3 to every odd number and subtract 2 from every even number. Step 2: reverse the order. Step 3: replace each number by the sum of its digits.

  • After step 1: 18, 20, 12, 38. (15 is odd, so 15 + 3 = 18. 22 is even, so 22 - 2 = 20. 9 + 3 = 12. 40 - 2 = 38.)
  • After step 2: 38, 12, 20, 18.
  • After step 3: 11, 3, 2, 9. (3 + 8 = 11, 1 + 2 = 3, 2 + 0 = 2, 1 + 8 = 9.)

In an exam you may get the output and be asked for the input. Then you run the steps backward: undo the last step first. That works only when each step can be undone. Reversing the order can, but "sum of the digits" cannot (many numbers share a digit sum), so questions of that kind give you enough information otherwise.

Matrices: finding the rule in a grid

A figure matrix or missing number grid shows a 3 by 3 block of numbers with one blank. There is a rule that works along every row (or every column), and the same rule gives the blank.

Common families of rules, in the order to try them:

Rule What to check
Third = first x second multiply the first two numbers in a row
Third = first + second add them
Third = first squared + second square the first, then add
Row sums are equal each row adds to the same total
Column sums are equal each column adds to the same total
Middle = (first + third) / 2 the middle number is the average

Test the rule on every complete row before using it. Two rows that agree make it a rule; one row that disagrees kills it.

Example 1. Rows: (2, 5, 10), (3, 4, 12), (6, 7, ?). Try "third = first x second": 2 x 5 = 10 and 3 x 4 = 12, so the rule fits both complete rows. The blank is 6 x 7 = 42.

Example 2. Rows: (3, 2, 11), (4, 5, 21), (5, 6, ?). The product rule fails (3 x 2 = 6, not 11). Try first squared plus second: 9 + 2 = 11 and 16 + 5 = 21. The blank is 25 + 6 = 31.

Example 3. Rows: (4, 9, 7), (6, 5, 3), (10, 6, ?). The row rules fail: 4 and 9 can't give 7 by multiplying or adding. Check columns: the first column is 4 + 6 + 10 = 20 and the second column is 9 + 5 + 6 = 20. So every column sums to 20 and the blank is 20 - 7 - 3 = 10.

Triangles, circles and other patterns

Pattern puzzles place numbers at the corners of a triangle (or around a circle) with a result in the center, and the same rule is applied in each figure. Treat each figure as one "row" of four numbers.

Example 4. Three triangles have corner numbers and a center: (4, 3, 2) with center 10; (5, 2, 6) with center 4; (6, 3, ?) with center 8. Try the rules one by one: sum of corners gives 9 and 13, which is wrong; a x b + c gives 14 and 16, which is wrong; a x b - c gives 12 - 2 = 10 and 10 - 6 = 4, which fits both. For the third triangle, 6 x 3 - ? = 8 gives ? = 10.

flowchart LR
    A["Write each figure<br/>as a row of numbers"] --> B["List candidate rules<br/>(sum, product, square, difference)"]
    B --> C{"Rule fits<br/>every complete figure?"}
    C -->|"no"| B
    C -->|"yes"| D["Apply to the figure<br/>with the blank"]

Keep trying rules until one fits every complete figure; only then use it on the incomplete one.

The program tests a list of candidate rules against complete rows and columns and reports the blank, so you can see why the wrong rules are rejected.

JS Rule checker for grids and triangles

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Common traps

  • Swapping instead of moving. If the machine moves an item to the front, the others shift; they do not trade places. Check against the sample output.
  • Testing the rule on one row only. Many rules fit a single row by accident. Check every complete row or column.
  • Mixing up rows and columns. If row rules fail, try columns before giving up.
  • Ignoring the step count. For a one-item-per-step machine, n - 1 steps is the ceiling, so a question that asks for more is a trap.
  • Reading words by length instead of by alphabet (or the reverse). The step description says which.

Next: the last puzzle lesson in this chapter, where people have jobs, hobbies and teams.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. A machine moves the smallest free number to the left end on odd steps and the largest free number to the right end on even steps. For the input 34 12 57 8 41 26, what is the arrangement after step 2?

    Step 1 moves 8 to the front, giving 8 34 12 57 41 26. Step 2 moves 57 to the back, giving 8 34 12 41 26 57.
  2. 2. An operation machine does these steps in order: (1) add 3 to odd numbers and subtract 2 from even numbers, (2) reverse the order, (3) replace each number by the sum of its digits. What is the output for the input 7 10?

    Step 1: 7 becomes 10 and 10 becomes 8, giving 10 8. Step 2: reverse to 8 10. Step 3: digit sums give 8 and 1, so the output is 8 1.
  3. 3. Rows of a grid: (2, 5, 10), (3, 4, 12), (6, 7, ?). What is the missing number?

    In each complete row the third number is the first times the second (2 x 5 = 10 and 3 x 4 = 12). So the blank is 6 x 7 = 42.
  4. 4. Triangles have corners a, b, c and a center number: (4, 3, 2) gives 10 and (5, 2, 6) gives 4. A third triangle has corners 6, 3 and a missing number, with center 8. What is the missing corner?

    The rule is a x b - c (4 x 3 - 2 = 10 and 5 x 2 - 6 = 4). So 6 x 3 - c = 8, giving c = 10.
  5. 5. A machine fixes exactly one item per step and the line has 9 items. What is the largest number of steps it can need?

    After n - 1 = 8 steps, eight items are fixed, and the last one has only one place left.

Summary

  • A machine either rearranges items (arrangement) or changes them (operation); write a numbered line for every step.
  • Machines that fix one item per step need at most n - 1 steps; items that are moved shift the others, they do not swap.
  • For grids, try row rules (product, sum, square plus another) and column rules, and check every complete row or column.
  • For triangles and circles, treat each figure as a row of numbers and test candidate rules one by one.
  • A rule is only a rule when it fits every complete example; run operation machines backward when you need the input.

Next: Grouping, Selection and Mixed Puzzles.