Decompose, spot patterns, debug — Mathematics, 11–13
Keep the essential, split into steps, reuse a pattern, write an algorithm — and hunt the bug with the awkward case.
Five habits of a good solver
“Marta has 3 brothers, a dog and 45 pencils. She gives 2/5 of the pencils away. How many?” Abstract: keep only the essential, 45 pencils and 2/5 (brothers and dog do not count). Decompose: split into simple steps, 45 ÷ 5 = 9 and 9 × 2 = 18. Spot patterns: another problem may have the same shape. The algorithm is the step-by-step recipe that works for any numbers. Debug: look for and correct the errors when something fails.
A pattern you can reuse
Six people greet each other, one handshake per pair. How many handshakes? With 2 people there is 1; with 3, 3; with 4, 6; with 5, 10. The increases are 2, 3, 4…, so for 6 people you add 1 + 2 + 3 + 4 + 5 = 15. That pattern serves other problems of the same kind: in a tournament where each of 7 teams plays every other once, there are 1 + 2 + … + 6 = 21 matches. Spotting the pattern and applying it to a similar problem saves you starting from scratch.
A case: can three sticks make a triangle?
Algorithm: 1) write the three lengths; 2) find the longest; 3) add the two shorter ones; 4) if the sum is greater than the longest, a triangle exists; if not, it does not. Case 3, 4 and 5: 3 + 4 = 7 > 5, yes. Case 2, 3 and 6: 2 + 3 = 5 < 6, no. Case 4, 4 and 8: 4 + 4 = 8, which is not greater than 8: the two short sticks lie flat along the long one, so there is no triangle. The procedure splits the problem into steps and can be written as a program, for instance in Scratch.
A shortcut that only fails in the awkward case
Rui simplified the algorithm: “add the first two lengths and compare with the third”. He tested 3, 4, 5 and 5, 6, 10, and it worked. Debugging means hunting for the case that can break it: 8, 3, 4. The shortcut does 8 + 3 = 11 > 4 and says “yes”, but 3 + 4 = 7 < 8, so there is no triangle. It only worked before because the longest came last. The fix: always add the two shorter ones. Debug by testing hard cases and finding the failing step, not by starting over.
Where you see it: spreadsheets and programs
In a spreadsheet you write a formula once and it repeats down every row: an algorithm with a pattern. For the matches of a tournament with n teams, n × (n − 1) ÷ 2 (each team plays the other n − 1, and each match is counted twice, so you halve it) gives, for 2 to 8 teams, 1, 3, 6, 10, 15, 21 and 28 matches, the same numbers as the handshake pattern. A game program does the same: it is split into small blocks, rules repeat, hard cases are tested and it is corrected where it fails. Same thinking, with or without a computer.
Keep exploring
Other languages
Loading MyLeoNes™…