Assignment 3

Due on Sunday 15th July (11pm-ish)

You are very strongly encouraged to work in pairs. Plan and think out carefully before you start programming. The point of these questions is to get you using Python's modules and classes to build various useful things in a modular and reuseable way. You should start by building something pretty simple, focussing on getting the classes and methods talking to one another correctly, and only then start giving them any real functionality.
* in question 1 means that we talked about this on Monday, and ** means that we talked about it on Tuesday.

Question 1:

Build a class or collection of classes to handle matrices and vectors (**). Your classes should allow the 'instantiation' of matrices and vectors, and facilitate the ability to take a matrix A and a vector v and build a new matrix B with v as an additional column added to the right of A. You should also build functions to perform row operations on B (**), and a function which can use those row operations to solve simultaneous equations (**).

Now that you have done this, you should write a program to model the zero knowledge secret sharing protocol (*). Your version should handle the case of any 3 people out of a large collection being the minimum number needed. You are welcome to explore cases where any n people are needed for some chosen value of n >= 2, though you are urged to be careful when you test for equality after solving the system of equations :)

Question 2:

Similar to the example we have been building in class over the past few days, you should build a model of a collection of towns. Each town will have a name and a unique ID, and the ability to host some number of people (each town might have different limits on the number of people it can host). Each town may have roads going from it to other towns (again, each town may have different limits on the number of outward roads it can have, and even different limits on the number of incoming roads it can accept). People should also have names and unique IDs, and permit the ability to have possibly multiple friends.

Your model should use classes sensibly, and allow the construction of a network of towns (roads are allowed to pass over or under each other without intersecting, so there is no need to fuss about whether you can draw a 'flat' map of this). It should also allow people to move from one town to another (provided there's hosting space in the target town (and any intermediate towns needed enroute)). Finally, you should allow people to 'friend' other people, and if the 'friendship' is mutual, alert each other when they are in the same town (and 'unalert' each other if they had been in the same town but one or other has moved so that they are no longer in the same town -- beware of the case where both move from town A to town B !!).