Professional Documents
Culture Documents
• To gain experience in designing algorithms for a given problem description and implementing those
algorithms in Python 3.
Submission Procedure
1. Put you name and student ID in a comment at the start of your file in your solution.
2. Save your file into a zip file called YourStudentID.zip
Important Notes:
1. Please ensure that you have read and understood the university’s policies on plagiarism and collusion
available at https://www.monashcollege.edu.au/ data/assets/pdf_file/0010/17101/dip-assessment-
policy.pdf. You will be required to agree to these policies when you submit your assignment.
2. Your code will be checked against other students’ work and code available online by advanced plagiarism
detection systems. Do not take the risk, make sure your work is your own.
3. Where it would simplify the problem you may not use built-in Python functions or libraries (e.g. using
list.sort() or sorted()). Remember that this is an assignment focusing on algorithms and programming.
4. Your program will be checked against a number of test cases. Do not forget to include comments in your code
explaining your algorithm. If your implementations have bugs, you may still get some marks based on how close
your algorithm is to the correct algorithm. This is made difficult if code is poorly documented.
5. For each task, you need to write a program that properly decomposes the problem. You will learn functions and
decomposition in Week 3.
Marks: This assignment has a total of 50 marks and contributes to 8% of your final mark. Late submission will
have 5% off the total assignment marks per day (including weekends) deducted from your assignment mark.
Assignments submitted 7 days after the due date will normally not be accepted
1
Marking Criteria:
Total: 50 marks
Interview Rubric
0 The student cannot answer even the simplest of questions
There is no sign of preparation
They probably haven’t seen the code before
0.25 There is some evidence the student has seen the code
The answer to a least one question contained some correct points
But it’s clear they cannot engage in a knowledgeable discussion about the code
0.5 The student seems underprepared
Answers are long winded and only partly correct
They seem to be trying to work out the code as they read it
They seem to be trying to remember something they were told but now can’t remember
However they clearly know something about the code
With prompting they fail to improve on a partial or incorrect answer
0.75 The student seems reasonably well prepared
Questions are answered correctly for the most part but the speed and/or confidence they are
answered with is not 100%
With prompting they can add a partially correct answer or correct an incorrect answer
1 The student is fully prepared
All questions were answered quickly and confidently
It’s absolutely clear that the student has performed all of the coding themselves.
2
Background:
This assignment has you working on representing a coloured quilt as a table and deciding which colour should
occupy each square. In this problem, you have a rectangular quilt. Some of the squares in the quilt will need to
be coloured. These are marked with “X”. No square can be the same colour as any of the surrounding eight
squares. Note that wrap around is not considered in this problem so a square on the right end does not need
to be different to one on the left end (unless they are already adjacent).
X X - - 0 1 - - 0 1 - -
- X - X - 2 - 0 - 2 - 0
X X X - 0 1 3 - 1 0 1 -
- X - - - 2 - - - 2 - -
Table 2: Coloured quilt Table 3: Another coloured quilt
Table 1: Read from file
Note: The size of the quilt will never be greater than 10 x 10 and the number of coloured squares to be filled
in will never exceed 15 squares i.e. there will never be more than 15 X’s in a file. We will only use four colours.
Any more than 4 will take too long to run if you use brute-force.
3
Task 1: Representation and display (20 marks)
The simplest representation of this problem would be to represent the quilt as a table, where ‘X’ marks the
squares to be coloured and ‘ - ‘ marks the squares that don’t need to be coloured. Integers can be used to
represent the colours with each integer representing a different colour (see table 1, 2, and 3).
4
Task 2: Correctness: (10 marks)
This part is about how to ensure the representation is in fact a valid quilt colouring.
Extend your python program (and menu) so that it can take a representation of the quilt state and determine
whether any two adjacent squares have the same colour.
Where any two adjacent squares are the same colour it prints "invalid quilt" to the screen, otherwise it prints
"valid quilt" to the screen.
For example, consider the three quilts below:
01--
-2-0
013-
-2--
01--
-2-0
012-
-2--
0 - - - - - - - 0
- 1 - - - 012 -
0 - - 01 - - - 0
- 1 2 - - 012 -
5
Task 3: Generating random quilts (10 marks)
In this task you will need to ask the user the dimensions of the quilt, N and M. You will also ask the user to
enter the number of X’s they want in the quilt. You will use these values to generate a new quilt of size N x M
in which the X’s are randomly place in the quilt. You will need to check that the user has entered values that
makes sense e.g. if the user enters 5 x 4 for the quilt size, they should not be able to enter a value of 21 for
the number of X’s. The minimum number of X’s allowed should be greater than 20% of N x M.