您当前的位置 : > 科技

代写COMP9021 Principles of Programming

日期: 2024-04-13
1
COMP9021 Principles of Programming
Term 1, 2024
Coding Quiz 6
Worth 4 marks and due Week 9 Thursday @ 9pm
Description
You are provided with a stub in which you need to insert your code where indicated without doing
any changes to the existing code to complete the task.
Given the value of seed and density, the provided code randomly fills an array (or grid) of size
10 x 10 with 0s and 1s.
Your task is to determine the maximum number of "spikes" in a shape.
A shape is made up of 1s connected horizontally or vertically (it can contain holes).
A "spike" in a shape is a 1 that is part of this shape and "sticks out" (has exactly one neighbour in
the shape).
Neighbours are only considered vertically or horizontally (not diagonally).
Note that a shape with a single 1 is also a spike.
See test cases below for more examples.2
Due Date and Submission
Quiz 6 is due Week 9 Thursday 11 April 2024 @ 9.00pm (Sydney time).
Note that late submission with 5% penalty per day is allowed up to 3 days from the due date, that
is, any late submission after Week 9 Sunday 14 April 2024 @ 9pm will be discarded.
Make sure not to change the filename quiz_6.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 Quiz 6.
Test Cases
$ python3 quiz_6.py
Enter two integers, the second one being strictly positive: 0 8
Here is the grid that has been generated:
1 1 0 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 0
0 1 1 0 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 0 1 1 1 1 1
1 0 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 0
1 1 1 1 1 1 1 0 1 1
The maximum number of spikes of some shape is: 13
$ python3 quiz_6.py
Enter two integers, the second one being strictly positive: 0 7
Here is the grid that has been generated:
1 1 1 1 0 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 0 1 1 1 1 1 1 1 1
1 0 1 0 1 1 1 1 1 0
1 1 1 1 1 1 1 1 1 1
1 1 0 1 1 0 0 1 1 1
1 1 1 1 1 0 1 1 1 1
1 1 1 1 1 1 0 1 1 1
1 1 1 1 1 1 0 0 1 1
1 0 1 1 1 1 0 1 1 1
The maximum number of spikes of some shape is: 3
$ python3 quiz_6.py
Enter two integers, the second one being strictly positive: 0 2
Here is the grid that has been generated:
1 1 0 1 1 1 1 1 1 0
0 1 0 0 1 0 1 0 0 1
1 0 1 1 1 0 1 1 1 0
0 0 1 0 1 1 0 1 0 0
0 0 0 1 0 0 1 1 0 1
1 0 1 0 1 1 0 1 1 0
1 0 0 0 0 1 1 0 0 0
0 0 0 1 1 0 0 1 1 1
1 1 0 1 0 1 1 0 0 0
1 0 0 1 0 1 1 0 0 0
The maximum number of spikes of some shape is: 74
$ python3 quiz_6.py
Enter two integers, the second one being strictly positive: 0 4
Here is the grid that has been generated:
1 1 0 1 1 1 1 1 1 1
1 1 1 0 1 1 1 0 0 1
1 0 1 1 1 1 1 1 1 0
0 0 1 0 1 1 1 1 0 1
1 1 1 1 0 0 1 1 0 1
1 0 1 1 1 1 0 1 1 1
1 1 1 1 0 1 1 0 0 1
1 0 0 1 1 1 1 1 1 1
1 1 0 1 0 1 1 1 1 0
1 0 1 1 1 1 1 0 0 1
The maximum number of spikes of some shape is: 8
$ python3 quiz_6.py
Enter two integers, the second one being strictly positive: 1 2
Here is the grid that has been generated:
0 0 1 0 1 1 1 1 0 0
1 0 1 1 0 1 1 0 0 1
0 0 0 0 1 0 1 0 0 1
1 0 1 0 0 1 1 0 1 0
0 1 0 1 1 0 1 1 1 1
0 1 0 1 1 0 1 1 0 1
0 0 1 1 1 0 1 0 1 1
0 0 0 0 0 0 1 1 1 1
1 0 1 0 0 1 0 1 1 0
1 1 1 1 1 0 1 1 0 0
The maximum number of spikes of some shape is: 55
$ python3 quiz_6.py
Enter two integers, the second one being strictly positive: 2 2
Here is the grid that has been generated:
0 0 0 1 0 1 1 0 0 0
1 1 1 1 1 0 0 1 1 1
1 1 0 0 0 0 0 0 1 0
0 1 0 1 1 1 1 1 1 0
1 1 0 1 1 1 1 1 1 1
1 1 0 1 0 1 1 1 1 1
1 0 1 1 0 1 0 0 0 0
0 1 0 0 0 1 0 0 0 1
0 0 1 1 0 0 0 0 0 0
0 0 0 1 1 0 0 0 0 1
The maximum number of spikes of some shape is: 46
Test Cases Explained
$ python3 quiz_6.py
Enter two integers, the second one being strictly positive: 0 8
Here is the grid that has been generated:
1 1 0 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 0
0 1 1 0 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 0 1 1 1 1 1
1 0 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 0
1 1 1 1 1 1 1 0 1 1
The maximum number of spikes of some shape is: 1
$ python3 quiz_6.py
Enter two integers, the second one being strictly positive: 0 7
Here is the grid that has been generated:
1 1 1 1 0 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 0 1 1 1 1 1 1 1 1
1 0 1 0 1 1 1 1 1 0
1 1 1 1 1 1 1 1 1 1
1 1 0 1 1 0 0 1 1 1
1 1 1 1 1 0
1 1 1 1
1 1 1 1 1 1 0 1 1 1
1 1 1 1 1 1 0 0 1 1
1 0 1 1 1 1 0
1 1 1
The maximum number of spikes of some shape is: 37
$ python3 quiz_6.py
Enter two integers, the second one being strictly positive: 0 2
Here is the grid that has been generated:
1 1 0
1 1 1 1 1
1
0
0 1 0 0 1 0 1 0 0 1
1 0 1 1 1 0 1 1
1
0
0 0
1 0 1
1 0 1 0 0
0 0 0 1 0 0
1 1 0 1
1 0 1 0 1 1 0 1
1
0
1 0 0 0 0 1 1 0 0 0
0 0 0 1 1 0 0 1 1 1
1 1 0 1 0 1 1 0 0 0
1 0 0 1 0 1 1 0 0 0
The maximum number of spikes of some shape is: 78
$ python3 quiz_6.py
Enter two integers, the second one being strictly positive: 0 4
Here is the grid that has been generated:
1 1 0
1 1 1 1 1 1 1
1 1 1 0 1 1 1 0 0
1
 
