Learn this topic first

Skip to the questions ↓

Read this, then start. Tap a topic to open or close it.

Counting Figures
Exam weightage: LowAbout 0-1 questions per placement paper. Seen most in AMCAT, Capgemini non-verbal. All topics

How many triangles are in a triangle with three lines drawn from the top? Most people say 4. The answer is 10, and by the end of today you will be able to prove it.

Label, then count by size

Start with a picture. A triangle has lines drawn from its top corner A down to the base. The lines cut the base into small pieces.

Beginner method: label the points on the base P0, P1, P2 ... Count triangles made of 1 piece, then 2 pieces, then 3, and so on. With 4 pieces: 4 + 3 + 2 + 1 = 10.

Base cut into k pieces (lines from one corner)
Triangles = k + (k - 1) + ... + 1 = k(k + 1)/2
Same thing using points
k pieces means k + 1 base points. Triangles = (k + 1)C2
nC2
Ways to choose 2 things from n = n(n - 1)/2
PQRSTA
Count by size: 4 single pieces, 3 made of two, 2 of three, 1 of four = 10
P0P1P2P3P4A
Pick 2 of the 5 base points (P1, P3) and join them to A: one triangle
Why the formula works (proof)
  1. Look at any triangle in the figure. Its sides can only lie on lines from A or on the base.Those are the only lines drawn.
  2. So one corner is A, and the other two corners are on the base.Two sides go down from A and meet the base.
  3. Choose any two base points, say P1 and P3. Join both to A: that is exactly one triangle.See the shaded triangle in the second picture.
  4. So triangles and pairs of base points match one to one.Every triangle gives a pair, every pair gives a triangle.
  5. k pieces give k + 1 base points, and the number of pairs is (k + 1)k/2.nC2 = n(n - 1)/2 with n = k + 1.
  6. Hence proved: triangles = k(k + 1)/2.

Squares in a grid

A chessboard has 64 small squares, but also 2 × 2 squares, 3 × 3 squares and so on up to the whole board. The question counts all of them.

Beginner method: count one size at a time. A k × k square is fixed by where its top-left corner sits. In the picture, the dots show every place a 2 × 2 square can start in a 4 × 4 grid: 3 × 3 = 9 places.

k × k squares in an n × n grid
(n - k + 1)2
All squares in an n × n grid
12 + 22 + ... + n2 = n(n + 1)(2n + 1)/6
All squares in an m × n grid (m ≤ n)
Add (m - k + 1)(n - k + 1) for k = 1 to m
A 2 × 2 square can start at 3 × 3 = 9 corners (dots)
A 3 × 3 square can start at 2 × 2 = 4 corners (dots)
Why the formula works (proof)
  1. A k × k square covers k columns and k rows, so its top-left corner can be in column 1 up to column n - k + 1.Any further right and it falls off the grid.
  2. In the same way the corner can be in row 1 up to row n - k + 1.
  3. Each (row, column) choice gives a different square: (n - k + 1) × (n - k + 1) squares of size k.Count the dots in the picture: 9 for size 2, 4 for size 3.
  4. Sizes go from k = 1 (value n2) to k = n (value 1).So the total is 12 + 22 + ... + n2.
  5. The sum of squares formula: (k + 1)3 - k3 = 3k2 + 3k + 1. Add this for k = 1 to n: the left side collapses to (n + 1)3 - 1.Every middle cube cancels.
  6. So 3(sum of k2) + 3n(n + 1)/2 + n = (n + 1)3 - 1, which simplifies to sum of k2 = n(n + 1)(2n + 1)/6.
  7. Hence proved.

Rectangles and squares in grids

Every rectangle has a top edge, a bottom edge, a left edge and a right edge. In a grid, the top and bottom lie on two of the horizontal lines, and the left and right lie on two of the vertical lines.

So instead of looking for rectangles, choose lines. A 3 × 4 grid has 4 horizontal lines and 5 vertical lines (always one more line than rows or columns).

