Micro Challenge # 40 – Finding sequencing errors

6 July 2020 - 3 minute read

Welcome to the fortieth of Altitude Foundation’s #MicroChallenges2020

Today’s challenge will help you practice spotting sequencing errors

What’s a Micro Challenge?

These challenges are short activities to help you develop, revise or refresh your coding skills, posted every Monday, Wednesday and Friday.

Micro Challenge #40

This week, we are exploring debugging and error-spotting. 

The Challenge:

Today’s challenge focuses on sequencing – the topic of our very first MicroChallenge. Below are three sequences, one pseudocode, one Python and  one JavaScript with sequencing errors. Can you spot the error and rearrange the sequence so it makes sense?

  1. A vote tallying programme (pseudocode)

vote tally a ← 0

vote tally b ← 0

IF press a, vote tally a ← add 1

IF press b, vote tally b ← add 1

OUTPUT “Enter your vote”

Press A ← USERINPUT

OUTPUT “Thank you for your vote”

OR

Press B ← USERINPUT 

OUTPUT “Thank you for your vote”

OUTPUT “The new tally is” + vote tally a + vote tally b

  1. A sock matching game (JavaScript)

input.onButtonPressed(Button.A, function () {

  if (Socks_1[index] == Socks_2[index_2]) {

        basic.showString(“Matched pair“)

        basic.showString(“Try Again“)

        basic.clearScreen()

    } else {

        basic.showString(“Hurra!!!“)  

    basic.showString(“1st!“)

    basic.pause(500)

    basic.showString(“” + (Socks_1[index]))

    basic.pause(500)

    basic.showString(“2nd“)

    basic.pause(500)

    basic.showString(“” + (Socks_2[index_2]))

    }

})

  1. A programme which picks a song for you to sing to time washing your hands

from microbit import *

import random

answers = [

    “Any Dream Will Do”

    “Take On Me”

    “Do-Re-Mi”

    “All Star”

    “Never Gonna Give You Up”

    “Mr Brightside”

    “Africa”

]

while True:

    display.show(“Wash Your Hands?”)

    if accelerometer.was_gesture(“shake”):

        display.clear()

        sleep(1000)

        display.scroll(“1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19”)

        display.scroll(random.choice(answers))

        display.show(Image.YES)

Review it:

Advanced:

  • Could you come up with your own sequencing challenge – create a sequence and then mix it up and see if someone else can put it in the right order?

Share it

We would love to see what you have created! Please send any pictures, videos, or files of your activities to us – either via Facebook, Twitter or Instagram  using #MicroChallenges2020 or to challenges@altitudefoundation.org. If you are emailing them to us, please let us know if you are happy for us to share your stuff on our social media platforms (with credit, of course).

Sign-up here to receive a weekly email with Micro Challenges top tips and solutions:



Leave a comment

Leave a Reply