Programming Demonstration

You have a team of five people, and your job is to get them to co-operate to carry out a simple task. The team is arranged in a circle with the members numbered from 1 to 5. Member 2 is to the left to member 1.

Each person has to think of a number and the team has to work out the total of these numbers. This may seem very simple, but your team members can only do very simple things. Each member can:
  1. Tell a number to the person on their right.
  2. Tell a number to the person on their left.
  3. Listen to the person on their right.
  4. Listen to the person on their left.
  5. Add what they heard to what they have remembered.
  6. Remember what they have heard.
  7. Stop.
Team member one is the leader and has one list of instructions to follow (the master program). The other team members all follow the slave program. Devise master and slave programs so that each member reaches the Stop instruction having remembered the sum of all the original numbers.

There now follows a demonstration which permits you to enter the programs and numbers which each person has though of (in the range 1..99) and then watch the outcome. Press the Run Program button when you have entered your data. When your program stops, a message will appear beside this button to tell you whether everythin has worked. Remember, each person must know the total and have "stopped".