Rectangles (squares included) in an m × n grid
(m + 1)C2 × (n + 1)C2
Written out
m(m + 1)/2 × n(n + 1)/2
Rectangles that are NOT squares
All rectangles - all squares
4 horizontal lines, 5 vertical lines. Any 2 + any 2 = one rectangle
A different choice of lines gives a different rectangle
Why the formula works (proof)
  1. Pick any 2 horizontal lines and any 2 vertical lines.The thick lines in the picture.
  2. They cross in exactly 4 points, and those points are the corners of one rectangle.The shaded one.
  3. Going the other way, every rectangle gives back its 2 horizontal and 2 vertical edge lines.So nothing is counted twice and nothing is missed.
  4. Ways to pick 2 of the (m + 1) horizontal lines = (m + 1)C2, and 2 of the (n + 1) vertical lines = (n + 1)C2.
  5. Each pair of horizontal lines can go with each pair of vertical lines, so multiply.Multiplication rule.
  6. Hence proved: rectangles = (m + 1)C2 × (n + 1)C2.

Triangles in a triangle grid

Now the triangle is cut into rows of small triangles, like a pyramid of tiles. Some triangles point up, and some point down (upside-down). Beginners forget the upside-down ones.

Count them in two groups: upright triangles size by size, then upside-down triangles size by size. With 3 rows: upright 6 + 3 + 1 = 10, upside-down 3, total 13.

Upright triangles of size k (n rows)
1 + 2 + ... + (n - k + 1)
Upside-down triangles of size k
1 + 2 + ... + (n - 2k + 1), only when 2k ≤ n
Totals for n = 1, 2, 3, 4, 5
1, 5, 13, 27, 48
3 rows: one upright triangle of size 2 (yellow) and one upside-down of size 1 (green)
4 rows: an upside-down triangle of size 2 needs 2 rows above and 2 below
Why the formula works (proof)
  1. An upright triangle of size k is fixed by its top corner.Once the top is chosen, the rest hangs below it.
  2. Its top corner can be any point in the top n - k + 1 rows of points, and row r has r points.The triangle must still fit above the base.
  3. So upright triangles of size k = 1 + 2 + ... + (n - k + 1).
  4. An upside-down triangle of size k needs k rows above its top edge and k rows from the top edge to its bottom corner.The top edge sits on row k or lower, the bottom corner on row n or higher.
  5. That leaves n - 2k + 1 usable rows, holding 1 + 2 + ... + (n - 2k + 1) positions.Zero when 2k > n.
  6. Add both groups for every size. Hence proved.

Mixed figures: triangles inside rectangles

When the figure is not a standard grid, there is no single formula. Use the labelling method: put a letter on every corner and crossing point, then list triangles by how many small pieces they use.

Rectangle with both diagonals: 4 small triangles meet at the centre, and each diagonal cuts the rectangle into 2 big triangles, so 4 more. Total 8.

Rectangle with both diagonals
8 triangles
Square with both diagonals and both midlines
16 triangles
Any figure
Label points, count by number of pieces, never skip a size
Rectangle + 2 diagonals: 4 small (yellow shows one) + 4 made of two pieces (green shows one) = 8
Square + diagonals + midlines: 8 small + 4 of two pieces + 4 half-squares (green) = 16
Why the formula works (proof)
  1. Rectangle: the diagonals cross at the centre O, making 4 small triangles.Size 1 = 4.
  2. Two neighbouring small triangles share a half-diagonal, and together they form a triangle whose third side is a full diagonal: 4 such pairs.Size 2 = 4.
  3. Three small pieces never make a triangle (they make a shape with 4 corners), and all four make the rectangle.Sizes 3 and 4 = 0.
  4. 4 + 4 = 8.
  5. For the square with midlines: 8 small, 4 made of two pieces, 4 half-squares = 16.Same steps, one more line in each direction.
  6. Hence proved.

Points, lines and diagonals

Some questions give points instead of a drawing: 'there are 8 points and no three are on one line; how many triangles?'

A straight line needs 2 points and a triangle needs 3 points. If no three points are on one line, every choice of 3 points makes a real triangle.

Straight lines through n points (no three on a line)
nC2 = n(n - 1)/2
Triangles from n points (no three on a line)
nC3 = n(n - 1)(n - 2)/6
Diagonals of an n-sided polygon
n(n - 3)/2
123456
6 points: any 3 of them make a triangle. 6C3 = 20
12345
5 points: 5C2 = 10 lines. 5 are sides of the pentagon, 5 are diagonals
Why the formula works (proof)
  1. A line is fixed by any 2 of the points, and different pairs give different lines because no three points share a line.So lines = nC2.
  2. A triangle is fixed by its 3 corners, and 3 points not on a line always make one.So triangles = nC3.
  3. Diagonals: each corner of the polygon joins to n - 1 other corners. 2 of those joins are sides, so n - 3 are diagonals.
  4. n corners × (n - 3) counts every diagonal twice, once from each end.Divide by 2.
  5. Hence proved: diagonals = n(n - 3)/2.

Formula sheet: every shape

One table for revision. Every row was proved in a section above, and each number in the Example column comes from a brute-force count by the computer, not from the formula.

Read the shape, find what you are counting, apply the formula, and compare with the worked number.

Lines
boxes + 1 in each direction
nC2
n(n - 1)/2
nC3
n(n - 1)(n - 2)/6
PQRSTA
Lines from one corner
Lines from one corner + 1 line across
Grid of unit squares
Triangle cut into rows
Rectangle + diagonals
Square + diagonals + midlines
123456
Points with no three on a line
ShapeCountingFormulaExample
Triangle, lines from one corner, base in k piecesTrianglesk(k + 1)/2k = 4: 10
Same, plus c lines across parallel to the baseTriangles(c + 1) × k(k + 1)/2k = 4, c = 1: 20
n × n gridSquaresn(n + 1)(2n + 1)/68 × 8: 204
m × n gridSquaresadd (m - k + 1)(n - k + 1)3 × 4: 20
m × n gridRectangles (squares included)(m + 1)C2 × (n + 1)C23 × 4: 60
m × n gridRectangles that are not squaresrectangles - squares4 × 4: 70
Triangle cut into n rowsTriangles (up + upside-down)1, 5, 13, 27, 48 for n = 1 to 54 rows: 27
Rectangle + both diagonalsTriangles88
Square + diagonals + both midlinesTriangles1616
n points, no three on a lineStraight linesnC28 points: 28
n points, no three on a lineTrianglesnC38 points: 56
Polygon with n sidesDiagonalsn(n - 3)/2hexagon: 9
n × n × n cubeCubes of all sizes13 + 23 + ... + n3 = (n(n + 1)/2)23 × 3 × 3: 36
Why the formula works (proof)
  1. Rows 1 and 3 to 12 are proved in the sections above.Each section ends with its own proof.
  2. Lines across: each of the c + 1 horizontal lines (base included) works like its own base with the same k pieces, so the apex count repeats c + 1 times.
  3. Cube row: a k × k × k cube is fixed by its front-top-left corner, which has (n - k + 1) places along each of the 3 directions.The same corner idea as squares, in 3D.
  4. So there are (n - k + 1)3 cubes of size k, and adding k = 1 to n gives 13 + ... + n3.
  5. Hence proved.
Worked exampleA triangle has 3 lines drawn from the top corner to the base (4 small triangles). How many triangles in total?
  1. The base is cut into k = 4 pieces.3 inside lines make 4 pieces.
  2. By size: 4 + 3 + 2 + 1.Pieces of 1, 2, 3 and 4.
  3. 10.
Cryptarithmetic
Exam weightage: MediumAbout 1-2 questions per placement paper. Seen most in Infosys, Capgemini (game-based round). All topics

SEND + MORE = MONEY: every letter is a different digit. You do not guess. You use four rules, each one proved today, and the puzzle falls apart column by column.

Place value: turn letters into numbers

In a cryptarithm, letters stand for digits. AB does not mean A times B. It means the two-digit number with A in the tens place and B in the ones place.

So AB = 10A + B, and ABC = 100A + 10B + C. Writing this out turns a puzzle into ordinary algebra.

AB
10A + B
ABC
100A + 10B + C
AB + BA
11(A + B)
Ax 10Bx 1
AB = 10A + B
Ax 100Bx 10Cx 1
ABC = 100A + 10B + C
Why the formula works (proof)
  1. AB + BA = (10A + B) + (10B + A).Write each number in place value.
  2. = 11A + 11B = 11(A + B).Collect the A terms and the B terms.
  3. AB - BA = (10A + B) - (10B + A) = 9A - 9B = 9(A - B).
  4. ABC - CBA = (100A + 10B + C) - (100C + 10B + A) = 99A - 99C = 99(A - C).The middle digit cancels.
  5. Hence proved.

Addition-based puzzles and carries

Add from the right, one column at a time, exactly like school addition. When a column adds up to 10 or more, write the ones digit and carry 1 to the next column. The small red numbers in the picture are the carries.

Two facts do most of the work: a carry is only ever 0 or 1, and if the answer is one digit longer than the numbers being added, its first digit is 1.

Column rule
top + bottom + carry in = answer digit + 10 × carry out
Carry when adding two numbers
Always 0 or 1
Answer one digit longer
Its first letter = 1
1TOGO+OUT
21 + 81 = 102: the carry into a new column is 1, so O = 1
119999+198
Even the biggest case, 99 + 99, carries only 1
Why the formula works (proof)
  1. The biggest a column can be is 9 + 9 + 1 = 19.Two digits at most 9 each, plus a carry of at most 1.
  2. 19 is less than 20, so the carry out is at most 1.Carry out = how many tens the column total has.
  3. If a new front digit appears, it can only come from the last carry, so it is 0 or 1.
  4. A number does not start with 0, so the new front digit is 1.
  5. Hence proved: the carry is 0 or 1, and the extra leading digit is 1.

Zero and nine: the same-letter rule

Sometimes a column shows a letter that comes out unchanged: X + Y = X. What must Y be?

If no carry came in, Y adds nothing, so Y = 0. If a carry of 1 came in and the column still ends in X, Y must be 9 and the column carries 1 out.

X + Y = X, no carry in
Y = 0, no carry out
X + Y + 1 = X (ends in X), carry in 1
Y = 9, carry out 1
X + X ends in Y
Y is even
4720+67
7 + 0 = 7: the answer digit did not change, so the added digit is 0
113697+133
Tens: 3 + 9 + 1 = 13, ends in 3 again: the added digit is 9
Why the formula works (proof)
  1. Column rule: X + Y + c = X + 10d, where c is the carry in and d the carry out.Previous section.
  2. Take X away from both sides: Y + c = 10d.
  3. Y + c is between 0 and 10. If d = 0 then Y + c = 0, so Y = 0 and c = 0.
  4. If d = 1 then Y + c = 10. Y is at most 9, so c = 1 and Y = 9.
  5. X + X = 2X, and 2X or 2X - 10 is even, so the digit written is even.
  6. Hence proved.

Multiplication endings

For multiplication puzzles, look at the last digit first. The last digit of a product depends only on the last digits you multiply.

There are only 10 digits, so we can list every case. The table is the proof: nothing is left out.

d × d ends in d
d = 0, 1, 5 or 6 only
A square number ends in
0, 1, 4, 5, 6 or 9, never 2, 3, 7, 8
Anything × 5
Ends in 0 or 5
25+625
25 × 25 = 625: a number ending in 5, squared, ends in 5
Digit dd × dEnds in
000
111
244
399
4166
5255
6366
7499
8644
9811
Why the formula works (proof)
  1. The last digit of a product comes only from the last digits multiplied.The tens and above only add whole tens.
  2. So check d × d for d = 0 to 9 (the table).Only 10 cases, all listed.
  3. The endings column shows d only for 0, 1, 5, 6, and never shows 2, 3, 7 or 8.Read down the table.
  4. Hence proved.

Subtraction-based puzzles and letter-digit substitution

Subtraction puzzles are easier if you flip them into additions: A - B = C is the same as C + B = A. Then every addition rule works.

