Parsons Problems and Why Shuffled Code Lines Teach Beginners Faster
A Parsons problem hands a beginner every line of a working program, then scrambles the order. The student's only job is to put the lines back together so the program runs.

A Parsons problem hands a beginner every line of a working program, then scrambles the order. The student's only job is to put the lines back together so the program runs. Nothing has to be typed from memory, no syntax has to be recalled, and yet the exercise forces the learner to think hard about what each line does and when it needs to happen.
We started using them at the club after noticing that new members spent most of their first sessions fighting typos rather than thinking about logic. A missing colon would eat ten minutes. With a shuffled set of lines on the table, the same students were arguing about whether the counter should be set before or inside the loop within five minutes of sitting down. That argument is exactly the thinking we want.
What a Parsons Problem Actually Looks Like
The format is named after Dale Parsons, who described it with Patricia Haden in 2006 as a puzzle that keeps students engaged while they learn programming patterns. The classic version is simple. You take a short, correct program of four to ten lines, split it so each line is its own piece, and shuffle the pieces.
Here is a beginner example built from a program that adds up the numbers in a list. The student receives these five lines in random order:
total = 0scores = [4, 7, 2, 9]for s in scores:total = total + sprint(total)
To finish, they must decide that the list comes first, the total starts at zero before the loop, the addition sits indented inside the loop, and the print waits until the loop is done. Put the print inside the loop and the program shows four numbers instead of one. That single mistake teaches more about indentation than a paragraph of explanation ever does.
Why Arranging Lines Beats Typing From Scratch Early On
A new coder writing from a blank file has to juggle three things at once: what the program should do, how Python spells it, and where each piece goes. Parsons problems remove the second job entirely. Every line is already spelled correctly, so all of the learner's attention goes to order, nesting and flow.
Research on the format backs up what we see in the room. A 2017 study by Barbara Ericson and colleagues found that students who solved Parsons problems reached similar learning gains to those who wrote the equivalent code, while taking roughly half the time. For a club that meets for 90 minutes a week, halving practice time on a concept is a big deal.
There is also a confidence effect. A blank editor tells a nervous beginner that everything depends on them. A pile of correct lines tells them the answer is already here, and they only need to find it. Several of our members who quit typing exercises in frustration happily worked through a dozen Parsons puzzles in one session.
Four Variations Worth Rotating Through
Once the basic format is familiar, small changes keep it challenging without returning to a blank page.
- Distractor lines. Add one or two lines that do not belong, such as
total = 1next tototal = 0. Students must reject the wrong option, which surfaces common misconceptions. - Indentation left out. Give the lines flush left and ask students to add the indentation themselves. This is the best way we have found to make nesting stick.
- Two-dimensional puzzles. Mix the order and leave a single blank in one line, such as the comparison in an
ifstatement. It is a gentle bridge toward writing code. - Explain the order. After solving, the student writes one sentence per line saying why it sits where it does. This catches lucky guesses.
Running Them in a Club Session
Paper strips work better than you might expect. We print each program in a large font, cut the lines into strips with scissors, and put each set in an envelope. Pairs tip the envelope onto the table and start sliding strips around. Physical pieces invite talking and pointing in a way that a screen rarely does.
A typical 30 minute block looks like this:
| Minutes | Activity |
|---|---|
| 0 to 5 | Mentor solves one puzzle out loud, narrating every choice |
| 5 to 20 | Pairs work through three envelopes of rising difficulty |
| 20 to 25 | Each pair types one solved puzzle into the editor and runs it |
| 25 to 30 | Group discussion of the trickiest distractor line |
The typing step matters. Running the arranged code confirms the answer and gives beginners their first taste of a program working without them having written it from nothing. If the output is wrong, the pair goes back to the strips, which turns debugging into a calm, concrete activity. For more on that kind of support, see our guide on helping a beginner debug without fixing the bug for them.
Writing Good Puzzles Without Spending All Evening
A good Parsons problem is short. Four to eight lines is the sweet spot for first-timers. Past ten lines the puzzle becomes a test of patience rather than understanding.
Start from code your members already understand partly, then remove the support. Some guidelines that have served us well:
- Each puzzle should target one idea, such as a loop with an accumulator or an
ifandelsepair. - Avoid two lines that could swap places and still work, unless you want to discuss that later.
- Choose distractors from real mistakes you have seen members make, not random wrong code.
- Use friendly data: names, scores, snack counts. Abstract values like
xandymake the puzzle harder for no benefit.
Once you have a set of 10 to 15 puzzles covering variables, loops, conditions and functions, you can reuse them every term. Ours took about two evenings to make and have lasted three years.
When to Move Students On
Parsons problems are a stepping stone, not a destination. The signal to move on is when a student solves a puzzle with distractors in under three minutes and can explain the order without hesitating. At that point the puzzle is no longer stretching them.
The next step is a faded exercise: give the first half of a program as arranged lines, and ask them to write the second half. After that, short open exercises like the ones in our small Python exercises guide become much less intimidating, because the learner already has a feel for how working code is shaped.
FAQ
Are Parsons problems only useful for complete beginners?
They are most powerful in the first few months, but harder versions with distractors and missing indentation still challenge intermediate learners. Some clubs use longer puzzles to introduce recursion or nested loops to members who are otherwise comfortable.
Do I need special software to run them?
No. Paper strips in envelopes work well and encourage talking. Free online tools exist that check answers automatically, but they are optional. A shared document where students drag lines around also works fine.
How do I stop students just guessing until it works?
Ask them to explain the position of each line before running the code, or limit the number of times they may run it. The explain-the-order variation is the simplest fix, since a guess falls apart once someone asks why.
The Short Version
Parsons problems let beginners practise the logic of programming without being slowed down by syntax. Keep them short, base distractors on real mistakes, and always finish by running the code. Find more ideas for the classroom side of the club in our teaching code section.
More in Teaching Code
Teaching Code
How to Teach Beginners to Read Python Documentation
I ran a small test at club last February because I was tired of a specific pattern.
Teaching Code
How to Teach the Difference Between print and return
In week five of our adult evening group, a learner called me over because her code had stopped working.
Teaching Code
How to Train Volunteer Mentors for a Coding Club
Our club recruited nine volunteers in one term. Three were still turning up by week six.