Mathematics · Professor Pi

Team coding toolkit:全部卡片

整套按顺序列出——孩子看到之前,您可以先通读一遍。

1 KS3-MATH-PCT-0001

A method that solves a problem by calling itself on a smaller version of it

Recursion

提示Russian dolls do it; so does a mirror facing another mirror.

为什么It needs two parts: a base case small enough to answer outright, and a step that shrinks the problem towards that base case. Miss the base case and the program never stops. Term-to-term sequences in maths are the same idea — each term is defined from the one before, and the first term is the base case.

2 KS3-MATH-PCT-0002

A program shares out whole sweets between children and must never split one. Which kind of division does it need?

Whole-number division

提示The kind that keeps what is left over as a separate answer, rather than trailing off into a decimal tail.

为什么Most languages offer two divide operators: one gives 3.5, the other gives 3 with a leftover of 1. Timed rounds lean on the second constantly — filling boxes, counting complete rows, wrapping a clock past 12. Reaching for the wrong one is a favourite way to lose an otherwise correct solution.

3 KS3-MATH-PCT-0003

A pattern grows by the same amount at every step. What lets a program jump straight to the 500th value without looping through the rest?

The nth term rule

提示The position-to-value formula — the one written with n in it.

为什么A term-to-term rule ('add 4 each time') needs every step before the one you want; a position-to-value rule ('4n + 1') goes straight there. For a linear pattern the multiplier of n is the common difference, and the constant is whatever makes the first value come out right. In a timed round, replacing a loop of 500 steps with one line of arithmetic is often the whole trick.

4 KS3-MATH-PCT-0004

The running totals 1, 3, 6, 10, 15 … which stack into a neat pyramid of dots, are called the … numbers? (one word)

triangular

提示Think of the shape a rack of snooker reds makes, then use the adjective form of that shape.

为什么They are the running totals 1, 1+2, 1+2+3 …, so the nth one is n(n+1)/2. That formula replaces a whole loop, which is why it turns up in timed rounds so often.

5 KS3-MATH-PCT-0005

To decide whether a number is prime, a program tries dividing by 2, 3, 4 and upwards. At which value can it safely stop?

Its square root

提示If a divisor bigger than this existed, its partner would be smaller and you would have met it already.

为什么Divisors come in pairs that multiply to the number: for 36 they are 2 × 18, 3 × 12, 4 × 9, 6 × 6. Past 6 the pairs simply repeat the other way round, so nothing new can appear. Stopping there turns a check on a million from a million steps into a thousand — which is the difference between a solution that finishes inside the round and one that does not.

6 KS3-MATH-PCT-0006

Two lights flash on regular but different cycles and have just flashed together. Which number tells a program when they next coincide?

Their lowest common multiple

提示You meet it as the partner of HCF; buses at a stop setting off again at the same moment is the classic question.

为什么Flashing lights, buses at a stop, gear teeth lining up — all the same question. For cycles of 4 and 6 the answer is 12, not 24: multiplying the two cycles always gives a time that works, but usually not the earliest one. Divide the product by the HCF to get it right, or in code walk through the multiples of the larger cycle until one fits the smaller.

7 KS3-MATH-PCT-0007

The longest side of a right-angled triangle, always opposite the right angle

The hypotenuse

提示Greek for 'stretching under'; it is the side a ladder makes when it leans against a wall.

为什么Pythagoras gives its length: square the two shorter sides, add them, take the root. Programs use it constantly for the straight-line distance between two points on a grid, where the difference across and the difference up are the shorter sides. Comparing squared distances instead of rooted ones is a common speed trick, because the ordering comes out the same either way.

8 KS3-MATH-PCT-0008

A computer stores decimals only approximately, so a program should test two of them by checking they are ____ rather than exactly equal.

close

提示Exact matching fails here — what you want is a tolerance, a tiny gap you are willing to accept.

为什么In most languages 0.1 + 0.2 does not equal 0.3 exactly; it comes out a hair over, because binary cannot write 0.1 any more neatly than decimal can write a third. The fix is to check the difference is smaller than some tiny amount. Whole numbers have no such problem, which is one reason experienced coders stay with integers wherever they can.

9 KS3-MATH-PCT-0009

Nearly every programming language works out × and ÷ before + and −, following the same priority order you learned as ____.

BIDMAS

提示The six-letter word your maths teacher writes on the board; brackets come first in it.

为什么Brackets, Indices, Division and Multiplication, then Addition and Subtraction. Languages agree with the maths, so 2 + 3 * 4 is 14 rather than 20. Where they can differ from each other is what a bare minus sign does in front of a power — when in doubt, add brackets: they cost nothing and settle the argument.

10 KS3-MATH-PCT-0010

A whole number that divides exactly into another is a ____ of it; a number appearing in another number's times table is a ____ of it; a number with exactly two divisors is ____.

factor; multiple; prime

提示All three are Year 7 words about how one whole number sits inside another; the last is the special case with the fewest.

为什么These three words carry most of the number theory a coding round needs. Note the two edge cases a test program will throw at you first: 1 is not prime, because it has only one divisor, and 2 is the only even prime there is.

11 KS3-MATH-PCT-0011

In Round 1 of the Perse Coding Team Challenge, how do entrants normally work?

In pairs on one computer

提示Not alone and not in a big group — and there is only a single keyboard between them.

为什么Round 1 runs for 40 minutes, with entrants working in twos — or solo where a school has to — on a single machine, and a high score carries them through to Round 2, which lasts an hour and allows teams of up to three. The challenge is run by The Perse School in Cambridge, is free to enter, and is open to UK pupils in Year 11 and below. Solutions may be written in Python, C++, C#, Java, JavaScript or Visual Basic.Net.

12 KS3-MATH-PCT-0012

Round 1 of the Perse Coding Team Challenge lasts how many minutes? (type the number only)

40

提示It is shorter than Round 2, which runs for a full hour.

为什么Round 1 is forty minutes, Round 2 sixty. Judging roughly how long a problem will take before you start it is a real part of the skill — an unfinished perfect answer scores nothing at all.

把学到的留下来

在这个页面上,练习不会被保存。在孩子自己的星空里,每一张卡都有排程——在快要忘记之前重新出现——写这张卡的教授也只有一步之遥。