Secret Santa Scratch
How it works
Kyle is paired with Aiden
Millie is paired with Dave
Archie is paired with Oliver
- Understand and use sequence in an algorithm
- Understand and use iteration in an algorithm (FOR and WHILE loops)
- Understand and use selection in an algorithm (IF, Else and Else if)
- Understand and use data structures in an algorithm (for example, Lists, Tables or Arrays)
EDUCATOR: COMPUTATIONAL THINKING COMPETENCIES:
COMPUTER SCIENCE EDUCATORS:
CSTA K–12 CS Standards:
AREA OF LEARNING AND EXPERIENCE: Science and Technology:
Computation is the foundation for our digital world.
Progression step 3
- I can use conditional statements to add control and decision-making to algorithms.
- I can identify repeating patterns and use loops to make my algorithms more concise.
- I can explain and debug algorithms.
Progression step 4
- I can decompose given problems and select appropriate constructs to express solutions in a variety of environments.
- I can select and use data structures that efficiently manage data in algorithms.
- I can plan and implement test strategies to identify errors in programs.
Progression step 5
- I can identify, define and decompose problems, choose appropriate constructs and express solutions in a variety of environments.
- I can use file-handling techniques to manipulate data in algorithms.
- I can test, evaluate and improve a solution in software.
In this lesson, students will code a Secret Santa name picker. The program works by picking a name at random from a list and then pairing them up with a name from the second list. Each person must keep their pairing a secret and either buy or make a gift for the person they have been drawn with.
Start by sharing the following code. Challenge the students to predict what will happen before revealing the answer.
Share the source code for the sorting hat (below) and challenge the students to modify the code so that it picks a name from the class at random.
Sorting hat code:
Explain to the students that, currently, the random name picker can pick the same name several times. Challenge the students to modify their name picker so that it removes a name from the list once it is picked so that the name cannot be picked again.
Instruct the students to add the following block to the end of their program:
Share the worked example (below) and challenge the students to modify their code so that it picks two names at random from the list and prints out the names. For example:
Alex is paired with Kyle
Millie is paired with Dave
Have the students modify their code so that that it pairs everyone in the list (whole class).
Top tip: The students will need to use a loop. For example:
Challenge the students to create a random group picker that places people into groups of 4 or 5.