首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
COMP9021代做、Python程序语言代写
项目预算:
开发周期:
发布时间:
要求地区:
COMP9021 Principles of Programming
Term 1, 2024
Coding Quiz 1
Worth 4 marks and due Week 3 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. The current code will generate a mapping (that is, a
dictionary) based on a seed and an upper bound values provided by the user. Your task is to process the
list of cycles based on the generated mapping and the reversed dictionary as described below.
Marking
List of Cycles 2 marks
Reversed Dictionary 2 marks
--------------------------------------------
Total 4 marks
Due Date and Submission
Quiz 1 is due Week 3 Thursday 29 February 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 3 Sunday 3 March 2024 @ 9pm will be discarded.
Make sure not to change the filename quiz_1.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 1.
Test Cases
$ python quiz_1.py
Enter two integers: 0 4
The generated mapping is:
{2: 3, 4: 1}
The keys are, from smallest to largest:
[2, 4]
Properly ordered, the cycles given by the mapping are:
[]
The (triply ordered) reversed dictionary per lengths is:
{1: {1: [4], 3: [2]}}
$ python quiz_1.py
Enter two integers: 0 6
The generated mapping is:
{1: 1, 3: 3, 5: 6, 6: 6}
The keys are, from smallest to largest:
[1, 3, 5, 6]
Properly ordered, the cycles given by the mapping are:
[[1], [3], [6]]
The (triply ordered) reversed dictionary per lengths is:
{1: {1: [1], 3: [3]}, 2: {6: [5, 6]}}
$ python quiz_1.py
Enter two integers: 0 11
The generated mapping is:
{2: 7, 3: 11, 4: 10, 5: 10, 7: 2, 9: 5, 10: 10, 11: 5}
The keys are, from smallest to largest:
[2, 3, 4, 5, 7, 9, 10, 11]
Properly ordered, the cycles given by the mapping are:
[[2, 7], [10]]
The (triply ordered) reversed dictionary per lengths is:
{1: {2: [7], 7: [2], 11: [3]}, 2: {5: [9, 11]}, 3: {10: [4, 5, 10]}}
$ python quiz_1.py
Enter two integers: 10 9
The generated mapping is:
{1: 5, 2: 6, 3: 5, 4: 5, 5: 6, 6: 7, 7: 1, 9: 6}
The keys are, from smallest to largest:
[1, 2, 3, 4, 5, 6, 7, 9]
Properly ordered, the cycles given by the mapping are:
[[1, 5, 6, 7]]
The (triply ordered) reversed dictionary per lengths is:
{1: {1: [7], 7: [6]}, 3: {5: [1, 3, 4], 6: [2, 5, 9]}}
$ python quiz_1.py
Enter two integers: 20 11
The generated mapping is:
{2: 4, 3: 9, 4: 4, 5: 8, 6: 2, 7: 5, 8: 11, 9: 1, 10: 10, 11: 5}
The keys are, from smallest to largest:
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
Properly ordered, the cycles given by the mapping are:
[[4], [5, 8, 11], [10]]
The (triply ordered) reversed dictionary per lengths is:
{1: {1: [9], 2: [6], 8: [5], 9: [3], 10: [10], 11: [8]},
2: {4: [2, 4], 5: [7, 11]}}
$ python quiz_1.py
Enter two integers: 50 15
The generated mapping is:
{1: 5, 2: 14, 3: 15, 4: 3, 5: 5, 6: 5, 7: 15, 8: 6, 9: 10, 10: 15, 11: 12,
12: 15, 13: 14, 14: 8, 15: 9}
The keys are, from smallest to largest:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
Properly ordered, the cycles given by the mapping are:
[[5], [9, 10, 15]]
The (triply ordered) reversed dictionary per lengths is:
{1: {3: [4], 6: [8], 8: [14], 9: [15], 10: [9], 12: [11]},
2: {14: [2, 13]},
3: {5: [1, 5, 6]},
4: {15: [3, 7, 10, 12]}}
$ python quiz_1.py
Enter two integers: 12 38
The generated mapping is:
{1: 11, 2: 13, 3: 38, 4: 38, 5: 6, 6: 36, 7: 9, 8: 37, 9: 4, 10: 9, 11: 36,
12: 6, 13: 3, 15: 29, 16: 8, 17: 13, 19: 22, 20: 3, 21: 38, 22: 33, 24: 12, 25:
4, 27: 11, 28: 23, 29: 22, 30: 3, 31: 11, 32: 17, 33: 9, 34: 26, 35: 30, 36:
31, 37: 22, 38: 37}
The keys are, from smallest to largest:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 19, 20, 21, 22, 24,
25, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38]
Properly ordered, the cycles given by the mapping are:
[[4, 38, 37, 22, 33, 9], [11, 36, 31]]
The (triply ordered) reversed dictionary per lengths is:
{1: {8: [16],
12: [24],
17: [32],
23: [28],
26: [34],
29: [15],
30: [35],
31: [36],
33: [22]},
2: {4: [9, 25], 6: [5, 12], 13: [2, 17], 36: [6, 11], 37: [8, 38]},
3: {3: [13, 20, 30],
9: [7, 10, 33],
11: [1, 27, 31],
22: [19, 29, 37],
38: [3, 4, 21]}}
$ python quiz_1.py
Enter two integers: 34 56
The generated mapping is:
{1: 34, 2: 8, 3: 35, 4: 11, 5: 28, 6: 47, 7: 24, 9: 27, 10: 38, 11: 4, 12:
38, 15: 4, 16: 55, 17: 39, 19: 35, 20: 55, 23: 22, 24: 33, 25: 2, 26: 12, 27:
35, 28: 13, 29: 1, 30: 53, 31: 38, 32: 2, 33: 29, 34: 12, 35: 1, 36: 8, 37: 48,
38: 55, 39: 33, 40: 42, 41: 41, 43: 25, 44: 50, 45: 56, 47: 6, 48: 35, 49: 5
2, 50: 4, 51: 1, 52: 40, 53: 43, 54: 17, 55: 48, 56: 41}
The keys are, from smallest to largest:
[1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 15, 16, 17, 19, 20, 23, 24, 25, 26, 27,
28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 43, 44, 45, 47, 48,
49, 50, 51, 52, 53, 54, 55, 56]
Properly ordered, the cycles given by the mapping are:
[[1, 34, 12, 38, 55, 48, 35], [4, 11], [6, 47], [41]]
The (triply ordered) reversed dictionary per lengths is:
{1: {6: [47],
11: [4],
13: [28],
17: [54],
22: [23],
24: [7],
25: [43],
27: [9],
28: [5],
29: [33],
34: [1],
39: [17],
40: [52],
42: [40],
43: [53],
47: [6],
50: [44],
52: [49],
53: [30],
56: [45]},
2: {2: [25, 32],
8: [2, 36],
12: [26, 34],
33: [24, 39],
41: [41, 56],
48: [37, 55]},
3: {1: [29, 35, 51], 4: [11, 15, 50], 38: [10, 12, 31], 55: [16, 20, 38]},
4: {35: [3, 19, 27, 48]}}
Hints
(1) The cycles
A cycle is a path that starts and ends with the same key.
Similarly, a path of length at least 1 in which no key appears more than once, except the first key is the same as the
last key, is called a cycle.
A cycle is a list of keys [k1, k2, k3, …, kn] where the first key k1 of the list is the value of the last
key kn, that is, the following key:value elements must exist in the mapping (or dictionary):
k1: k2, k2: k3, …, kn-1: kn, and kn: k1
For instance, in the example with 10 9 as input, there is one cycle:
[1, 5, 6, 7]
since the following key: value elements are in the mapping (or dictionary):
{1: 5}, {5: 6}, {6: 7}, and {7: 1}
Make sure when recording the cycle do not repeat the first key at the end, that is, for the following cycle:
1 5 6 7 1
{1:5} {5:6} {6:7} {7:1}
It should be recorded as [1, 5, 6, 7] not [1, 5, 6, 7, 1]
Please also note that the keys in the cycle are not necessarily ordered. The only requirement is that the first
elements of the cycles are in order (and not the elements within the cycle) as shown in the example with 12 38 as
input:
[[4, 38, 37, 22, 33, 9], [11, 36, 31]]
The two cycles above are not ordered. However, looking at the first elements of the cycles only, the two cycles are
ordered since 4 is smaller than 11.
(2) The (triply ordered) reversed dictionary per lengths
For instance, in the example with 0 4 as input:
The generated mapping is:
{2: 3, 4: 1}
The (triply ordered) reversed dictionary per lengths is:
{1:[4], 3:[2]} first generate the reversed dictionary
{1: {1: [4], 3: [2]}} final result
In the example with 0 6 as input:
The generated mapping is:
{1: 1, 3: 3, 5: 6, 6: 6}
The (triply ordered) reversed dictionary per lengths is:
{1:[1], 3:[3], 6:[5,6]} first generate the reversed dictionary
{1: {1: [1], 3: [3]}, 2: {6: [5, 6]}} final result
Triply ordered because there are three levels of sorting:
• level 1: per length which is the key of the outer dictionary
• level 2: per original value which is the key of the inner dictionary
• level 3: the values of the inner dictionary which are lists are sorted
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代写dts207tc、sql编程语言代做
2024-12-25
cs209a代做、java程序设计代写
2024-12-25
cs305程序代做、代写python程序...
2024-12-25
代写csc1001、代做python设计程...
2024-12-24
代写practice test preparatio...
2024-12-24
代写bre2031 – environmental...
2024-12-24
代写ece5550: applied kalman ...
2024-12-24
代做conmgnt 7049 – measurem...
2024-12-24
代写ece3700j introduction to...
2024-12-24
代做adad9311 designing the e...
2024-12-24
代做comp5618 - applied cyber...
2024-12-24
代做ece5550: applied kalman ...
2024-12-24
代做cp1402 assignment - netw...
2024-12-24
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!