COMP9021 Principles of Programming Term 2, 2024
Assignment 2
Worth 13marks and due Week 11 Monday @ 10am
1. General Matters
Copyright By PowCoder代写 加微信 powcoder
The purpose of this assignment is to:
Develop your problem-solving skills.
Design and implement the solution to a problem in the form of a medium sized Python program.
Analyse the various features of a labyrinth, represented by a particular coding of its basic elements into numbers, from the set {0, 1, 2, 3} only, stored in a text file.
Check that the input text file is correct and represents a labyrinth. Output the labyrinth features nicely.
Use object-oriented programming.
This assignment is worth 13 marks distributed as follows:
Your program will be tested against several inputs. For each test, the auto-marking script will let your program run for 30 seconds. The outputs of your program should be exactly as indicated.
1.3 Due Date and Submission
Your programs will be stored in a file named labyrinth.py. The assignment can be submitted more than once. The last version just before the due date and time will be marked (unless you submit late in which case the last late version will be marked).
Assignment 2 is due Week 11 Monday 5 August 2024 @ 10:00am (Sydney time).
Please note that late submission with 5% penalty per day is allowed up to 5 days from the due date, that
is, any late submission after Week 11 Saturday 10 August 2024 @ 10:00am will be discarded.
Please make sure not to change the filename labyrinth.py while submitting by clicking on [Mark] button in Ed. It is your responsibility to check that your submission did go through properly using Submissions link in Ed otherwise your mark will be zero for Assignment 2.
1.4 Reminder on Plagiarism Policy
You are permitted, indeed encouraged, to discuss ways to solve the assignment with other people. Such discussions must be in terms of algorithms, not code. But you must implement the solution on your own. Submissions are scanned for similarities that occur when students copy and modify other people’s work or work very closely together on a single implementation. Severe penalties apply.
2. Description
The representation of the labyrinth is based on a coding with only the four digits 0, 1, 2 and 3 such that:
• 0 codes points that are connected to neither their right nor their below neighbours:
• 1 codes points that are connected to their right neighbours but not to their below ones:
• 2 codes points that are connected to their below neighbours but not to their right ones:
• 3 codes points that are connected to both their right and below neighbours:
A point that is connected to none of their left, right, above, and below neighbours represents a pillar: Analysing the labyrinth will also allow to represent:
• cul-de-sac:
• entry-exit path:
3. Examples
3.1 First Example
The file named labyrinth_1.txt contains the following: 10221230
32212022 30113100 20300120 32201232 10011000
As per the coding above, labyrinth_1.txt will look like the following:
Here is a possible interaction:
3.2 Second Example
The file named labyrinth_2.txt contains the following:
022302120222 222223111032 301322130302 312322232330 001000100000
As per the coding above, labyrinth_2.txt will look like the following:
Here is a possible interaction:
3.3 Third Example
The file named labyrinth_3.txt contains the following:
31111111132 21122131202 33023022112 20310213122 31011120202 21230230112 30223031302 03122121212 22203110322 22110311002 11111101110
As per the coding above, labyrinth_3.txt will look like the following:
Here is a possible interaction:
3.4 Fourth Example
The file named labyrinth_4.txt contains the following:
As per the coding above, labyrinth_4.txt will look like the following:
Here is a possible interaction:
3.5 Fifth Example
The file named labyrinth_5.txt contains the following:
As per the coding above, labyrinth_5.txt will look like the following:
Here is a possible interaction:
3.6 Sixth Example
The file named labyrinth_6.txt contains the following:
0111221210021212201201323330200 1131011210301210323130331302310 3300200323203011010332232320332 2330312230220302032203223112310 1211020213223110101302032332212 1112222331300131013312312223130 1110120222130303102210113130100 0020320223200020113011131202302 3213100301021111202122030110112 1200320130030313001031302312110 0310130300203000312021011212020 3131210323320222322212332031120 2021033213003230103112331130222 1013300313133312220131222100010 1231322020123133221023110302002 3322231133223020311032001102310 2323101332332011010132023031132 2200112102133112231003320012120 2130210032120230313010200102112 2311003320123302322223032120112 0201320233130133202333323012120 1003010311132003122332112221132 2032100103021312110202200332310 3211202310233321202022122021022 1200330103010322222131033003000 1121200200313110310030131100332 0012021023310003332301123031222 0120302110232113312232012023020 2303222021330232031311210131312 0101112200130031003120203121102 2012100113233120321011002012220 0010322001332202013202312122110 0213000131303132112301110130112 1222303101032032301032210302110 1220131300113200003021222120012 1333010013001231321110022323022 3021223221133030131221100102210 2013320130211320203021000311312 0303003010033021320232203222020 2030233001202311110121110133220 1001011011001101100000010100100
As per the coding above, labyrinth_6.txt will look like the following:
Here is a possible interaction:
4. Detailed Description 4.1 Input
The input is expected to consist of ydim lines of xdim members of {0, 1, 2, 3}, where x dim and ydim are at least equal to 2 and at most equal to 31 and 41, respectively, with possibly lines consisting of spaces only that will be ignored and with possibly spaces anywhere on the lines with digits.
Thexth digitnoftheyth line,with0≤x