DEV Community

Kennedy McGarness
Kennedy McGarness

Posted on

computational thinking/pseudocode exercise for beginners

currently in my first week learning to code!

four cornerstones of computational thinking

  • decomposition
  • pattern recognition
  • abstraction
  • testing/debugging algorithms

here's an example of pseudocode I wrote, separated into each 'cornerstone' for class:

objective: write pseudocode for performing an at-home task

task chosen: putting away laundry

//Algorithm: Put away laundry

//Tasks:
//Put away shirts
//Put away socks
//Put away pants

//Pattern recognition:
//Shirts go in the closet
//Socks go in the top drawer
//Pants go in the third drawer

//Abstraction:
//Ignore second drawer

//Sequence:
//1. Event 1: Hang shirts:
// Conditional: If (it is a shirt) {hang it in the closet}
// Debug: A shirt has a hole in it - what do we do?
// Conditional: If (it is a shirt) {hang it in the closet} else if (a shirt is torn) {put it in the donation // bag}
//2. Event 2: Put away socks:
// Conditional: If (it is a sock) {put it in the top drawer}
// Debug: A sock has a hole in it - what do we do?
// Conditional: If (it is a sock) {put it in the top drawer} else if (a sock has a hole) {put it in the trash}
//3. Event 3: Put away pants:
// Loop: for (each pair of pants in the laundry) {put it in the third drawer}

Top comments (0)