1
0 1 1 1 1 1 1
1 0
0 0 1 0 1 1 1 1 0
1
1 1 1 1 0 0 1 1 0 1
1 0 1 1 1 1 0 1 1 1
1 1 1 1 0 1 1 0 0 1
1 0 0 1 1 1 1 1 1 1
1
1 0 1 0 1 1 1 1 0
 
1
0
1 1 1 1 1 0 0 1
The maximum number of spikes of some shape is: 8
$ python3 quiz_6.py
Enter two integers, the second one being strictly positive: 1 2
Here is the grid that has been generated:
0 0 1 0
1 1 1
1 0 0
1 0 1 1 0 1 1 0 0 1
0 0 0 0 1 0 1 0 0 1
1 0 1 0 0
1 1 0
1 0
0 1 0 1 1 0 1 1 1 1
0 1 0 1 1 0 1 1 0 1
0 0 1 1 1 0 1 0 1 1
0 0 0 0 0 0 1 1 1 1
1 0 1 0 0 1 0 1 1 0
1 1 1 1 1 0
1 1 0 0
The maximum number of spikes of some shape is: 59
$ python3 quiz_6.py
Enter two integers, the second one being strictly positive: 2 2
Here is the grid that has been generated:
0 0 0 1 0 1 1 0 0 0
1 1 1 1 1 0 0
1 1 1
1 1 0 0 0 0 0 0 1 0
0 1 0 1 1 1 1 1 1 0
1 1 0 1 1 1 1 1 1 1
1 1 0 1 0 1 1 1 1 1
1 0
1 1 0 1 0 0 0 0
0 1 0 0 0
1 0 0 0 1
0 0 1 1 0 0 0 0 0 0
0 0 0 1 1 0 0 0 0 1
The maximum number of spikes of some shape is: 4
请加QQ:99515681  邮箱:99515681@qq.com   WX:codinghelp