您的位置: 首页 > 科技

代写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
 
[ 编辑: code ]
03-17 业务推手:成功博主分享,WhatsApp如何简化流程,轻轻松松提升效果!
业务推手:成功博主分享,WhatsApp如何简化流程,轻轻松松提升效果!
 在这个快节奏的时代,博主们如何快速有效地推广业务,成为了他们共 [详细]
06-05 Instagram自动私信助手-Ins引流工具/ig精准推广软件
Instagram自动私信助手-Ins引流工具/ig精准推广软件
这款Instagram营销软件是一种多功能的工具,能够满足现代社交媒体 [详细]
05-20 博主亲身验证揭示市场趋势, WtApp工具智慧之选助力业务迅猛发展
博主亲身验证揭示市场趋势, WtApp工具智慧之选助力业务迅猛发展
在这个信息爆炸的时代,如何快速、准确地把握市场趋势,是每个企业家 [详细]
05-25 外贸初体验 揭秘WhatsApp拉群营销工具,点燃我的好奇心
外贸初体验 揭秘WhatsApp拉群营销工具,点燃我的好奇心
刚踏入外贸领域的我,Ws对一切充满了好奇与期待。而在这次初体验中 [详细]