Login and get codingPyBites is starting a campaign to try and pair up the highest ranking Ninjas with some of the lower ranking ones. Your task is to rank the given Ninjas according to their number of Bites.
We are going to delve into some Object Oriented Programming here because we want to retain state as we add more Ninjas to the
Ranking
class.I have laid out the structure of the script for you. Your task is to flesh out the
Ninja
andRankings
classes.The
Ninja
class will have the following features:
- string
name
- integer
bites
- support
<
,>
, and==
, based onbites
- print out in the following format:
[469] bob
The
Rankings
class will have the following features:
- method
add()
that adds a Ninja object to the rankings- method
dump()
that removes/dumps (and returns) the lowest ranking Ninja from Rankings- method
highest()
returns the highest rankingNinja
, but it takes an optionalcount
parameter indicating how many of the highest ranking Ninjas to return- method
lowest()
, the same as highest but returns the lowest ranking Ninjas, also supports an optionalcount
parameter
returns how many Ninjas are in Rankings whenlen()
is called on it- a
pair_up()
method that pairs up study partners: the highest with the lowestNinja
of theranking
instance, then the second highest with the second lowestNinja
of theranking
etc. It takes an optional count parameter indicating how many Ninjas to pair up (default =3
).Remember, that the standard library is your friend, best of luck!
145 out of 147 users completed this Bite.
Will you be the 146th person to crack this Bite?
Resolution time: ~81 min. (avg. submissions of 5-240 min.)
Our community rates this Bite 7.12 on a 1-10 difficulty scale.
» Up for a challenge? 💪