13 years ago

Following Instructions


Activity 1.1


Carry out the following set of instructions in your head.

Think of a number between 1 and 10

Multiply that number by 9

Add up the individual digits of this new number

Subtract 5 from this total

Think of the letter at that position in the alphabet

Think of a country in Europe that starts with that letter

Think of a mammal that starts with the second letter of the country’s name

Think of the colour of that mammal

Congratulations! You’ve just become a human computer. You were given a set of instructions which you have carried out (by the way, did you think of the color grey?).

That’s exactly what a computer does. You give it a set of instructions, the machine carries out those instructions, and that is ALL a computer does. If some computers seem to be able to do amazing things, that is only because someone has written an amazingly clever set of instructions. A set of instructions designed to perform some specific task is known as an algorithm.

There are a few points to note from the algorithm given above:

  • There is one instruction per line

  • Each instruction is unambiguous

  • Each instruction is as short as possible

Activity 1.2

This time let’s see if you can devise your own algorithm.

The task you need to solve is to measure out exactly 4 gallons of water. You have two containers. Container A, if filled, will hold exactly 5 gallons of water, while container B will hold 3 gallons of water. You have an unlimited supply of water and a drain to get rid of any water you no longer need. It is not possible to know how much water is in a container if you only partly fill it from the supply.

If you managed to come up with a solution, see if you can find a second way of measuring out the 4 gallons.

For those of you like me, you probably used the power of Bing or Google and noticed there are at least two ways to solve the problem given in Activity 1.2. Is one better than the other? Well, if we start by filling container A, the solution needs less instructions, so that might be a good guideline at this point when choosing which algorithm is best.

However, the algorithms that a computer carries out are not written in English like the instructions shown above, but in a more stylised form using a computer programming language. DarkBASIC is one such language. The set of program language instructions which make up each algorithm is then known as a computer program or software.

Just as we may perform a great diversity of tasks by following different sets of instrucions, so the computer can be made to carry out any task for which a program exists.

Computer programs are normally copied (or loaded) from a magnetic disk into the computer’s memory and then executed (or run). Execution of a program involves the computer performing each instruction in the program one after the other. This it does at impressively high rates, possibly exceeding 2,000 million (or 2 billion) instructions per second (2,000 mips for short).

Depending on the program being run, the computer may act as a word processor, a database, a spreadsheet, a game, a musical instrument or one of many other possibilities. Of course, as a programmer, you are required to design and write computer programs rather than use them. And, more specifically, our programs in these tutorials will be mainly games-related; an area of programming for which DarkBASIC Pro has been specifically designed.

Activity 1.3


  1. A set of instructions that performs a specific task is known as what?

  2. What term is used to describe a set of instructions used by a computer?

  3. The speed of a computer is measured in what units?

Solutions:


Activity 1.1

No solution

Activity 1.2

Fill A

Fill B from A

Empty B

Empty A into B

Fill A

Fill B from A

Activity 1.3

  1. An algorithm

  2. A Computer Program

  3. mips (millions of instructions per second)



0 comments

Loading...

Next up

Short intro of us 💕✌️

We're an eletro duo based in Seoul 🇰🇷 Heavily influenced by the 90s.

Our new album #Xennials is all about the nostalgia of that era 💽 CD listenin 📟 beeper beepin 💾 floppy disks floppin days 😎

Stream now! 🎧

https://open.spotify.com/album/3YwWhnHWVy5cA8XOpbaGRA?si=8E9awqU…

Bandana Dee the Dream Friend

art comission.

Smile! Here, take some happy pills! ✨💊 #Blender #3DModelling #3DArt Buy me a Ko-fi: https://ko-fi.com/barbarafb_

Chiaki Nanami!

Successful landing

#screenshotsaturday

Path of Kami: The Evolution of the Lore

Runestones: from concept to in-game model🗿

So here's the first of the zodiac signs i will make for the next weeks.

A Shiny Mega Gengar 🌟 For @ManutkArt 's #ThreeColorsChallenge!