Alphanumeric puzzles mix digits and letters: 5A + B3 = 91 means (50 + A) + (10B + 3) = 91.

A - B = C
C + B = A
Borrow
If the top digit is smaller, add 10 to it and take 1 from the next column
5A
50 + A
9P4Q-5P
9P - 4Q = 5P: flip it to 5P + 4Q = 9P
Why the formula works (proof)
  1. Subtraction asks: what do I add to B to get A?That is what minus means.
  2. So if A - B = C, then C + B = A, and the other way round.
  3. A borrow in subtraction is just the carry in the flipped addition.Borrowing 10 = carrying 1.
  4. Hence proved: every subtraction puzzle is an addition puzzle.

Putting it together: SEND + MORE = MONEY

Now use every rule on the famous puzzle. Each move below is forced by a rule proved above, so there is no guessing until the very end, and even then only a few digits are left to try.

Red numbers are the carries. Check the finished sum at the end: 9567 + 1085 = 10652.

Move 1
Extra leading letter = 1 (M = 1)
Move 2
Use the carry rule on the leftmost column (S = 9, O = 0)
Move 3
Same-letter and column rules on the middle columns
111SENDMORE+MONEY
The letters, with the carries that the rules force
11195671085+10652
The solution: every column checks
Why the formula works (proof)
  1. M = 1: the answer has one more digit than SEND and MORE.Carry rule.
  2. Thousands: S + 1 + carry = 10 + O. O cannot be 1 (M is 1), so O = 0 and S = 9 (or 8 with a carry; that fails later).Carry rule.
  3. Hundreds: E + 0 + carry = N. N is not E, so the carry is 1 and N = E + 1.Same-letter rule.
  4. Tens: N + R + carry = E + 10. Put N = E + 1: R + carry = 9, so R = 8 (9 is taken by S).Same-letter rule, nine case.
  5. Units: D + E = Y + 10. Trying the free digits gives E = 5, N = 6, D = 7, Y = 2.Only a few digits are left.
  6. 9567 + 1085 = 10652. Every column checks. Hence proved.

Rule sheet: every rule on one page

All the rules from today in one table. Use it as a checklist: go down the list and ask 'does this rule tell me anything about my puzzle?'

Column rule
top + bottom + carry in = digit + 10 × carry out
Digits 0 to 9 add to
45
Ax 100Bx 10Cx 1
ABC = 100A + 10B + C
1SOSO+TOO
50 + 50 = 100: leading 1, and O + O = O means O = 0
RuleWhat it saysProved in
Place valueAB = 10A + B, ABC = 100A + 10B + CPlace value
Reversed sumAB + BA = 11(A + B)Place value
Reversed differenceAB - BA = 9(A - B), ABC - CBA = 99(A - C)Place value
CarryAdding two numbers, every carry is 0 or 1Carries
Leading 1Answer one digit longer → its first letter is 1Carries
No leading 0The first letter of any number is not 0Carries
Zero ruleX + Y = X, no carry in → Y = 0Zero and nine
Nine ruleX + Y + 1 ends in X → Y = 9, carry out 1Zero and nine
Even ruleX + X always ends in an even digitZero and nine
Same endingd × d ends in d only for 0, 1, 5, 6Multiplication endings
Square endingsSquares end in 0, 1, 4, 5, 6, 9 onlyMultiplication endings
FlipA - B = C is C + B = ASubtraction
Three rowsAdding three numbers, a carry can be 2This sheet
Why the formula works (proof)
  1. Rows 1 to 12 are proved in the sections above.
  2. Three rows: the biggest column is 9 + 9 + 9 + carry. With a carry of at most 2 that is 29, so the next carry is at most 2.Two rows gave 19, so a carry of 1.
  3. 0 + 1 + ... + 9 = 9 × 10 / 2 = 45.Sum of the first n numbers.
  4. Hence proved.
Worked exampleAB + BA = 121, where A and B are digits. Find A + B.
  1. AB + BA = 11(A + B).Place value.
  2. 11(A + B) = 121, so A + B = 11.