You are on page 1of 3

Peer Group Assignment: Deadline Wednesday 27th October

Alexandra Rogers, ALU Discrete Maths Facilitator

1 Instructions
This assignment is a peer group assignment. For it, I will need you to arrange yourselves into groups of 3
or 4 people. Once you have done this, haven 1 person from your group email me listing the members of
your group and the cohort each member is in. You may have members from different cohorts in your peer
group. The deadline for sending me the email with your peer groups is Wednesday 27th October at
13:00 CAT. If you don’t have a peer group, or your peer group is less than 3 people, please let me know
by the same deadline. I will then assign you a peer group/add other people to your peer group to make
them up to the required size by the end of the day. *Please note, it might be necessary for you to accept
another member into your peer group if you have a group of 3 and there is 1 person who needs a group*.
Below you will find a list of problems for your group to solve. This assignment is designed to get you
thinking about how to code the concepts covered in Discrete Maths so far. It will call upon the coding
skills you are learning in Programming I. Your solutions to these problems should be written in Python.

1.1 Submission
You must submit to Canvas the following:
1. Your Python Code.
2. A short write-up of your code explaining to the user (me) what your code does. For each problem,
write your reasoning for your code, showing knowledge of the discrete maths concepts. (E.g. What
discrete maths concept did you use when checking that a relation is reflexive and how is this reflected
in your code?)
3. In your short write-up, include screenshots of your code being applied to examples (as asked in the
questions). This screenshot should clearly show your code, the input and the output.

1.2 Extra info


Note:
ˆ This will be worth 15% of your overall grade.
ˆ Not all questions are weighted equally - some questions might be worth more points than others.
ˆ You will be graded on if your Python code works for every case possible, if the outputs are clear
and uncluttered, if your examples are correct, and how clearly your solutions are presented in your
write-up.
ˆ Grades will be the same for each person in the group.
ˆ Deadline is Wednesday 10th November at 23:59.
If there are any questions or problems with the above instructions, please email me. Good luck and
have a pleasant break!

1
2 Problems
1. Write a programme to test if a given list of elements constitutes a set. It should take as its input a
list of elements and should output a True or False value.
If the truth value is False then it must also output the list converted to a set.
As well as the code, submit an example in your write-up of a list of elements which is not a set and
the output that your code gives on this example.

ˆ E.g. For the input [’Alex’, ’Bob’, ’Sam’, ’Brian’, ’Brian’, ’Sam’, ’Sam’] it should output
something like:
False, the set should be: [’Alex’, ’Bob’, ’Brian’, ’Sam’]

2. Write a programme that takes as input 2 finite sets of any size, A, B, and outputs the following:
a) the truth value of B ⊆ A,
b) the set A − B,
c) the set A × B.
As well as the code, submit 1 example in your write-up of sets A and B and the outputted values
for a)-c).

ˆ E.g. Figure 1 shows the output when the input is A = [1, 4, 2, 5], B = [1, 2, 5]:

Figure 1: Example of Question 2 output (Note, AxB continues beyond the picture)

3. Write a programme that takes as input finite sets A and R where R is of the form (written mathe-
matically):
R = {(x1 , y1 ), (x2 , y2 ), ..., (xn , yn )}.
Your code should first check if R is a relation on A (that is, if R is a set and if R ⊆ A × A).
If R is not a relation on A, your programme should output a statement to this effect.
If R is a relation on A then your programme should output which of the following properties the
relation satisfies:
a) reflexive,
b) transitive, and/or
c) symmetric.
(Remember, a relation can have none, one, two, or all three of the above properties.) If the relation
R fails one of these properties, your code should output the element(s) which fail(s) this property.
In addition to the code, submit 1 example in your write-up of an A and R where R is a relation
on A and 1 example where R is not a relation on A, along with the output of your code for these
examples.

2
Figure 2: Example of Question 3 output

ˆ The output of your code should be something similar to Figure 2 when R is a relation on A,
e.g. when the input is A = [1, 4, 2, 5], R = [[2, 2], [4, 4], [5, 5], [5, 2], [2, 4]].
ˆ The output of your code should be something similar to the following when R is not a relation
on A, e.g. for input A = [1, 4, 2, 5], R = [[2, 3], [4, 4], [5, 5], [5, 2], [2, 4]]:
R is a set
R is not a subset of AxA because the following element is in R but not in AxA: [2, 3]
R is not a relation on A

4. Write a programme that takes as input 2 finite sets X and Y , where X, Y ⊂ Z, and outputs a truth
value (’True’ or ’False’) for the following statement:

∀x ∈ X, ∃y ∈ Y such that y | x.

In addition to the code, give 1 example in your write-up of sets X, Y where this truth value is True,
and 1 example where the truth value is False.

You might also like