You think there is life and there are problems. Two separate things. But in reality, they are inseparable.

– Buddha

Many parents understand that learning to code builds their child’s problem-solving skills. But very few parents know how. Using the example of “Rock Paper Scissors”, a game that we teach kids to build in one of our Python courses, we’ll show you how coding naturally develops problem-solving skills in children. 

The Art of Problem-Solving

Teaching problem-solving to kids is important because they will need these skills to succeed in everyday life. By providing structure and practice, kids can improve these skills and be confident in solving problems.

Girls who is confused and has a problem

When faced with a problem or a challenge, we ask children how they would go about solving it. Most kids would have this reaction: “I don’t even know where to start!”.

A simple and intuitive problem-solving framework helps them think about a problem in a structured way and gets them started. 

Below is a simple and intuitive problem-solving framework with three steps:

  1. Break the problem down into smaller problems.
  2. Decide which smaller problem to tackle first, which next, and so on.
  3. Find a solution for each small problem, until all the problems are solved.

1. Break the problem down into smaller problems. 

A big problem can almost always be broken down into smaller problems. This is called problem decomposition. These smaller problems are easier to get started on and easier to solve. Once the first small problem is solved, it provides children with the confidence and the forward momentum to solve the subsequent small problems until the entire problem is solved. 

2. Decide which small problem to tackle first, which next, and so on. 

Once the big problem has been broken down into smaller problems, they need to finalize the order in which these small problems should be solved. This process of thinking about these small problems and finalizing the order in which to solve them is called problem sequencing. 

You may consider which small problems you already know how to solve and start with those. Some of these small problems are dependent on other small problems getting solved first. So, they’ll need to be completed in a way that accounts for that. Once problem sequencing is done, you are almost halfway done with solving the problem.

3. Find a solution for each small problem, until all the problems are solved.

Finally, these small problems need to be solved one at a time. Because these problems have a much simpler scope and complexity than the big problem, solving them is much easier. Using a mix of creativity and critical thinking, kids can come up with a solution, apply it, and then analyze the results. The more experience and practice they have, the easier it will become to solve progressively larger problems.

How programming teaches kids the art of problem-solving

The “Rock Paper Scissors” project at CodeWizardsHQ is a perfect example to demonstrate how students develop problem-solving skills while learning programming. Students use the steps outlined above to solve problems with code.

Students break the game down into smaller pieces.

For this project, we initially asked students how we should go about building the “Rock Paper Scissors” game. Most students don’t know where to start. That is when we introduce the problem-solving framework of decomposing the problem into smaller steps. As soon as we teach them how to think about the problem, they can use that thought process to formulate these three steps:

  1. User makes a choice
  2. Computer makes a choice
  3. Decide winner and display 

After the student deconstructs the problem, they realize how breaking down a problem puts them in a much better position to solve it. Confusion turns to confidence as they have now figured out a starting point.

Decide which smaller problem to tackle first, which next, and so on. 

Now that the small problems are identified, they must decide the order in which to solve them. Kids use their computational and critical thinking skills here to consider all factors that may affect the order.

The game steps are organized in the order that the game is executed. We also ask students to consider any dependencies. For example, both the user and the computer must make a choice before the winner is decided. As a result, the winner has to be decided and displayed at the end. 

Also, the computer cannot make a choice before the user. That would mean that the user must make a choice immediately at the same time or they will know the computer’s choice before making their choice and the game would not be fair.

As a result, the steps are solved in this order:

Problem solving steps for tic tac toe

Find a solution for each small problem, until all the problems are solved.

Once students have the three smaller steps and the order in which to solve them, they can write code to solve each one.

For the first step, the computer needs to ask the user to make a choice. Students will know how to solve this specific problem because asking for user input is one of the first things they learn in the middle school Intro to Programming in Python course and also in our high school Intro to Python course.  

For the second step in the game, the computer needs to choose from the same options presented to the user: rock, paper, or scissors. This step requires the student to think of a way for the computer to make a choice.

The student might think to themselves, “when I play rock paper scissors, what the other person chooses is random to me”.

Luckily, they already know how to write code that tells the computer to create a random number. This is also taught in the middle school Intro to Programming in Python and also high school Intro to Python course. It’s a common programming problem that has a standard solution. All they need to do now is connect the random number to the computer’s choice. 

python code for random number

In order to get a random choice, the computer must first generate a random number between 1 and 3. Students then program “if” statements that attach each potential number to one of the choices: rock, paper, or scissors. The computer now randomly picks from rock, paper, or scissors by generating a random number.

python if else statement

For the last step, they need the computer to decide who the winner is based on the choices made by the user and the computer. The computer will show a different output for each combination but, since students rarely practice organizing their thoughts, all of these combinations might feel jumbled in their heads. 

To solve this problem, we ask them to list each of the combinations and outcomes by organizing them in a logical drawing. With a little guidance, they end up with a decision tree like the one below. 

Decision tree for tic tac toe

For every user choice, the computer will randomly pick from three options. By extending that logic, the student can organize three possible user choices with three corresponding computer choices for each, a total of nine outcomes.

When we get students to tell us about how the computer reaches each outcome, they start to explain it in an “if-then” structure. “If I pick rock, and if the computer picks scissors, then the computer outputs ‘rock wins’”. Transferring this logical “if-then” structure into code for each of the nine outcomes is just a matter of knowing the correct syntax.

The result in Python: