Fix: Ensure all skills are tracked as files, not submodules
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
def Strongest_Extension(class_name, extensions):
|
||||
"""You will be given the name of a class (a string) and a list of extensions.
|
||||
The extensions are to be used to load additional classes to the class. The
|
||||
strength of the extension is as follows: Let CAP be the number of the uppercase
|
||||
letters in the extension's name, and let SM be the number of lowercase letters
|
||||
in the extension's name, the strength is given by the fraction CAP - SM.
|
||||
You should find the strongest extension and return a string in this
|
||||
format: ClassName.StrongestExtensionName.
|
||||
If there are two or more extensions with the same strength, you should
|
||||
choose the one that comes first in the list.
|
||||
For example, if you are given "Slices" as the class and a list of the
|
||||
extensions: ['SErviNGSliCes', 'Cheese', 'StuFfed'] then you should
|
||||
return 'Slices.SErviNGSliCes' since 'SErviNGSliCes' is the strongest extension
|
||||
(its strength is -1).
|
||||
Example:
|
||||
for Strongest_Extension('my_class', ['AA', 'Be', 'CC']) == 'my_class.AA'
|
||||
"""
|
||||
strongest_ext = None
|
||||
max_strength = None
|
||||
|
||||
for ext in extensions:
|
||||
cap = sum(1 for c in ext if c.isupper())
|
||||
sm = sum(1 for c in ext if c.islower())
|
||||
strength = cap - sm
|
||||
|
||||
if max_strength is None or strength > max_strength:
|
||||
max_strength = strength
|
||||
strongest_ext = ext
|
||||
|
||||
return f"{class_name}.{strongest_ext}"
|
||||
Reference in New Issue
Block a user