Question: Complete the following tasks with documentation. The documentation / commenting must consist of ( but is not limited to ) : For each function, high
Complete the following tasks with documentation. The documentationcommenting must consist of but is not limited to:
For each function, highlevel description of that function. This should be a two or three
sentence explanation of what this function does.
Your main function in the assignment should contain a generalised description of the
approach your solution uses to solve the assignment task.
For each function, specify what the input to the function is and what output the function
produces or returns if appropriate
For each function, the appropriate BigO or BigTheta time and space complexity of that
function, in terms of the input size. Make sure you specify what the variables involved
in your complexity refer to Remember that the complexity of a function includes the
complexity of any function calls it makes.
Within functions, comments where appropriate.
You are an adventurer in FITWORLD a magical world where humans and FITMONs live in
harmony. FITMONs are insanely cute creatures which make everyone around them happy.
Each FITMON has a cutenessscore where a higher score means a cuter FITMON.
Recently, it was discovered that it is possible to fuse FITMONs together. The fusing process
could increase or decrease the cutenessscore of the resulting FITMON. Thus, you set out to
fuse FITMONs together, to create the very cutest FITMON possible, that no FITMON ever
was. In order to do so you head over to a FITMON Center.
Input
You have a list of fitmons:
Contains N fitmon in the list N N is a nonzero, positive integer where N
Each fitmon is identified by their index in the fitmons list.
Each fitmon in the list is a list of values
affinityleft, cutenessscore, affinityright
affinityleft is a positive float in the range of inclusive. Only the leftmost
fitmons will have an affinityleft of as there is no fitmon on the left for it to
fuse.
affinityright is a positive float in the range of inclusive. Only the rightmost
fitmonsN will have an affinityright of as there is no fitmon on the right for
it to fuse.
cutenessscore is a nonzero, positive integer.
An example of the input list fitmons is illustrated below:
fitmons
In this input, fitmons has a:
affinityleft of
cutenessscore of
affinityright of
Fusing Logic
From the fitmons list, you realize that each fitmon can only fuse with the adjacent fitmon in
the adjacent fitmon. Your goal is to fuse all of the given fitmons into only fitmon. Thus:
fitmonsi can only fuse with either fitmonsi or fitmonsi
The affinity for the fusing fitmons are the same as illustrated in the example input. We
see that fitmonsi would have the same value as fitmonsi and similarly
fitmonsi would have the same value as fitmonsi
However, fitmons can only fuse with fitmons as there is no fitmon on its left.
Likewise, fitmonsN can only fuse with fitmonsN as there is no fitmons on its
right.
Once a fitmon is fused, it no longer exist and thus cannot be used for fusing again.
When fitmons fuse, their cuteness changes based on their cutenessscore and the affinity
of the fuse. Fusing fitmonsi with fitmonsi will create a new fitmon with:
The affinityleft will be based on the affinityleft of the left fitmon,
affinityleft fitmonsi
The cutenessscore is computed using the affinityscore of the fusing fitmons multiplied with their cutenessscore based on the following equation,
cutenessscore fitmonsi fitmonsi
fitmonsi fitmonsi
The affinityright will be based on the affinityright of the right fitmon,
affinityright fitmonsi
Note: as the cutenessscore is an integer, you can use int on it after each and every
fuse; before the next fuse if any
Using the example input earlier:
Fusing fitmons with fitmons will produce a fitmon with the value of
Fusing fitmons with fitmons will produce a fitmon with the value of
Fusing fitmons with fitmons will produce a fitmon with the value of
Therefore, you implement a function called fusefitmons which accepts the list fitmons and
this function would fuse all of the fitmon in the list into a single ultimate final fitmon. The
resulting fitmon will have the highest possible cutenessscore from the fusing.
Output
The fusefitmons function would return an integer, where it is the cutenessscore of the
highest possible cutennessscore from fusing all of the fitmons if there are N fitmonns
then you would need N fuses in total.
Complexity
The function fusefitmons must run at the worstcase, ON
time and ON
space where
N is the number of items the list fitmons. It is possible for your solution to run better than
the complexity stated here.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
