Not every problem requires writing a program. Many, however, become easier when we choose how to represent them, separate the decisions, and find a way to control the outcome. These twenty cases show computational thinking at work through data, rules and verification.
Before choosing a procedure
Formulating the problem well means declaring what we know, what we want to achieve and what we cannot do. If two solutions respect all the constraints, a criterion such as cost or time allows one to be preferred. An example clarifies the method; an edge case helps us find out where it breaks.
Represent the data
1. Library loans
A reader searches for the latest available copy of a book that exists in two copies. Use a code for each copy, not just the title.
Show the solution
Record a status for each copy: available, on loan or for consultation. If one is on loan and the other is for consultation, there are zero copies available, even if the catalog contains two.
2. A map without distances
In the plan of a museum it is interesting to know if you can go from one room to another without going through a staircase. Here the connections count, not the shape of the rooms.
Show the solution
Represent rooms as points, doors as connections, and exclude stairs. If you get from A to B and from B to D through doors, the route A–B–D is valid even if A and D appear far away on the plan.
3. A mosaic with less data
To describe the red, red, red, blue, blue row, you don't need to list every tile.
Show the solution
Write 3 red, 2 blue. Rebuild the row to check that the colors and order match. If the colors always alternate, this system can become longer than the original list.
4. An availability table
Three rooms have a projector, step-free access, or both. You need to select a room with both requirements.
Show the solution
Use two yes/no columns and only keep rows with two yeses. A "missing data" is neither yes nor no: the room remains to be verified.
5. Merge records without confusing people
Two registers contain two students who are both called Luca Rossi. You want to link loans to your membership registry.
Show the solution
Use your membership code as your key. If the loan only shows the name and there are two possible codes, report an ambiguous match instead of choosing the first line.
Break down work and respect dependencies
6. Mount a photography exhibition
To set up six panels you need to choose the photos, check the captions and mount the prints.
Show the solution
Divide the work into packages with a verifiable result. While one person prepares the captions, another can check the frames; the assembly of a panel only starts when it has both the photo and the caption approved.
7. Course prerequisites
A practical module requires both the measurement module and the data representation module. These two can be done in any order.
Show the solution
Draw two arrows towards the practical module. To build the path, only add modules with all prerequisites already completed. If two modules request each other, it signals the loop.
8. Distribute tasks in an editorial office
Three deliveries last 6, 4 and 3 minutes and two equally trained people are available. You want to finish as soon as possible.
Show the solution
Assign job 6 to one person and the other two to the other: you finish in 7 minutes. You can't finish in 6, because 13 minutes of work exceeds the total 12 minutes available for two.
9. Prepare kits with shared parts
Each kit requires 2 clips and 3 cards. You have 11 clips and 14 cards.
Show the solution
The clips allow 5 kits, the cards only 4. Prepare 4 kits: 3 clips and 2 cards remain. Counting resources separately avoids promising an incomplete fifth kit.
10. Insert an activity among commitments
A room is occupied from 9:00 to 9:40 and from 10:10 to 10:30. A continuous space of 30 minutes is needed.
Show the solution
Order the intervals and measure the gaps between one commitment and the next. With intervals that exclude the final moment, from 9:40 to 10:10 there are exactly 30 minutes; with 5 minutes of tidying up is not enough.
Recognize regularities and compare strategies
11. Rebuild a texture
On one band it repeats red, blue, blue. You want to know which color occupies box 14.
Show the solution
Divide the band into groups of three. Box 14 is the second of the fifth group, so it is blue. Also try box 15, so as not to confuse the zero remainder with the first position.
12. Compare two inventories in one step
Two item lists are sorted by code and do not contain duplicates. You want to locate codes present only in a list without starting the search every time.
Show the solution
Scroll through lists with two pointers. If the codes match, advance in both; otherwise it records the minor code and only advances in its list. At the end it also records the remaining elements.
13. Group support requests
You have three requests for the same printer and two for a different printer. You want to organize your work without losing reports.
Show the solution
Group by device code and maintain the five request IDs. You get two groups, not two requests. A resolved fault can close a group only after all reported symptoms have been verified.
14. Show the distribution of times
Two groups both take 10 minutes on average: the first has times 9, 10, 11; the second 2, 10, 18.
Show the solution
In addition to the average, it plots times on a line or shows minimum and maximum. In the first group the interval has a width of 2, in the second 16. The average is the same, but it does not describe the variability.
15. Select a field's reservations
Four requests partially overlap. They all have the same value and you want to accept as many of them without overlap.
Show the solution
Sort by end time and accept the first compatible request every time: leave more space for subsequent ones. The rule does not automatically apply if some reservations are worth more than others.
Check, fix, and handle exceptions
16. Reserve the last place
Two operators see that there is only one seat left and try to book it at the same time.
Show the solution
Treat availability checking and booking as a single indivisible operation. After the first confirmation, the second one must fail. Check that the number of confirmed seats never exceeds capacity.
17. Do not record a delivery twice
A code reader sends the same event twice because it does not receive confirmation immediately.
Show the solution
Assign an identifier to the event and check if it has already been recorded before updating the total. By repeating the same event twice, the total must increase only once; two different events should instead both be counted.
18. Check a flooring
A rectangular room measures 5 by 4 meters; some areas do not need to be covered. The total area alone does not say whether the tiles fit.
Show the solution
Draw a grid to scale and try out an arrangement. Check for overlaps, uncovered cells and obstacles. Two cutouts with the same area may have different shapes and may not be interchangeable.
19. Distinguish zero and missing data
A rain gauge registers 0 mm on Monday and no value on Tuesday. You want to calculate the average of the days measured.
Show the solution
Count Monday in the denominator but not Tuesday. If valid values are 0 and 6, the average is 3; treating the missing data as zero would make it 2. If there are no valid measurements, the mean is undefined.
20. Try a return policy
An educational card game requires a deposit of 5 tokens. Upon complete return, 5 tokens are given back; if a card is missing, 3 are returned.
Show the solution
Prepare three tests: intact deck, one missing card and two missing cards. The first two have expected outcomes; the third reveals an incomplete specification. Ask for a rule instead of automatically extending the existing one.
The same question for all cases
What data should I keep? Which property must remain true after each step? How do I know I'm done? What example could disprove my solution? Answering these questions makes a process explicit, verifiable and reusable, even when we perform it by hand.