首页
资讯
科技
财商
汽车
文娱
生活
>
科技
代写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 s
trictly
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
3
$
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:
7
4
$
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:
5
5
$
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
6
Test Cases Explained
$
python3 quiz_6.py
Enter two integers, the second one being s
trictly
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:
3
7
$
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:
7
8
$
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:
5
9
$
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
相关推荐
福建老板卖鞋服年入140亿
AMD和英特尔并未出现在中国信息安全评估中心批准的处理器名单中
想必不用我说,大家也知道淀粉肠的江湖地位了吧
老杨第一次再度抓握住一瓶水,他由此产生了新的憧憬
Intalight赛炜斩获MedTech全球最佳眼底影像设备品牌