Bag Of Cows

Pseudo Code Library

The Philosophical Restaurant

Challenge one: Hope in our hearts

The menu items picked will be based on an algorithm, which asks the customer to choose a number and then calculates what to give them.

Here is how the chef works out what to give the customer:

  1. Lay out all the foods in a line on the table, out of sight of the customer.
  2. Ask the customer for a number. This can be any number except 0 or the number of things on the table. Call this number 'n' (the offset).
  3. Show the choices to the customer.
  4. Ask the customer what they hate most
  5. Starting from the food they hate, move along the foods by 'n' places. If this goes over the line of things on the table, walk back to the start of the line of foods and keep counting along until you get to the 'n'th food.
  6. That is what they get to eat.
  7. The same procedure is followed for the starter, main course, and pudding.

Write a program following the algorithm above to select from these possible choices:

Starters: Soup, Salad, Mushrooms, Whitebait, Bruschetta, Avocado, Prawns, Olives, Bread, Doughballs

Mains: Chicken, Steak, Pizza, Risotto, Pasta, Salad, Pie, Casserole, Pork, Lasagne

Puddings: Fruit, Ice Cream, Sorbet, Crumble, Cheese, Rice Pudding, Tiramisu, Trifle, Cheesecake, Apple Pie

Here is the lists in a format you might find convenient...

'Soup', 'Salad', 'Mushrooms', 'Whitebait', 'Bruschetta', 'Avocado', 'Prawns', 'Olives', 'Bread', 'Doughballs'

'Chicken', 'Steak', 'Pizza', 'Risotto', 'Pasta', 'Salad', 'Pie', 'Casserole', 'Pork', 'Lasagne'

'Fruit', 'Ice Cream', 'Sorbet', 'Crumble', 'Cheese', 'Rice Pudding', 'Tiramisu', 'Trifle', 'Cheesecake', 'Apple Pie'


  1. The program should ask for the customer's name
  2. The program should ask for the number once (all lists have 10 items, so the same number is valid for all).
  3. It should keep asking until a valid number is given.
  4. For each of starter, main and pudding it should
    1. Show a list of the options
    2. Allow the customer to select which one they don't want - only accept a choice which is in the list.
    3. Store in a variable the food the customer will be given by moving 'n' places up the list of foods
    4. The program should display on the screen a personalised message saying what food has been selected.
  5. Once completed, the program should start again for the next customer.


Please base your code on the challenge 1 template here.

Download and complete the challenge 1 evidence document.



Ask for the customer's name (1) Show it rejecting a blank name
Show it accepting a non-blank name
Ask for the customer's number (2) Show it rejecting a non numeric value
Show it rejecting zero
Show it rejecting 10 (the size of the list)
Show it accepting a valid value
Display the list of starters (1) Prove that was done
Display the list of mains and puddings (1) Prove that was done
Ask the customer to choose a starter (2) Show it rejecting blank
Show it rejecting something not in the list
Show it accepting something on the list
Choose the starter they will have (4) Choose offset number '3' and a food at the start of the starters list
Show displaying the message to the customer
Prove that the food selected is indeed 'n' places further up the starters list

Choose offset number '3' and the last food in the starters list
Show displaying the message to the customer
Prove that the food selected is indeed 'n' places further up the starters list, and that is has wrapped round.
Choose the main (4) and pudding (4) they will have Either:

Repeat the starters tests for mains and puddings


Demonstrate that your code uses a function with parameters to calculate the food chosen, and so will always work for mains and puddings if it works for starters.